我是Apache POI的新手。我使用的是Apache 3.15版。我正在尝试阅读.xlsm文件。我的代码如下。我得到的错误与其他链接不同。此重复链接([Apache POI Parsing error])中给出的解决方案也不适用于我。
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);
}
我在线上遇到以下错误 " 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)
有人可以告诉我任何我做错的事吗?或者我在这里失踪了什么?