Re: Cast general numeric cell into text



Mike Toews wrote:
Hi,

I'm hoping to get some incite as to how I can convert a cell with floating point contents (numeric) formatted as "General" to an exact displayed text (i.e., string) for that cell. This isn't as easy as it should be, since it is dependent on several factors such as cell width and font size.

For example: in a fresh sheet put "22.654654378" into one cell, and resize the cell back to 64px width. The cell now shows "22.6547". How can I capture that into text? If I use (e.g.,) =text(A1,"General") then I get the exact value typed originally, and not the displayed value.

Note that I'm actually developing some code to pull this data from old spreadsheets into a database, but I don't know how to reverse-engineer what MS have done with the general formatting. I'd like to keep the original and displayed formatting from this data (i.e, I'd rather have the text "0.2986" as displayed rather than "0.29861111111111099", also in my situation, the number of decimals change for each row—some use numeric formatting that I can use directly, and other cells use "General" which require this assistance—very messy). Gnumeric reproduces this behavior perfectly, so I'm hoping someone who knows whats ticking beneath may be able to help me.
I'm sure I don't understand what your're doing or why. I'm sorry if this sounds a bit sermon-like but generally you want presentation separated from content. If you have numbers at a greater precision that is reasonable given the accuracy of the measurement, then the round() function should sort that out. Once you put your information into the database, any rounding results in a loss of precision, as you see with a spreadsheet, displayed precision does not have to be the same as stored precision.
I don't know if I'm being helpful or annoying.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]