我想使用apache poi(vesrion 3.7)格式化生成的excel文件(使用动态报告生成)。我在格式化excel时基本上面临两个问题。
如何在excel报告中使用apache poi实现这两件事?
任何帮助将不胜感激。
提前致谢!
此致
Shikha Singhal
答案 0 :(得分:0)
问题1:存储为文本警告的数字:
将单元格类型设置为Numeric:
Cell cell = sheet.getRow(0).createCell(2);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellValue(12345);
问题2:Cell的左缩进
XSSFCellStyle style = workbook.createCellStyle();
style.setAlignment(CellStyle.ALIGN_LEFT);
cell.setCellStyle(style);