gpt4 book ai didi

java - 增加列的宽度而不是指数值

转载 作者:行者123 更新时间:2023-11-30 11:31:01 25 4
gpt4 key购买 nike

我有一个问题是,我生成了一个包含许多数据列的 Excel 工作表。现在有一个名为 abc_ID 的列,来自后端的值是 long 类型,如下所示

//shown below how the value is passed for that column
private Long abc_Id;
abcdeed.abc_Id(13243534540L);

HSSFCellStyle[] cellStyles = new HSSFCellStyle[11];
HSSFCellStyle styleHeader = null;
HSSFCellStyle styleHeaderRBorder = null;
HSSFCellStyle cellStyleReportName = null;
HSSFCellStyle cellStyle00 = null;
HSSFCellStyle style_WhiteBg = null;

并且我已经设置了以下 abc_ID 列的单元格样式

if(columnHeaders[i].equals("abc_Id") && abcdeed.getabc_Id() != null){
cell.setCellValue(abcdeed.getabc_Id());
cell.setCellStyle(cellStyles[9]);

现在的问题是,当最终生成 excel 工作表时,当我首先打开该 excel 工作表时,列 abc_Id 的值看起来是压缩的,其中的值最初是指数类型,这是因为该列是压缩类型 I希望列宽应该扩大一个并且值不应该是指数类型,我试图增加 cellStyles 但它不起作用。请提出解决方案。

最佳答案

在该特定单元格的所有行中使用 CELL_TYPE_STRING。

 rows.getCell(abc_Id_Cell_No).setCellType(Cell.CELL_TYPE_STRING);

最后

 Sheet.autoSizeColumn(abc_Id_Cell_No);

这会将所有单元格值更改为字符串,autoSizeColumn 将调整该列的宽度。

关于java - 增加列的宽度而不是指数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17439675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com