Created
September 28, 2023 13:14
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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