forked from CourseRepository/SeleniumWebdriverWithJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteToExcel.java
More file actions
43 lines (34 loc) · 1.11 KB
/
WriteToExcel.java
File metadata and controls
43 lines (34 loc) · 1.11 KB
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
41
42
43
package testcase;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* @author - rahul.rathore
* @date - 16-Nov-2014
* @project - Webdriver
* @package - testcase
* @file name - WriteToExcel.java
*/
public class WriteToExcel {
public static void main(String[] args) throws IOException {
File excel_file = new File("excel_file.xlsx");
FileOutputStream fout = new FileOutputStream(excel_file);
XSSFWorkbook book = new XSSFWorkbook(); // create workbook
XSSFSheet sheet = book.createSheet("Test Data Sheet"); // create the sheet
for(int i = 0; i < 4; i++){
XSSFRow row = sheet.createRow(i); //create the row
for(int j = 0; j < 4; j++){
XSSFCell cel = row.createCell(j); //create the column
cel.setCellValue("Data" + j); //set the cel value
}
}
book.write(fout);
fout.close();
System.out.println("File Created");
}
}