I would like to write a boolean-value into an excel-cell, but instead of setting the cellStyle to "logic" the cellStyle will become "number" instead.
private void writeToDocument(XSSFWorkbook workbook) {
Sheet sheet = workbook.createSheet("testSheet");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(true);
}
I already tryied
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat([short s]);
cell.setCellStyle(cellStyle);
but no short s between 0 and 49 did the job.
When appropriate overloaded version of setCellValue
is used the cell types will be assigned automatically, for example
cell.setCellValue(true);
System.out.println(cell.getCellType());
prints BOOLEAN
Checked on org.apache.poi:poi:4.1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With