Examples? Direct cell access?

Jan 27, 2014 at 10:56 AM
I can't find examples, inline source documentation or other documentation about this project. What I've seen from the short introduction is that this library can read Excel files into DataSet-like table structures. This may work fine if the Excel worksheets are strict tables with only one header row containing the column names. But if the file contains arbitrary data with custom header rows, footer rows and other stuff, I need to access the cells directly and read the raw data from them. Can this library provide such methods? Like, say, access row 10, column 3, interpret as decimal number, or maybe even give me the raw string value (if that exists) for me to interpret it on my own as number, currency, date or something else.
Jan 27, 2014 at 11:27 AM
I think you have two options.
  1. Use datasets but specify reader.IsFirstRowAsColumnNames = false so that the whole sheet is the contents of the dataset.
    Then in your example for row 10 column 3 you would have ds.Tables[0].Rows[9][2]
  2. Use the IDataReader interface and step through until you get to row 10 then read the value for field 3