【POI】导出xls文件报错:The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook

简介: 使用POI导出xls文件,由于数据过多,导致导出xls报错如下:The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook  原因:代码中创建HSSFCellStyle cellStyle = hssfWorkbook.createCellStyle();次数过多,导致报错。

使用POI导出xls文件,由于数据过多,导致导出xls报错如下:

The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook 

 

原因:

代码中创建

HSSFCellStyle cellStyle = hssfWorkbook.createCellStyle();

次数过多,导致报错。

 

解决方法:

把创建HSSFCellStyle对象放在循环之外,或者放在全局,仅创建一次就可以多次使用。

或者可以把创建的相关对象全都提取为static,一次赋值  多次使用。。。。每次使用的时候,判断对象是否有值,如果没有就创建并赋值,缓存下来。如果有,直接使用!!!

相关文章
|
JSON 边缘计算 数据格式
KubeEdge安装加入边缘节点报错: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal number into
KubeEdge安装加入边缘节点报错: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal number into
412 0
|
6月前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
178 0
|
7月前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER(上海蓝云阻断页)
在Azure App Service上部署的应用遇到`SSL: WRONG_VERSION_NUMBER`错误。问题可能由不兼容的TLS版本引起,但即使将最小入站TLS版本改为1.2,问题仍存在。实际原因是上海蓝云的阻断页面,表明网站未完成ICP备案或有安全规定限制。解决方案包括:1) 对App Service绑定自定义域名并进行ICP备案,或2) 使用Application Gateway处理公网请求。在复杂环境中,需仔细排查和适配规则。
208 11
|
关系型数据库 MySQL
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
534 0
|
9月前
|
JavaScript 前端开发
完美解决 报错 Vue Invalid prop: type check failed for prop “min“. Expected Number with value 1,
完美解决 报错 Vue Invalid prop: type check failed for prop “min“. Expected Number with value 1,
326 1
|
JavaScript
vue 渲染列表报错Avoid using non-primitive value as key, use string/number value instead. found in
vue 渲染列表报错Avoid using non-primitive value as key, use string/number value instead. found in
145 0
|
Web App开发 JavaScript 前端开发
Edge浏览器报错IE解决 Expected identifier, string or number 配置 babel vue plugins Preset
Edge浏览器报错IE解决 Expected identifier, string or number 配置 babel vue plugins Preset
400 0
|
SQL 并行计算 数据库连接
ArcSWAT报错:Error Number :-2147467259; 对 COM 组件的调用返回了错误 HRESULT E_FAIL
ArcSWAT报错:Error Number :-2147467259; 对 COM 组件的调用返回了错误 HRESULT E_FAIL
|
API Android开发
Flutter导入第三方包后报错The number of method references in a .dex file cannot exceed 64K
Flutter导入第三方包后报错The number of method references in a .dex file cannot exceed 64K
|
算法
LeetCode 414. Third Maximum Number
给定一个非空数组,返回此数组中第三大的数。如果不存在,则返回数组中最大的数。要求算法时间复杂度必须是O(n)。
113 0
LeetCode 414. Third Maximum Number