/// <summary> /// Reads the first worksheet in the .xlsx file and returns it. This only supports .xlsx files (Office 2007, with open xml standard) /// and not .xls files (which had a closed file format that required COM). /// Also supports reading .csv files. /// This is safe to use on a server. /// </summary> /// <param name="builder"></param> /// <param name="filename">filename </param> /// <returns>table for the first sheet in the workbook. Table's name is the sheet name.</returns> public static MutableDataTable ReadExcel(this DataTableBuilder builder, string filename) { // For convenience if (filename.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { return(builder.ReadCsv(filename)); } using (Stream input = new FileStream(filename, FileMode.Open, FileAccess.Read)) { return(builder.ReadExcel(input)); } }