-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteExcel.java
More file actions
35 lines (21 loc) · 806 Bytes
/
WriteExcel.java
File metadata and controls
35 lines (21 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.demoqa.dataUtile;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class WriteExcel {
public void writeData(String sheetName, String cellValue, int row, int col) throws IOException {
String excelPath = "./test-data/Login-data.xlsx";
File file = new File(excelPath);
FileInputStream fis = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet = wb.getSheet(sheetName);
sheet.getRow(row).createCell(col).setCellValue(cellValue);
FileOutputStream fos = new FileOutputStream(file);
wb.write(fos);
wb.close();
fos.close();
}
}