Writing string, numeric data to Excel via C# works, but Excel does not treat numeric data correctly
Posted
by Chapax
on Stack Overflow
See other posts from Stack Overflow
or by Chapax
Published on 2010-03-28T10:20:44Z
Indexed on
2010/03/28
10:23 UTC
Read the original article
Hit count: 172
Hi, I'm getting result sets from Sybase that I return to a C# client.
I use the below function to write the result set data to Excel:
***private static void WriteData(Excel.Worksheet worksheet, string cellRef, ref string[,] data) {
Excel.Range range = worksheet.get_Range(cellRef, Missing.Value);
if (data.GetLength(0) != 0)
{
range = range.get_Resize(data.GetLength(0), data.GetLength(1));
range.set_Value(Missing.Value, data);
}
}*
The data gets written correctly.
The issue is that since I'm using string array to write data (which is a mixture of strings and floats), Excel highlights every cell that contains numeric data with the message "Number Stored as Text".
How do I get rid of this issue?
Many thanks, Chapax
© Stack Overflow or respective owner