-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExcel.java
More file actions
40 lines (32 loc) · 972 Bytes
/
Excel.java
File metadata and controls
40 lines (32 loc) · 972 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
36
37
38
39
40
package project;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.WebDriver;
public class Excel {
WebDriver driver=null;
public Excel(WebDriver d)
{
driver=d;
}
public void putData(String s,List<String> a) throws IOException
{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(s);
int rownum = 0;
for(int i=0;i<a.size();i++)
{
Row row = sheet.createRow(rownum++);
Cell cell = row.createCell(0);
cell.setCellValue(a.get(i));
}
FileOutputStream out = new FileOutputStream(new File(System.getProperty("user.dir")+"\\Excel_File\\Book1.xlsx"));
workbook.write(out);
out.close();
}
}