1
votes

I am trying to use Microsoft.Office.Interop.Excel to read excel file in c#. I want to read range of cells as it is way faster than reading cell one by one:

Range rbeg = (Range)sheet.Cells[1, i + 1];
Range rend = (Range)sheet.Cells[totalRowCount, i + 1];
Range range = sheet.get_Range(rbeg, rend);
column = (object[,])range.Value2;

The problem is when I want to get number format of cells by calling:

range.NumberFormat

I get System.DBNull. It works when I call it for single cell.

I want to distinguish between cells with numerical values and "%" values.

Any ideas?

1

1 Answers

0
votes

See the documentation:

[NumberFormat] returns Null if all cells in the specified range don't have the same number format.

What were you expecting it to do in this case?