Hello Daniel, Daniel Noll wrote: > Andreas Hartmann wrote: >> Hello! >> >> I have to read datas from cells in excel sheets. The goal is, to get the >> data as they are formated by the user, who wrote the sheet. >> >> >> Examples: >> >> A cell is formated as text. The user wrote in this cell the number 13. >> Excel shows this number as the user wrote it (as 13), but POI recognizes >> this cell as a number cell (which is wrong), though the user defined it as >> text. If I'm Reading the cell with POI as number, the value I get is 13.0, >> which is wrong again (must be 13). >> > Actually, I think you might be mis-understanding Excel. > > To actually *define* a cell as text, you need to type a single quote > before you enter the number. HSSF correctly identifies this type of > cell as a string typed cell (I just checked, FWIW.) > > What you've probably done, is created a number cell, and merely > *formatted* it as text. This cell is still stored as a number, and > therefore HSSF will always see it as a number. As you can see, > formatting as text and defining as text are two different things.
It was done slightly other :-). We took the whole sheet and formated it as text. After that, the cells have been filled with datas. The goal is, that the datas must be read exactly as they are given to excel. [...] Very good info, which resolved my problem. Thank you very much! > I do agree with the underlying sentiment of your post, though. It would > be very convenient if HSSF had a convenient getFormattedString() method > on HSSFCell which automatically outputted the cell in the same format > Excel would have displayed. I can imagine it being a fair bit of work > though. It would be really necessary. > I got this far myself and then decided that formatting the values was > ultimately more trouble than it was worth, and opted to display > everything in a standard format. This is not a solution for me, because I have to take the values 1:1 without any change. Well, I've to do some work, if I'm going to use this interface. With your help, I know basically, how to do it! Kind regards, Andreas Hartmann --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
