You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by David Fisher <df...@jmlafferty.com> on 2007/05/04 02:30:42 UTC
Why autoSizeColumn probably needs java.awt.headless=true
Rober,
As Andy says ask on the list.
In your Tomcat startup on the unix server you need to be sure to set
the following property -
-Djava.awt.headless=true
Do that and all should be good.
If you notice slight differences in widths between windows and unix
that may be due to the fact that autoSizeColumn uses fonts to do its
magic. (Which is why it needs the "graphic environment") So, then you
might want to install fonts into /usr/java/jre/lib/fonts/ on the unix
box. If you get stuck with that then you can ask again - Yegor can
explain the exact rules.
Regards,
Dave
On May 3, 2007, at 6:57 PM, bugzilla@apache.org wrote:
> DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
> RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
> <http://issues.apache.org/bugzilla/show_bug.cgi?id=42331>.
> ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
> INSERTED IN THE BUG DATABASE.
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=42331
>
> Summary: autoSizeColumn. Exception in non graphical
> environment
> Product: POI
> Version: 3.0-dev
> Platform: Other
> OS/Version: other
> Status: NEW
> Severity: normal
> Priority: P2
> Component: HSSF
> AssignedTo: poi-dev@jakarta.apache.org
> ReportedBy: roberjruiz@yahoo.es
>
>
> I developed a webapp that generates excel files. Development
> environment is
> Tomcat server under Windows XP. Production server is a Unix machine
> with no
> graphical environment.
>
> autoSizeColumn method, from HSSFSheet class, works ok in windows,
> but throws an
> exception in unix environment. The lack of graphical environment
> seems to be the
> reason.
>
> --
> Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?
> tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-dev-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-dev-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: Why autoSizeColumn probably needs java.awt.headless=true
Posted by Yegor Kozlov <ye...@dinom.ru>.
Rober,
To calculate column width HSSFSheet.autoSizeColumn uses Java2D classes
that throw exception if graphical environment is not available.
However, some tasks such as computing text layout can be
done in a headless mode, that is in the absence of graphical
environment.
To use headless mode you must set the following system property:
java.awt.headless=true
either via -Djava.awt.headless=true startup parameter or via System.setProperty("java.awt.headless", "true").
As Dave mentioned, there can be slight differences in the
result:
- Native graphical toolkits (WinXP or Unix with X11) are always
more precise than the headless toolkit. The way the font
metrics are calculated may be different in headless and headful modes.
Moreover, it may different on different platforms, i.e. there can be
minor differences between text metrics calculated under Solaris and
under WinXP. That is why projects that require high-precision,
platform-independent graphic calculations use their own mechanism to measure text (for
example, Apache FOP). I don't think it's an issue in our case.
Auto-sizing in Excel is a rough operation - user needs to
APPROXIMATELY set column width to fit the text.
- If some of the fonts are not available, JDK uses the default font.
So if any fonts are missing in production you need to install them and
copy font files to $JAVA_HOME/jre/lib/fonts/.
P.S. It's good you raised this question. I'm going to update the docs
to reflect it.
Regards,
Yegor
DF> Rober,
DF> As Andy says ask on the list.
DF> In your Tomcat startup on the unix server you need to be sure to set
DF> the following property -
DF> -Djava.awt.headless=true
DF> Do that and all should be good.
DF> If you notice slight differences in widths between windows and unix
DF> that may be due to the fact that autoSizeColumn uses fonts to do its
DF> magic. (Which is why it needs the "graphic environment") So, then you
DF> might want to install fonts into /usr/java/jre/lib/fonts/ on the unix
DF> box. If you get stuck with that then you can ask again - Yegor can
DF> explain the exact rules.
DF> Regards,
DF> Dave
DF> On May 3, 2007, at 6:57 PM, bugzilla@apache.org wrote:
>> DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
>> RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
>> <http://issues.apache.org/bugzilla/show_bug.cgi?id=42331>.
>> ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
>> INSERTED IN THE BUG DATABASE.
>>
>> http://issues.apache.org/bugzilla/show_bug.cgi?id=42331
>>
>> Summary: autoSizeColumn. Exception in non graphical
>> environment
>> Product: POI
>> Version: 3.0-dev
>> Platform: Other
>> OS/Version: other
>> Status: NEW
>> Severity: normal
>> Priority: P2
>> Component: HSSF
>> AssignedTo: poi-dev@jakarta.apache.org
>> ReportedBy: roberjruiz@yahoo.es
>>
>>
>> I developed a webapp that generates excel files. Development
>> environment is
>> Tomcat server under Windows XP. Production server is a Unix machine
>> with no
>> graphical environment.
>>
>> autoSizeColumn method, from HSSFSheet class, works ok in windows,
>> but throws an
>> exception in unix environment. The lack of graphical environment
>> seems to be the
>> reason.
>>
>> --
>> Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?
>> tab=email
>> ------- You are receiving this mail because: -------
>> You are the assignee for the bug, or are watching the assignee.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
>> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
>> The Apache Jakarta POI Project: http://jakarta.apache.org/poi/
>>
>>
DF> ---------------------------------------------------------------------
DF> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
DF> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
DF> 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/