You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Yegor Kozlov <ye...@dinom.ru> on 2007/02/26 18:42:16 UTC

HSSF Announcement: column autofit is implemented

Hi All

I'm pleased to announce that the "autofit column width" feature is
implemented in HSSF. There were many requests to have it since the very beginning of POI and finally it is present.

The implementation is pure Java2D and the result is pretty close to
what excel calculates.

Usage:
To autofit a column just call HSSFSheet.autoSizeColumn(short column)
as follows:

 HSSFSheet sheet;
 ...
 sheet.autoSizeColumn((short)0); //autofit the first column


Important note: the fonts used in the xls being auto-fitted must be
available. Otherwise Java will use default font and the result may be
not correct.

Regards,
Yegor Kozlov


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re[2]: HSSF Announcement: column autofit is implemented

Posted by Yegor Kozlov <ye...@dinom.ru>.
Tahir,

It's possible to do. Probably it will a a param telling the algorithm
to preserve wide columns. I will look at it later.

Thanks for the idea.

Yegor

TA> Yegor,

TA> Is it possible to somehow auto-size only those columns that are not wide
TA> enough to display there content but leave those columns that are wider than
TA> required? I mean that I don't want to shrink the columns that can show there
TA> content even if they are wider than max width of content.

TA> Wassalam,

TA> Tahir

>> -----Original Message-----
>> From: Yegor Kozlov [mailto:yegor@dinom.ru]
>> Sent: Monday, February 26, 2007 10:42 PM
>> To: POI Users List
>> Subject: HSSF Announcement: column autofit is implemented
>> 
>> Hi All
>> 
>> I'm pleased to announce that the "autofit column width" feature is
>> implemented in HSSF. There were many requests to have it since the very
>> beginning of POI and finally it is present.
>> 
>> The implementation is pure Java2D and the result is pretty close to
>> what excel calculates.
>> 
>> Usage:
>> To autofit a column just call HSSFSheet.autoSizeColumn(short column)
>> as follows:
>> 
>>  HSSFSheet sheet;
>>  ...
>>  sheet.autoSizeColumn((short)0); //autofit the first column
>> 
>> 
>> Important note: the fonts used in the xls being auto-fitted must be
>> available. Otherwise Java will use default font and the result may be
>> not correct.
>> 
>> Regards,
>> Yegor Kozlov
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/




TA> ---------------------------------------------------------------------
TA> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
TA> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
TA> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


RE: HSSF Announcement: column autofit is implemented

Posted by Tahir Akhtar <ta...@spectrum-tech.com>.
Yegor,

Thanks for implementing the much needed functionality. 

Is it possible to somehow auto-size only those columns that are not wide
enough to display there content but leave those columns that are wider than
required? I mean that I don't want to shrink the columns that can show there
content even if they are wider than max width of content.

Wassalam,

Tahir

> -----Original Message-----
> From: Yegor Kozlov [mailto:yegor@dinom.ru]
> Sent: Monday, February 26, 2007 10:42 PM
> To: POI Users List
> Subject: HSSF Announcement: column autofit is implemented
> 
> Hi All
> 
> I'm pleased to announce that the "autofit column width" feature is
> implemented in HSSF. There were many requests to have it since the very
> beginning of POI and finally it is present.
> 
> The implementation is pure Java2D and the result is pretty close to
> what excel calculates.
> 
> Usage:
> To autofit a column just call HSSFSheet.autoSizeColumn(short column)
> as follows:
> 
>  HSSFSheet sheet;
>  ...
>  sheet.autoSizeColumn((short)0); //autofit the first column
> 
> 
> Important note: the fonts used in the xls being auto-fitted must be
> available. Otherwise Java will use default font and the result may be
> not correct.
> 
> Regards,
> Yegor Kozlov
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/




---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/