You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Matthew Carey <ma...@ssl.co.uk> on 2013/08/02 18:47:42 UTC

Re: HSSFCell API changes - I do not see setEncoding() in 3.2

Using POI 3.9 I get strange issues with encoding. Running under CentOS
release 5.9 (Final)

I have written an application that takes an xls file as a template and reads
a csv file and outputs another xls file containing the data and images
referenced in the csv file in rows. It uses the formatting from the template
file.

When my POI using applications jar file is run from the command line a
correctly formatted xls file is generated from an xls file used as a
template with imported utf-8 data generating correctly accented characters
in the result xls file.

When the POI using application is run by a server process running as root on
the same box the character encoding of the generated cells is iso-8859-1 and
the accented characters become pairs of unknown characters in the xls.

I imagine that it is picking up some Locale setting and doing the wrong
thing. It would be nice to be able to override this.

Now it could be the csv file library (au.com.bytecode.opencsv) rather than
POI 




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HSSFCell-API-changes-I-do-not-see-setEncoding-in-3-2-tp2303497p5713419.html
Sent from the POI - User mailing list archive at Nabble.com.

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


Re: HSSFCell API changes - I do not see setEncoding() in 3.2

Posted by Matthew Carey <ma...@ssl.co.uk>.
Should of course be 

java -Dfile.encoding=UTF-8 -jar my.jar params



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HSSFCell-API-changes-I-do-not-see-setEncoding-in-3-2-tp2303497p5713464.html
Sent from the POI - User mailing list archive at Nabble.com.

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


Re: HSSFCell API changes - I do not see setEncoding() in 3.2

Posted by Matthew Carey <ma...@ssl.co.uk>.
I fixed the issue which I think was being picked from the LANG or Locale or
the user running the server by setting the file.encoding system property
explicitly on the command line. 

java -Dfile.encoding=UTF-8 my.jar params



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/HSSFCell-API-changes-I-do-not-see-setEncoding-in-3-2-tp2303497p5713463.html
Sent from the POI - User mailing list archive at Nabble.com.

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


RE: HSSFCell API changes - I do not see setEncoding() in 3.2

Posted by "Allison, Timothy B." <ta...@mitre.org>.
Concur with Nick.  How are you initializing the Reader that you pass to: 

CSVReader r = new au.com.bytecode.opencsv. CSVReader(Reader reader)

-----Original Message-----
From: Nick Burch [mailto:apache@gagravarr.org] 
Sent: Friday, August 02, 2013 1:01 PM
To: POI Users List
Subject: Re: HSSFCell API changes - I do not see setEncoding() in 3.2

On Fri, 2 Aug 2013, Matthew Carey wrote:
> I have written an application that takes an xls file as a template and reads
> a csv file and outputs another xls file containing the data and images
> referenced in the csv file in rows. It uses the formatting from the template
> file.
>
> When my POI using applications jar file is run from the command line a
> correctly formatted xls file is generated from an xls file used as a
> template with imported utf-8 data generating correctly accented characters
> in the result xls file.

I'm minded to blame your CSV reading here. POI works only on Java strings, 
which are unicode. POI sorts out any encoding parts for you when writing 
to the binary file format.

When reading from a csv file, you need to turn the bytes into the correct 
characters if you want to get valid Java strings out. Sounds like you're 
not doing that right in some cases... Easiest way to be sure is add some 
debugging that prints out a character at a time the values in one of your 
accented strings, and ensure they're correct

Nick

---------------------------------------------------------------------
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: HSSFCell API changes - I do not see setEncoding() in 3.2

Posted by Nick Burch <ap...@gagravarr.org>.
On Fri, 2 Aug 2013, Matthew Carey wrote:
> I have written an application that takes an xls file as a template and reads
> a csv file and outputs another xls file containing the data and images
> referenced in the csv file in rows. It uses the formatting from the template
> file.
>
> When my POI using applications jar file is run from the command line a
> correctly formatted xls file is generated from an xls file used as a
> template with imported utf-8 data generating correctly accented characters
> in the result xls file.

I'm minded to blame your CSV reading here. POI works only on Java strings, 
which are unicode. POI sorts out any encoding parts for you when writing 
to the binary file format.

When reading from a csv file, you need to turn the bytes into the correct 
characters if you want to get valid Java strings out. Sounds like you're 
not doing that right in some cases... Easiest way to be sure is add some 
debugging that prints out a character at a time the values in one of your 
accented strings, and ensure they're correct

Nick

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