I am very new to Apache POI. I am using Apache version 3.15. I am trying to read the .xlsm file. My code is as below. The error I am getting is different than the other link. Also the solution given in that duplicate link ([Apache POI Parsing error]) is not working for me.
String fileToRead_String = "C:\\Users\\vchaudh1\\Template\\template.xlsm";
File fileToRead_File = new File(fileToRead_String);
try{
FileInputStream fIP = new FileInputStream(fileToRead_File);
System.out.println("fIP.available() ="+ fIP.available());
XSSFWorkbook workbook;
workbook = new XSSFWorkbook(fIP);
FileOutputStream fileout = new FileOutputStream(fileToRead_String);
fileout.write(10);
workbook.write(fileout);
fileout.close();
System.out.println("xlsm created successfully........");
workbook.close();
}
catch(FileNotFoundException e){
System.out.println("exception is:::"+e);
}
I am getting following error at the line "workbook = new XSSFWorkbook(fIP);"
ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service Uncaught service() exception thrown by servlet ActionServlet: java.lang.IllegalAccessError: Class org/apache/poi/openxml4j/opc/PackageRelationshipCollection illegally accessing "protected" member of class org/apache/poi/util/POILogger
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection.java:313)
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:163)
at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:131)
at org.apache.poi.openxml4j.opc.PackagePart.loadRelationships(PackagePart.java:561)
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:109)
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:80)
at org.apache.poi.openxml4j.opc.PackagePart.<init>(PackagePart.java:125)
at org.apache.poi.openxml4j.opc.ZipPackagePart.<init>(ZipPackagePart.java:78)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:243)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:684)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:266)
Can anybody please suggest me anything where I am doing wrong? or what am I missing here?