public static ExcelFile ReadFile(string path, CsvLoadOptions options) { var workbook = new ExcelFile(); int sheetIndex = 0; using (var reader = new LargeCsvReader(path, options)) while (reader.CanReadNextSheet()) { reader.ReadSheet(workbook, $"Sheet{++sheetIndex}"); } return(workbook); }
static void Example4() { // Create large CSV file. using (var csv = File.CreateText("large-file.csv")) for (int i = 0; i < 5_000_000; i++) { csv.WriteLine(i); } // Import all CSV data into multiple sheets. var workbook = LargeCsvReader.ReadFile("large-file.csv", LoadOptions.CsvDefault); // Display name and rows count of generated sheets. foreach (var worksheet in workbook.Worksheets) { Console.WriteLine($"Name: {worksheet.Name} | Rows: {worksheet.Rows.Count:#,###}"); } }