Created
January 26, 2023 00:59
-
-
Save jahav/3c1432ebae08545debc2e1c4b7a20cf6 to your computer and use it in GitHub Desktop.
Test for issue 1838 of ClosedXML
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
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Diagnostics; | |
using System.IO; | |
using ClosedXML.Excel; | |
namespace ConsoleApp11 | |
{ | |
internal class Program | |
{ | |
private static DataTable GetTable() | |
{ | |
DataTable table = new DataTable(); | |
// add columns | |
for (var col = 1; col <= 245; col++) | |
{ | |
table.Columns.Add("col_" + col.ToString(), typeof(string)); | |
} | |
List<string> valuesList = new List<String>(); | |
foreach (DataColumn dc in table.Columns) | |
{ | |
valuesList.Add("testing 101.001000000000 test"); | |
} | |
for (var row = 1; row <= 50000; row++) | |
{ | |
table.Rows.Add(valuesList.ToArray()); | |
} | |
return table; | |
} | |
public static void Main() | |
{ | |
var table = GetTable(); | |
using (var workbook = new XLWorkbook()) | |
{ | |
var worksheet = workbook.Worksheets.Add("fgtesting"); | |
var stopwatch = Stopwatch.StartNew(); | |
worksheet.Cell(1, 1).InsertData(table); | |
stopwatch.Stop(); | |
Console.WriteLine("Insert data {0}", stopwatch.Elapsed); | |
using (var memoryStream = new MemoryStream()) | |
{ | |
stopwatch.Restart(); | |
workbook.SaveAs(memoryStream); | |
stopwatch.Stop(); | |
} | |
Console.WriteLine("SaveAs to memory stream {0}", stopwatch.Elapsed); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment