在用POI导出Excel表格时,报如下错误:
Caused by: java.lang.IllegalStateException: The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook
原因:style创建次数太多。
改进方法:现在循环外,创建style,然后在循环中再用样式。
修改前代码,如下所示,当数据不是很大时,系统不会提示出错,但当数据很大时,就会报错。
public class CellValue { public static HSSFWorkbook setValue (ExcelEntity g) { List<LinkedHashMap<String,Object>> list = g.getList(); HSSFWorkbook workbook = g.getWb(); /*HSSFSheet sheet = workbook.getSheet(g.getStr());*/ HSSFSheet sheet = workbook.getSheetAt(0); for(int i=0;i<list.size();i++) { LinkedHashMap<String,Object> map3 = list.get(i); HSSFRow contentRow = sheet.createRow(i+4); int j=0; for (Iterator<String> it = map3.keySet().iterator();it.hasNext();) { Object key = it.next(); HSSFCell NameContent = contentRow.createCell(j); System.out.println(map3.get(key)); NameContent.setCellValue((String)map3.get(key)); NameContent.setCellStyle(ExcelStyle.getContentStyle(workbook)); j++; } } return workbook; } }
修改后代码:
HSSFCellStyle contentStyle = ExcelStyle.getContentStyle(workbook); for(int i=0;i<list.size();i++) { LinkedHashMap<String,Object> map3 = list.get(i); HSSFRow contentRow = sheet.createRow(i+4); int j=0; for (Iterator<String> it = map3.keySet().iterator();it.hasNext();) { Object key = it.next(); HSSFCell NameContent = contentRow.createCell(j); System.out.println(map3.get(key)); NameContent.setCellValue((String)map3.get(key)); NameContent.setCellStyle(contentStyle); j++; } }
相关推荐
The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook
The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook is a wrong excepiton 将抛异常的方法去掉,是程序继续执行,生成excel 。本来想免费,但是苦于没积分所以...
解决常见的破解不完全问题:The maximum number of licenses has been exceeded for the following servers 弹窗! 将此文件替换安装目录C:\Program Files\Design Explorer 99 SE,如当初安装protel99时自定义了安装...
报错:Job for sshd.service failed because a timeout was exceeded. See "systemctl status sshd.service" and "journalctl -xe" for details. 问题2:程序sftp登陆不上 低版本的连接工具无法连接,现有程序sftp到...
整个unity里面的shader的#pragma multi xxxxx_ON 关键字不能超过256个,给系统添加负担...所以会报错:maximum number (256) of shader keywords exceeded unity。 做法是减少关键字的使用。 下面提供一个优化工具。
The boot.ini option /3GB was created for those cases where systems actually support greater than 2 GB of physical memory and an application can make use of it This capability allows memory intensive ...
This property can be assigned by a maximum time, which will be used to calculate the widths of the columns when the user double click on the line that separates columns. If the time of calculation ...
主要介绍了详解 Java Maximum redirects (100) exceeded的相关资料,需要的朋友可以参考下
- Updated the detection of Hyperthreading and the number of logical CPUs for a new Intel CPU. Release 5.3 build 1025 WIN32 release 11 July 2008 - Corrected a Disk test bug where on rare occasions a...
Maximum最大值
code to perform actions whenever an output node's threshold is exceeded. It could include code to generate events (rather than read them from a file). And it could include code to describe more ...
The best way to organize your feeds is up to you. == Screenshots == 1. Dashboard 2. Campaigns list 3. Add campaign main tab 4. Add campaign feeds tab 5. Add campaign categories tab 6. Add campaign ...
- The own address of CIF50 MPI/PB communication way was limited to 31. Now the limit is 126. - Bug-fix in PG-PC Interface (CP5611) communication way. Device could be disabled from polling, after ...
最近做的程序中涉及到的循环比较多且处理的情况较复杂,在运行程序时出现执行超时提示如下:Fatal error: Maximum execution time of 30 seconds exceeded in D:phpAppServwwwsum3test.php on line 3通过在网上搜索...
This exposure may or may not result in a catastrophic failure of the item." Typically, it can be inferred that an overstress has occurred when an item fails to meet its electrical characteristics....
Initially the first article was an experiment and the result of it exceeded all my expectations. I want to thank all readers who left comments and wrote emails, your opinions were really important ...
导入导出、合并单元格处理代码示例 jar包解决导出Excel 出现的问题:Warning: Maximum number of format records exceeded. Using default format.
Film cooling was modeled to allow performance prediction of scramjet engine design. The model was based on experimental results of the compressible mixing layer for the vicinity of the injection slot,...
See how to define your wireless network boundaries, and monitor to know if they're being exceeded and watch for unauthorized traffic on your network. *Covers the top 10 most popular open source ...