【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,一次赋值  多次使用。。。。每次使用的时候,判断对象是否有值,如果没有就创建并赋值,缓存下来。如果有,直接使用!!!

相关文章
|
10月前
|
缓存 druid 中间件
【YashanDB知识库】由于druid中间件配置导致的YAS-04003 maximum number of open cursors is 1000
【YashanDB知识库】由于druid中间件配置导致的YAS-04003 maximum number of open cursors is 1000
【YashanDB知识库】由于druid中间件配置导致的YAS-04003 maximum number of open cursors is 1000
|
10月前
【YashanDB知识库】YAS-04003 maximum number of open cursors is xxx
【YashanDB知识库】YAS-04003 maximum number of open cursors is xxx
【YashanDB知识库】YAS-04003 maximum number of open cursors is xxx
|
11月前
|
缓存 druid 中间件
【YashanDB 知识库】由于 druid 中间件配置导致的 YAS-04003 maximum number of open cursors is 1000
某客户Java业务运行时出现YAS-04003异常,导致业务无法正常运行,影响所有yashandb版本。原因是druid中间件配置不当,缓存PreparedStatement导致YashanDB open cursor超限。解决方法:增加OPEN_CURSORS参数值或修改druid配置,如将share-prepared-statements和pool-prepared-statements设为false。处理过程涉及查询vopen_cursor和v$sql视图,确认业务会话。经验总结:需结合Java框架及中间件配置与数据库视图分析行为。
|
11月前
【YashanDB 知识库】YAS-04003 maximum number of open cursors is xxx
**简介:** 应用运行时遇到错误“YAS-04003 maximum number of open cursors is 310”,原因是打开的游标数量超过默认限制(310)。建议检查代码,确保及时关闭不再使用的游标。如需增加限制,可通过命令 `alter system set OPEN_CURSORS=320;` 调整参数值。请参考官方文档以确定合适的数值。
|
关系型数据库 MySQL
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
Mysql报错:InnoDB: Operating system error number 13 in a fil..的解决方法
819 0
|
安全 前端开发 网络安全
【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处理公网请求。在复杂环境中,需仔细排查和适配规则。
633 11
从键盘上输入10个整数,写入到一个文件number.txt中,然后从此文件读出数据,显示在屏幕上。
从键盘上输入10个整数,写入到一个文件number.txt中,然后从此文件读出数据,显示在屏幕上。
374 0
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
381 0
|
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,
833 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
319 0