View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Danny Winbourne Danny Winbourne is offline
external usenet poster
 
Posts: 1
Default Maximum number of fonts exceeded in HSSFWorkBook

Thanks so much for the tip!
Was going mad trying to solve the issue, and your tip sorted it!

On Monday, October 27, 2008 5:42 PM S wrote:


Hi Team,

I am using HSSfWorkbook to create work books using POI API. It has been
working fine. But whenever the date is more and when I try to upload XL sheet
it is giving "
Maximum number of fonts have been exceeded error "

Any pointers in this regard are appreciated.
Thanks in Advance
SJ



On Tuesday, October 28, 2008 6:31 AM Joe wrote:


We get a similar message in one of our applications. I suspect that is is
due to a memory leak on the PC. It may or not be your application but
something else running on the PC. My solution is to reboot the PC before i
do any operations that may take a lot of memory or that has crashed
previously when I ran the application. Also when you run your macro close
all the unecessary apllications on the PC.

"SJ" wrote:



On Monday, November 09, 2009 10:21 PM senthil kumar A wrote:


Hi Guys ,

Following errorMessage has been arised for me also .

and from apache Site , i have fixed that error too .

I would like to share this information with you .



Wrong :



for (int i = 0; i < 10000; i++) {

Row row = sheet.createRow(i);

Cell cell = row.createCell((short) 0);

CellStyle style = workbook.createCellStyle();

Font font = workbook.createFont();

font.setBoldweight(Font.BOLDWEIGHT_BOLD);

style.setFont(font);

cell.setCellStyle(style);

}



Correct:



CellStyle style = workbook.createCellStyle();

Font font = workbook.createFont();

font.setBoldweight(Font.BOLDWEIGHT_BOLD);

style.setFont(font);

for (int i = 0; i < 10000; i++) {

Row row = sheet.createRow(i);

Cell cell = row.createCell((short) 0);

cell.setCellStyle(style);

}



Note : LOC of creating fonts is inside the loop , because when you are writing the records to the row. there is no need of keeping the font creation in loop , better move it outside the loop and try it . Sure popup message will not come in case of

large datas populated in the worksheet .

kindly let me know if any .



refURL : http://poi.apache.org/spreadsheet/quick-guide.html