You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ian <ia...@hotmail.com> on 2011/09/01 21:51:53 UTC

autoSizeColumn setColumnWidth passed 255

When I attempt to use the autoSizeColumn on a column that contains a lot of text
I get the following error.

Is this a known bug?

-------------------------------------------------------------------------

The maximum column width for an individual cell is 255 characters.
java.lang.IllegalArgumentException: The maximum column width for an individual
cell is 255 characters.
	at org.apache.poi.hssf.model.InternalSheet.setColumnWidth(InternalSheet.java)
	at org.apache.poi.hssf.usermodel.HSSFSheet.setColumnWidth(HSSFSheet.java)
	at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java)
	at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java)

------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: autoSizeColumn setColumnWidth passed 255

Posted by Yegor Kozlov <ye...@dinom.ru>.
I'm looking at HSSFSheet#autoSizeColumn and there is a check
preventing such exceptions:

    public void autoSizeColumn(int column, boolean useMergedCells) {
        double width = SheetUtil.getColumnWidth(this, column, useMergedCells);

        if (width != -1) {
            width *= 256;
            int maxColumnWidth = 255*256; // The maximum column width
for an individual cell is 255 characters
            if (width > maxColumnWidth) {
                width = maxColumnWidth;
            }
            setColumnWidth(column, (int)(width));
        }

    }

I'm pretty sure you are using an older version of POI. Please check
your classpath.  If the problem is still there, please post sample
code that demonstrates the bug.

Yegor

On Fri, Sep 2, 2011 at 3:38 PM, Ian <ia...@hotmail.com> wrote:
>
> This error was generated using version 3.8 beta4
>
>
> Yegor Kozlov <yegor.kozlov <at> dinom.ru> writes:
>
>>
>> which version of POI? Please try with the latest 3.8-beta4, there have
>> been improvements in column autosizing recently.
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: autoSizeColumn setColumnWidth passed 255

Posted by Ian <ia...@hotmail.com>.
This error was generated using version 3.8 beta4


Yegor Kozlov <yegor.kozlov <at> dinom.ru> writes:

> 
> which version of POI? Please try with the latest 3.8-beta4, there have
> been improvements in column autosizing recently.
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: autoSizeColumn setColumnWidth passed 255

Posted by Yegor Kozlov <ye...@dinom.ru>.
which version of POI? Please try with the latest 3.8-beta4, there have
been improvements in column autosizing recently.

Yegor

On Thu, Sep 1, 2011 at 11:51 PM, Ian <ia...@hotmail.com> wrote:
> When I attempt to use the autoSizeColumn on a column that contains a lot of text
> I get the following error.
>
> Is this a known bug?
>
> -------------------------------------------------------------------------
>
> The maximum column width for an individual cell is 255 characters.
> java.lang.IllegalArgumentException: The maximum column width for an individual
> cell is 255 characters.
>        at org.apache.poi.hssf.model.InternalSheet.setColumnWidth(InternalSheet.java)
>        at org.apache.poi.hssf.usermodel.HSSFSheet.setColumnWidth(HSSFSheet.java)
>        at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java)
>        at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java)
>
> ------------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org