poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew C. Oliver" <acoli...@apache.org>
Subject Re: creating second hssf sheet
Date Wed, 09 Jul 2003 15:40:16 GMT
There in lies the challenge!  :-)

I'd start with majick numbers  (254,255,256, 8191, 8192,8193,
32k-1,32k,32k+1, etc)

On 7/9/03 11:32 AM, "Avik Sengupta" <avik@apache.org> wrote:

> What is the max? anyone have any figures?
> On Wed, 2003-07-09 at 20:18, Andrew C. Oliver wrote:
>> I'd love it if someone submitted a patch which threw an exception when the
>> max had been reached....
>> On 7/9/03 5:41 AM, "Avik Sengupta" <avik@apache.org> wrote:
>>> Well, yes, in general you need to cache individual/separate styles. See
>>> the mail from Adam Reeve.. his mail contains an actual implementation..
>>> you do a similar thing, but obviously use more elements for the key. So
>>> while you may not know upfront what permutations you need, you can have
>>> the code keep track and generate new styles on demand. If would get more
>>> complicated if you are not specifying the same elements for each call
>>> (eg, one style you specify using color and font weight, while another
>>> you specify using color, and font type)  ... but it can be done using
>>> some form of defaulting and/or multidimensional search.
>>> In relation to whether that will end up creating the "too many styles
>>> problem" in any case... well, you will not have a different style for
>>> each cell, will you. Even in relatively sophisticated sheets, the number
>>> of styles will usually be far far less than the number of cells. The
>>> exact number of formats that cause excel to complain.. i dont know.
>>> Maybe someone on the list has done some experiments?
>>> Regards
>>> -
>>> Avik
>>> On Wed, 2003-07-09 at 14:53, Singh, Arshi (Indsys) wrote:
>>>> Your strategy is good but what if i need a style that is a combination of
>>>> couple of styles...like color, bold, underline, border, align, background,
>>>> fontsize, font type etc. The style required could be a combination of any
>>>> of
>>>> these styles which is not known to me in advance. Should i create a cache
>>>> of
>>>> all possible permutations n combinations of these styles? Wouldnt that end
>>>> up exceeding the "Too many styles " limit.
>>>> Arshi
>>>> -----Original Message-----
>>>> From: Avik Sengupta [mailto:avik@apache.org]
>>>> Sent: Wednesday, July 09, 2003 2:16 PM
>>>> To: POI Users List
>>>> Subject: RE: creating second hssf sheet
>>>> That code obviously wont work.. the style is accessed when serialisation
>>>> happens, and by then the style is ALIGN_RIGHT.
>>>> The general strategy is
>>>> HSSFCellStyle right =
>>>> wb.createCellStyle();right.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
>>>> HSSFCellStyle left =
>>>> wb.createCellStyle();left.setAlignment(HSSFCellStyle.ALIGN_GENERAL);
>>>> while(i have data){
>>>> ... create cell;
>>>> if (cell should be right) cell.setStyle(right); else
>>>> cell.setStyle(left);
>>>> }
>>>> Caveat: The above is very pseudo code... please check the api.
>>>> As regards your question on clearing after a sheet, afaik, formats are
>>>> stored globally in the workbook, not at each sheet. Tho i must say that
>>>> the exact semantics of when Excel complains about "Too many styles" is
>>>> not fully known.
>>>> On Wed, 2003-07-09 at 11:21, Singh, Arshi (Indsys) wrote:
>>>>> Hi,
>>>>>   I went through the sample code in FAQ. My requirement is such that
>>>> need
>>>>> a no. of fonts n styles. Thats why i was creating a new style n font
>>>>> everytime i needed one. But instead if i try to use the same style by
>>>>> changing all the values back to normal, then the latest style n font
>>>>> populated for the previous cells also.
>>>>> eg:-
>>>>> HSSFCellStyle cell_style = wb.createCellStyle();
>>>>> cell_style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
>>>>> sheet_cell.setCellStyle(cell_style);
>>>>> cell_style.setAlignment(HSSFCellStyle.ALIGN_GENERAL);
>>>>> sheet_cell2.setCellStyle(cell_style);
>>>>> Now its the ALIGN_GENERAL (second style) that gets set for the first
>>>>> cell also.
>>>>> I believe there is a font table for storing all the workbook fonts. Is
>>>> there
>>>>> a way to delete fonts from this, after one sheet is made...so that space
>>>> for
>>>>> more fonts can be made available.
>>>>> Thanks,
>>>>> Arshi.
>>>>> -----Original Message-----
>>>>> From: Michael Zalewski [mailto:zalewski@optonline.net]
>>>>> Sent: Wednesday, July 09, 2003 9:30 AM
>>>>> To: POI Users List
>>>>> Subject: RE: creating second hssf sheet
>>>>> It probably doesn't help much, cuz the real URL is
>>>>> http://jakarta.apache.org/poi/faq.html#faq-N100C2
>>>>> And the short answer is that you have to limit the number of HSSFStyle
>>>>> objects that you create. If you create a new one for each cell, you make
>>>> too
>>>>> many for Excel to handle. The FAQ contains good sample code.
>>>>> -----Original Message-----
>>>>> From: Avik Sengupta [mailto:avik@apache.org]
>>>>> Sent: Tuesday, July 08, 2003 11:32 AM
>>>>> To: POI Users List
>>>>> Subject: Re: creating second hssf sheet
>>>>> Does this help?
>>>>> http://jakarta.apache.org/poi/faq#faq-N100C2
>>>>> On Tue, 2003-07-08 at 18:46, Singh, Arshi (Indsys) wrote:
>>>>>> Hi,
>>>>>>    I have created a new workbook using POI hssf and made one excel
>>>>>> containing a number of fonts, styles etc. After that when i try to
>>>> create
>>>>> a
>>>>>> second sheet , it gives problems.
>>>>>>       If i try to create a small sheet 2 with a few lines of different
>>>>>> fonts then the fonts do not show as desired in sheet 2 and if i try
>>>>>> create a big sheet 2 having tables and orientations then the my output
>>>>> excel
>>>>>> file does not even open up and shows the error "Too Many Different
>>>>>> Formats".
>>>>>>       Can somebody please help me detect the error. Could it be because
>>>> of
>>>>>> some buffer in memory ????
>>>>>> Thanks,
>>>>>> Arshi.
>>>>> [useless trailers snipped]
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail: poi-user-help@jakarta.apache.org
>>>>> ADDRESSEE and may contain confidential and privileged information.
>>>>> If the reader of this message is not the intended recipient,
>>>>> you are notified that any dissemination, distribution or copy of this
>>>>> communication is strictly Prohibited.
>>>>> If you have received this message by error, please notify us
>>>>> immediately, return the original mail to the sender and delete the
>>>>> message from your system."
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail: poi-user-help@jakarta.apache.org

Andrew C. Oliver
Custom enhancements and Commercial Implementation for Jakarta POI

For Java and Excel, Got POI?

View raw message