Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel XSSFWorkbook takes more than 4 to 5sec to load from Stream (Bulk data) #1194

Open
4 tasks
utthungagokul opened this issue Sep 27, 2023 · 6 comments
Open
4 tasks

Comments

@utthungagokul
Copy link

NPOI Version

2.6.2

File Type

  • [] XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

Upload the Excel File

         -

Reproduce Steps

       The excel should have bulk data with multiple sheet.

Issue Description

While reading the bulk data (2500KB) file taken almost 4 to 5 sec just create a XSSWorkBook instance.

Attempt 1:

               using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
               {
                         XSSFWorkbook xssfWorkbook = new XSSFWorkbook(stream);  == > 4 to 5 sec 
               }

Attempt 2:

             IWorkbook xssfWorkbook;
             using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
             {                            
                     xssfWorkbook = WorkbookFactory.Create(stream);  == > 4 to 5 sec 
              }

Both Attempt 1 & 2 has same behavior.

@lahma
Copy link
Collaborator

lahma commented Sep 27, 2023

Without a sample Excel file I would just suggest buying a faster machine.

@tonyqus
Copy link
Member

tonyqus commented Sep 27, 2023

@utthungagokul Are you sure it's just 2500KB (2.5M) in size? Or 2500K rows? Can you upload this Excel file to help reproduce the issue?

@utthungagokul
Copy link
Author

@tonyqus I have attached the sample (.xlsx) file for your reference.

Configuration1 - Copy.xlsx

@lahma FYI , I using a dev system with Intel 11th Generation Processors with 16GB RAM.

@lahma
Copy link
Collaborator

lahma commented Sep 28, 2023

Looking at the file there just seems to be a lot data, like Sheet7 having 25k rows. With NPOI release build it takes 2 secs to initialize the workbook on my machine (AMD Ryzen 9 5950X). One option could be to lazy-initialize some structures, but if you need to access the data anyway it would then be loaded making the lazy-loading moot.

@tonyqus tonyqus changed the title Excel XSSWorkbook takes more than 4 to 5sec to load from Stream (Bulk data) Excel XSSFWorkbook takes more than 4 to 5sec to load from Stream (Bulk data) Oct 8, 2023
@tonyqus
Copy link
Member

tonyqus commented Oct 8, 2023

@utthungagokul Have you tried ExcelDataReader of ClosedXML? I'd like to know their response time on this case.

@Bykiev
Copy link
Collaborator

Bykiev commented Apr 9, 2024

@utthungagokul Have you tried ExcelDataReader of ClosedXML? I'd like to know their response time on this case.

I've tested with ClosedXML and here is result:

Elapsed NPOI: 9,0083647
Elapsed ClosedXML: 13,5467912

tested on core i3 6100u, code:

string filePath = "Configuration1.-.Copy (1).xlsx";

Stopwatch sw = new Stopwatch();
sw.Start();

using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
    using (XSSFWorkbook xssfWorkbook = new XSSFWorkbook(stream)) { }
}

sw.Stop();
Console.WriteLine("Elapsed NPOI: " + sw.Elapsed.TotalSeconds);

sw.Reset();
sw.Start();

using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
    using (var workbook = new XLWorkbook(stream)) { }
}

sw.Stop();
Console.WriteLine("Elapsed ClosedXML: " + sw.Elapsed.TotalSeconds);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants