我想将一个布尔值写入 excel 单元格,但不是将 cellStyle 设置为“逻辑”,而是将 cellStyle 变为“数字”。
private void writeToDocument(XSSFWorkbook workbook) {
Sheet sheet = workbook.createSheet("testSheet");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(true);
}
Run Code Online (Sandbox Code Playgroud)
我已经试过了
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setDataFormat([short s]);
cell.setCellStyle(cellStyle);
Run Code Online (Sandbox Code Playgroud)
但是没有 0 到 49 之间的 short s 完成了这项工作。