/// <summary> /// Converts all sheets to a DataSet /// </summary> /// <param name="self">The IExcel instance</param> /// <param name="configuration">An optional configuration object to modify the behavior of the conversion</param> /// <returns>A dataset with all workbook contents</returns> public static DataSet AsDataSet(this IExcel self, ExcelDataSetConfiguration configuration = null) { if (configuration == null) { configuration = new ExcelDataSetConfiguration(); } self.Reset(); var tableIndex = -1; var result = new DataSet(); do { tableIndex++; if (configuration.FilterSheet != null && !configuration.FilterSheet(self, tableIndex)) { continue; } var tableConfiguration = configuration.ConfigureDataTable != null ? configuration.ConfigureDataTable(self) : null; if (tableConfiguration == null) { tableConfiguration = new ExcelDataTableConfiguration(); } var table = AsDataTable(self, tableConfiguration); result.Tables.Add(table); }while (self.NextResult()); result.AcceptChanges(); if (configuration.UseColumnDataType) { FixDataTypes(result); } self.Reset(); return(result); }