Skip to content

Instantly share code, notes, and snippets.

@tony1223
Created October 10, 2020 04:50
Show Gist options
  • Save tony1223/6fe6700f77e141511962bdeb5102eac0 to your computer and use it in GitHub Desktop.
Save tony1223/6fe6700f77e141511962bdeb5102eac0 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.IO;
using System.Linq;
using NPOI.XSSF.Streaming;
namespace BigGridTest
{
class Program
{
static void Main(string[] args)
{
List<double> times = new List<double>();
var sortedMode = false;
for (int i = 0; i < 10; ++i)
{
var start = DateTime.UtcNow;
var workbook = new SXSSFWorkbook(null, 50000);
ISheet worksheet = workbook.CreateSheet("Sheet1");
for (int rownum = 0; rownum < 100000; rownum++)
{
IRow row = ((SXSSFSheet) worksheet).CreateRow(rownum);
for (int celnum = 0; celnum < 100; celnum++)
{
ICell Cell = row.CreateCell(celnum);
// Cell.SetCellValue("Cell: Row-" + rownum + ";CellNo:" + celnum);
}
}
var totalMilliseconds = (DateTime.UtcNow - start).TotalMilliseconds;
times.Add(totalMilliseconds);
Console.WriteLine("ExcelGeneratePerformanceTest: Content Done: " + totalMilliseconds + " ms");
}
var avg = times.Sum(n => n) / times.Count;
Console.WriteLine("ExcelGeneratePerformanceTest: Content Done: " + avg +" , sortedmode:"+sortedMode);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment