Please don't assume that the view shown on the screen is a close match to the data stored internally! M$FT-Excel stores all numeric data as floating-point numbers. Then it applies suitable formatting and other rules when it displays to you. Working in POI you see the raw internal data. Storing and reading date/time values is a particular joy!

Re character encoding: POI has cell encoding features, and copes with UTF-8 and UTF-16. Java is perfectly capable of dealing with special characters. You don't mention where on Linux the data is "converted to question marks". Did you use an IDE like Eclipse and view the data right there immediately when it's read? Also search Nabble for UTF-8 and encoding. I got this hit:

http://old.nabble.com/how-to-read-unicode-data-from-xls-sheet-td13601249.html#a13604018

chris...

p.s. Gruess aus New Jersey!


Felix Dreher wrote:
Hi all,

I'm trying to read Excel files (classes HSSFWorkbook, HSSFSheet, HSSFCell etc.). There are two issues that I'm currently struggling with:

1) non-ASCII characters like é or ü are read correctly on Windows, but not on Linux (where these characters are all converted to question marks). I tried to use the "Locale.setDefault(myLocale)" method, but with no success.

2) The tables I would like to read contain lots of whole numbers, which I would like to treat as strings because they are IDs or order numbers (i.e. I would like to simply read all cells in the same way as Excel displays them). However, they get read as decimal numbers, e.g. the number 1234 in an Excel table (formatted as 'General') becomes 1234.0 in its POI representation.
I tried two workarounds, but they didn't work:
a) open the Excel file, format all cells as Text, save.
b) use the HSSFDataFormatter class to define a 'Decimal format' with actually no decimals (e.g. DecimalFormat df = new DecimalFormat ("#"))

Any help would be greatly appreciated!

Thank you very much,
Felix


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to