i read data from an excel file with this code
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
Microsoft.Office.Interop.Excel.Range range;
int rCnt = 0;
int cCnt = 0;
string[,] data;
xlWorkSheet = (Worksheet)wb.Worksheets.get_Item(sheetId);
range = xlWorkSheet.UsedRange;
data = new string[range.Rows.Count, range.Columns.Count];
for (rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
{
for (cCnt = 1; cCnt <= range.Columns.Count; cCnt++)
{
data[rCnt - 1, cCnt - 1] = (string)
(range.Cells[rCnt, cCnt] as Range).Text;
}
}
Now i am running sometimes into cells where the value in excel is displayed as ### because the column space is not big enough to display the number. In excel of course i can see the right value in the line on the top when i click on the cell but in my program i am getting the ### as value instead of the right number.
Any advice here?
Try using
Range.Valueproperty instead ofText.So instead of
you would write