Kor*_*ler 5 java excel apache-poi
我想将一个布尔值写入 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 完成了这项工作。
小智 -1
使用以下代码获取布尔值
private void writeToDocument(XSSFWorkbook workbook) {
Sheet sheet = workbook.createSheet("testSheet");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellType(HSSFCell.CELL_TYPE_BOOLEAN);
cell.setCellValue((Boolean) true);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
759 次 |
| 最近记录: |