I have written before about the challenges of reading data from an Excel, mainly because Excel doesn’t define data types for columns like you do in a data table. That article included a formula to convert a column of numbers into a column of equivalent strings.
Last week I had to do the opposite. A customer wanted to link a data table to a spreadsheet, but the linking field in the spreadsheet had numeric characters, while the data table had a true numeric column. There is nothing you can do in the Crystal linking window to get a numeric column to link to a character column, so we had to convert the Excel column from characters to numbers. Just like the previous article, you can’t fix this by formatting the column. The data type assigned to an Excel column isn’t affected by the format of the column, but only by the actual values stored in that column.
After a few experiments I discovered a solution. If you write a formula like this in Excel:
A1 + 0
The result will be a number even if the cell A1 is a character string with numeric characters. Even better, if there are any true numbers in the column, the formula will work the same for them. So we copied that formula for the entire column and that new column became our linking field.