In Excel, textual data can be stored in cells specifically formatted as Text, or in other cells, with formats such as General. Mathematica Link for Excel uses this formatting difference to distiguish between text expressions and strings. If a cell is formatted as Text, the content of the cell is considered to be a Mathematica text expression, otherwise the string is considered to be a Mathematica string. xyz (Text format) | xyz | xyz (other format) | "xyz" |
Excel string mapping. Note, in Excel, the two versions of the string appear identical. However, there is an important behavioral difference between text cells and other cells: • Strings assigned to nontext cells pass through an Excel interpreter. The interpreter checks to see if the string being assigned appears to be a data type it knows about. If so, the string is converted to the identified data type, and an appropriate cell format is automatically applied if needed. • Strings assigned to text cells do not pass through the Excel interpreter. They can therefore contain exact numbers, rationals, or anything else that can be stored as a Mathematica expression. As an example, if 1/2 is assigned to a cell with the General format, the rational is interpeted as January 2 of the curent year, and a date format is automatically assigned to the cell. When 1/2 is assigned to a text cell, the fraction remains as entered. Notes • When using MathematicaLink worksheet functions, input ranges are assumed to contain text expressions even if the input range has not been formated as Text. This assumption makes it easier to build Mathematica expressions. You can wrap data ranges with the DATA worksheet function to treat strings contained in the range as Mathematica strings. |