I am using maven repository with dependency of apache poi-ooxml 3.15. I am not able to read/write due to error below.
My office is activated by the way.
Please help, Thanks
public static void saveIntoExcel(List<WebElement> title, List<WebElement> price) throws IOException, InvalidFormatException{
File file = new File("./file/ReadExcel.xlsx");
FileOutputStream fis = new FileOutputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(file);
XSSFSheet sheet = wb.getSheetAt(0);
System.out.println(sheet.getPhysicalNumberOfRows());
for(int i = 0; i < 30 ; i++){
int j = 0;
sheet.getRow(i+1).createCell(j).setCellValue(title.get(i).getText());
sheet.getRow(i+1).createCell(j+1).setCellValue(price.get(i).getText());
wb.write(fis);
}
wb.close();
org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries or contents found, this is not a valid OOXML (Office Open XML) file
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:290)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:774)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:308)