I am trying to generate excel file for displaying TestNG report into excel sheet.
For that I created simple program for creating excel sheet and display static data, but it's displaying error
I am trying to generate excel file for displaying TestNG report into excel sheet.
For that I created simple program for creating excel sheet and display static data, but it's displaying error
I am following this steps and it is running fine.
1. Need below jar files :
2. Use JRE 7 and Higher
3. Write following code for it as under :
import java.io.File;
import java.io.FileOutputStream;
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;
public class WriteData
{
public static void main(String args[])
{
try
{
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sh1 = wb.createSheet("Sheet1");
Row row = sh1.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("Selenium");
try
{
//Write the workbook in file system
FileOutputStream out = new FileOutputStream(new File("E:\\Data.xls"));
wb.write(out);
out.close();
System.out.println("written successfully on disk.");
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Note : Do not use jxl jar and imports.