I'm using ExcelDataReader to read XLS files and it's working fine. I am able to read file contents into a DataSet:
var excelDataSet = reader.AsDataSet(new ExcelDataSetConfiguration
{
ConfigureDataTable = (_) => new ExcelDataTableConfiguration { UseHeaderRow = true }
});
I then take the first table from the contents:
DataTable? table = excelDataSet.Tables["MyTable"];
And I can then loop through rows and columns with table.Rows[rowNumber][colNumber] and I read all text values except Boolean, which are Yes/No values and checkboxes. I get null values instead.
How can I read Yes/No and checkbox values?
Maybe there is a better way, but I was able get it to work by converting to an
int(as behind the scenes a bool is 1 or 0) and then converted that tobool.I used the reader but I imagine its the same when reading from your
datatable.var bool = Convert.ToBoolean(Convert.ToInt16(reader.GetString(colIndex)))