简体   繁体   中英

EPPlus Range Formula calculation takes forever on larger files

I am working on a worksheet that contains around 87,000 rows and I am using a formula to add up purchase amounts that only belong to a certain invoice.

Here is my formula:

workSheet.Cells[2, 17, workSheet.Dimension.End.Row, 17].Formula = "SUMIF(A:A,A"+2+",N:N)";

And then I run an epplus range calculation so I can work with the values programmatically:

workSheet.Cells[2, 17, workSheet.Dimension.End.Row, 17].Calculate();

However, this.Calculate() takes a super long time to run. It works fine with smaller files. But once the data gets too big it increases the time complexity tremendously.

Is there anything I can do with the formula or EPPlus to have this.Calculate() execute quickly? Thanks!

Answer in comments:

I have found out that the particular Excel formula is O(n^2) time complexity because it recursively rechecks all the rows again for each row it passes when .calculate() is called within EPPlus, so I just had to make my own formula in C# that basically does what the Excel formula is supposed to do, but this time it is O(n) time complexity which tremendously sped things up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM