I am using the COM interface for Excel, and I would like to get a formatted textual representation of the cell, not a true base value.
For example, suppose a cell contains a number 1.23456, and the user specified the format of the number with 1 decimal point. Then I would like to read the line "1.2". I know what I can use Range.Text, but this fails in several important ways. Range.Textreturns what the user sees in the sheet view, so if the cell is hidden, an empty string is returned. If the cell width is low, a truncated row is returned. Range.Textalso crashes since it is limited to 1024 characters.
Another use case is when a cell evaluates an error, for example. #DIV/0!, #NAME?, #REF!Etc. I know that I can read Range.Valueand check if the option is a type varError(I use Delphi, in VBA it will be vbError). I can’t figure out how to get a text representation #DIV/0!, etc. It Range.Textreturns this again , but not if the cell is hidden or too narrow.
EDIT
I think the limit on Range.Text is actually 255 characters.
source
share