Skip to content

Instantly share code, notes, and snippets.

@jahav
Created September 28, 2023 13:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahav/257bb2ffd5ab7adfded7e669290d8151 to your computer and use it in GitHub Desktop.
Save jahav/257bb2ffd5ab7adfded7e669290d8151 to your computer and use it in GitHub Desktop.
Create a file with 1 000 000 rows and 10 columns and print out how long it takes.
var sw = Stopwatch.StartNew();
using var wb = new XLWorkbook();
var sheet = wb.AddWorksheet();
// Lazy created data
var data = Enumerable.Range(0, 1_000_000).Select(_ =>
{
return Enumerable.Range(0, 10).Select(_ => "Hello world");
});
sheet.Cell("A1").InsertData(data);
sw.Stop();
Console.WriteLine($"Insert data: {sw.ElapsedMilliseconds}ms");
sw.Restart();
wb.SaveAs(@"1_000_000.xlsx");
sw.Stop();
Console.WriteLine($"Save data: {sw.ElapsedMilliseconds}ms");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment