Return-Path: Delivered-To: apmail-jakarta-poi-user-archive@www.apache.org Received: (qmail 72421 invoked from network); 26 Jul 2006 13:23:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jul 2006 13:23:53 -0000 Received: (qmail 69312 invoked by uid 500); 26 Jul 2006 13:23:47 -0000 Delivered-To: apmail-jakarta-poi-user-archive@jakarta.apache.org Received: (qmail 69261 invoked by uid 500); 26 Jul 2006 13:23:46 -0000 Mailing-List: contact poi-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "POI Users List" Reply-To: "POI Users List" Delivered-To: mailing list poi-user@jakarta.apache.org Received: (qmail 69240 invoked by uid 99); 26 Jul 2006 13:23:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jul 2006 06:23:46 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=HTML_MESSAGE,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [195.55.186.11] (HELO helvetiaprevision.com) (195.55.186.11) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jul 2006 06:23:42 -0700 Received: from eshub01.helvetiaprevision.com ([10.1.1.50]) by gw.helvetia.es (gw.helvetia.es [127.0.0.1]) (MDaemon.PRO.v7.2.0.R) with ESMTP id md50004442447.msg for ; Wed, 26 Jul 2006 15:21:32 +0200 To: poi-user@jakarta.apache.org Subject: trouble with "Too many different cell formats" issue MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.5.5 November 30, 2005 Message-ID: From: EAstiz@helvetiaprevision.com Date: Wed, 26 Jul 2006 15:21:42 +0200 X-MIMETrack: Serialize by Router on ESHUB01/SRV/HPH(Release 6.5.4|March 27, 2005) at 26/07/2006 15:22:24, Serialize complete at 26/07/2006 15:22:24 Content-Type: multipart/alternative; boundary="=_alternative 004985BBC12571B7_=" X-MDRemoteIP: 10.1.1.50 X-Return-Path: EAstiz@helvetiaprevision.com X-MDaemon-Deliver-To: poi-user@jakarta.apache.org X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) X-Spam-Report: * 0.2 NO_REAL_NAME From: does not include a real name * 0.1 HTML_MESSAGE BODY: HTML included in message * -4.0 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0001] X-Spam-Level: X-Spam-Processed: gw.helvetia.es, Wed, 26 Jul 2006 15:21:35 +0200 X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, hits=-3.7 required=15.0 tests=BAYES_00,HTML_MESSAGE, NO_REAL_NAME autolearn=no version=2.64 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --=_alternative 004985BBC12571B7_= Content-Type: text/plain; charset="US-ASCII" Hello, While generating a spreadsheet with some sheets (about 10) and many data inserted into it, I got the following error when the created workbook was opened with MS Excel 2002: "Too many different cell formats". This is a well-known issue reported by microsoft saying that workbooks with more than 4000 different cell formats (or combinations as Microsoft calles them) can not be handled and therefore, formatting is disabled for the remaining cells. Everything ok up to the this point. I generate lots of data that are included in the workbook, more than 4000 data cells. However, I do not apply more than 20 different styles. According to Microsoft, two cells with the same format do not account as two different formats. Nevertheless, excel complains. Trying to find out a solution, first I set the same style to all the cells. When more than 4000 cells were created I came accross to the same error. Style stands for all font formatting (for example: typeface, font size, italic, bold, and underline), borders (for example: location, weight, and color), cell patterns, number formatting, alignment, and cell protection. First try did not work, so afterwards I tried the following: I generated styles with the instruction: HSSFWorkbook wb = new HSSFWorkbook(); ..... HSSFCellStyle style = wb.createCellStyle(); but, I did not set the style as it should be done: # cell.setCellStyle(style); // note that it is commented out. cell is an instance of HSSFCell class Excell still complained..... the same error. Finally, I commented out the line where style is created from the workbook reference. In this case, Excel did not complain and all the cells were unformatted. I guess that HSSF library creates two different styles when the following code is executed: HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("0"); HSSFRow row = sheet.createRow(0); HSSFCell cell1 = row.createCell(0); // Style type 1 is created HSSFCellStyle style1 = wb.createCellStyle(); cell1.setCellStyle(style1); cell1.setCellValue("first cell data"); HSSFCell cell2 = row.createCell(1); // Style type 2 is created HSSFCellStyle style2 = wb.createCellStyle(); cell2.setCellStyle(style2); cell2.setCellValue("second cell data"); The right behavior should be that only one style is created eventhough it is set in two different cells. I think that HSSF creates a style every time createCellStyle() method is called from the workbook reference. Is there any way to fix it? Maybe I am not rigth in my thinking. Thanks in advance Eguzki Astiz Lezaun Helvetia Prevision Software engineer --=_alternative 004985BBC12571B7_=--