public static void SetCellValue(int sheetNum, String coordinant, String newValue) throws IOException {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(new File("C:\\Users\\s.aga\\Desktop\\Reporting\\Ovs.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(fis);
XSSFSheet sheet = workbook.getSheetAt(sheetNum);
CellReference cellReference = new CellReference(coordinant);
Row row = sheet.getRow(cellReference.getRow());
Cell cell = row.getCell(cellReference.getCol());
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue(newValue);
fos = new FileOutputStream(new File("C:\\Users\\s.aga\\Desktop\\Reporting\\Ovs.xlsx"));
fis.close();
workbook.write(fos);
System.out.println("Done :" + coordinant);
fos.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
}
Exception in thread "main" org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:204)
at utils.Utils.SetCellValue(Utils.java:54)
at reporting.Reporting.doReporting(Reporting.java:108)
at reporting.Reporting.main(Reporting.java:250)
Caused by: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:178)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:662)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:269)