在用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 is a wrong excepiton 将抛异常的方法去掉,是程序继续执行,生成excel 。本来想免费,但是苦于没积分所以...
描述中的信息进一步解释了这个问题:“The maximum number of cell styles was exceeded. You can define up to 4000 styles in a .xls workbook”。这意味着当尝试创建更多的单元格样式时,系统会报错,因为`.xls`...
解决常见的破解不完全问题: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”的错误。这通常是由于服务启动超时或者配置问题导致的。解决方法包括检查sshd的状态(`systemctl status sshd.service`)和日志...
整个unity里面的shader的#pragma multi xxxxx_ON 关键字不能超过256个,给系统添加负担...所以会报错:maximum number (256) of shader keywords exceeded unity。 做法是减少关键字的使用。 下面提供一个优化工具。
"Java Maximum redirects (100) exceeded" Java Maximum redirects (100) exceeded是指在Java中使用HttpClient进行网络请求时,遇到的最大重定向次数限制问题。该问题的主要原因是HttpClient的默认设置中,最大...
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 ...
Maximum file size of X KB exceeded(解决方案).md
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 ...
- 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...
在IT领域,尤其是在编程与数据处理中,“Maximum最大值”是一个极为重要的概念,它涉及到如何在一组数值或数据集合中找到最大的元素。这个概念在多种编程语言和算法中都有广泛的应用,例如在Java、Python、C++等语言...
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通过在网上搜索...
### Protel99se 序列号及其在局域网中的应用 #### 一、Protel99se简介 Protel99SE是一款由Altium公司开发的专业电路设计软件,广泛应用于电子工程领域,用于原理图绘制、PCB设计、信号完整性分析等方面。...
- When the menu was brought, I was shocked at the prices, which far exceeded my expectations. - Effective measures must be taken immediately to eliminate sandstorms. 4. 情态动词: - The phone is ...
在Hive on Spark作业中,如果遇到`Failed to get a spark session`,可能是因为YARN资源在某些时段紧张。一种解决方法是增加Hiveserver2中的`hive.spark.client.server.connect.timeout`参数,将其设为更长的时间,...
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 ...