fleming04 fleming04 - 2 months ago 16
C# Question

Import MS Excel table into C# List with varying data types

How do I store MS Excel 2007 cell values inside C#.Net 4.0 and later retrieve them one specific cell at a time? Note: I do not always know the Array (table size in Excel as the rows may vary)


APPLE | 1 | TRUE | 2.2
ORANGE | 4 | FALSE | 3.5
GRAPE | 5 | TRUE | 2.8


This is what i use on reading files from excel just download the DLL and reference it in your solution,

You can use

 dataRow[r] = row.GetCell(r).NumericCellValue;

to get the numeric value of cell

for further codes and explanation you can check NPOI documentation for this

**Edit You even though a row contains different columns this can be done using


it is a function used by NPOI to tell the end cell of a row.