https://bz.apache.org/bugzilla/show_bug.cgi?id=69473
Bug ID: 69473
Summary: SetCellStyle on DeferredSXSSFWorkbook is not working
Product: POI
Version: 5.3.0-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: SXSSF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 39943
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39943&action=edit
Contains generated file.xlsx, file2.xlsx and error produced by file2.xlsx
This method creates valid xlsx file:
public void get() {
try(OutputStream os = new FileOutputStream("C:\\excel\\file.xlsx"); var
workbook = new DeferredSXSSFWorkbook(100)) {
var outerSheet = workbook.createSheet();
outerSheet.setRowGenerator(sheet -> {
var row = sheet.createRow(0);
var cell = row.createCell(0);
cell.setCellValue("Hello");
var cell2 = row.createCell(1);
cell2.setCellValue("World");
});
workbook.writeAvoidingTempFiles(os);
workbook.dispose();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
This method generates corrupted xlsx file.
public void get2() {
try(OutputStream os = new FileOutputStream("C:\\excel\\file2.xlsx"); var
workbook = new DeferredSXSSFWorkbook(100)) {
var outerSheet = workbook.createSheet();
outerSheet.setRowGenerator(sheet -> {
var row = sheet.createRow(0);
var cell = row.createCell(0);
cell.setCellStyle(getBoldStyle(workbook));
cell.setCellValue("Hello");
var cell2 = row.createCell(1);
cell2.setCellValue("World");
});
workbook.writeAvoidingTempFiles(os);
workbook.dispose();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private CellStyle getBoldStyle(DeferredSXSSFWorkbook workbook) {
var font = workbook.createFont();
font.setBold(true);
var style = workbook.createCellStyle();
style.setFont(font);
return style;
}
It's possible the error is caused by czech locale on windows.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]