No matter how I open an xlsx, either populated or blank file, with the code below I get the errors second below shortened. My pom dependencies are third below. I am nonplussed. Do I downgrade the dependencies? The HSSF code works fine.
try {
in = currentFile.getInputStream();
try {
pkg00 = OPCPackage.open(in);
} catch (InvalidFormatException e) {
e.printStackTrace();
}
currentWb = new XSSFWorkbook(pkg00); //need to close with OPCPackage pkg00.close()
//currentWb = (XSSFWorkbook) WorkbookFactory.create(in);
currentSheet = currentWb.getSheetAt(0);
cleanWb = new XSSFWorkbook();
cleanSheet = cleanWb.createSheet();
} catch (IOException e) {
e.printStackTrace();
}
the save code:
try {
String path = createPath(markingDir,currentName,fileNum,null,null).toString();
pkg00.save(new FileOutputStream(new File(createPath(markingDir,currentName,fileNum,null,null).toString())));
} catch (IOException e) {
e.printStackTrace();
}
//createSerialFileName(markingDir, currentName, fileNum, cleanWb, null);
fileNum++;
filesProcessed++;
Wed Jul 01 15:30:35 EDT 2020 There was an unexpected error (type=Internal Server Error, status=500). java.nio.charset.spi.CharsetProvider: Provider com.spire.ms.charsets.CharsetProvider not found java.util.ServiceConfigurationError: java.nio.charset.spi.CharsetProvider: Provider com.spire.ms.charsets.CharsetProvider not found
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
I moved over to the hetrogenous ".ss." workbook and sheet in 4.12 and it saved wop. As a note that may be helpful, in my specific data case an xlsx with a blank line does not even add a null row but skips the row increment so to duplicate exactly, in my case, you would need to track the row number and where there is a missing increment explicitly insert a row. This is impt to the parsing as it breaks on the first blank cell in a column. fth.