Hello! I’m converting xls files to csv with workbook.save() method in Java. And I cant find a proper way to get clear number from cells, where currency or financial formatting applied.
The only way I found is to clear custom style from whole workbook, but I’m not shure about performance. What if I need to load heavy document with million cells?
Thats my code to convert document:
File outFile = Files.createTempFile(“out_”, “.csv”).toFile();
workbook.save(outFile.getAbsolutePath(), SaveFormat.CSV);
Thats my code to clear whole worksheet:
for (int i = 0; i <= worksheet.getLastColumnIndex(); i++) {
for (int j = 1; j < worksheet.getRowsCount(); j++) {
Style cellStyle = worksheet.getCellStyle(j, i);
if (!cellStyle.isDateTime()) {
cellStyle.setCustom("");
worksheet.setCellStyle(j,i,cellStyle);
}
}
}
Any help to make it in proper way? Thank you.