Slow performance for AdjustToContents() on large row numers
See original GitHub issueRead and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
If you answered No
, please test with the latest development build first.
Version of ClosedXML 0.95.4
What is the current behavior? If I execute the code worksheet.Columns().AdjustToContents() with 10’000 rows it takes more than 20 minutes (I stopped it).
What is the expected behavior or new feature? It should takes about an half seconds (as Excel does).
Is this a regression from the previous version? I don’t know.
Regressions get higher priority. Test against the latest build of the previous minor version. For example, if you experience a problem on v0.95.3, check whether it the problem occurred in v0.94.2 too.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment.
Without a code sample, it is unlikely that your issue will get attention. Don’t be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be minimal complete and verifiable. Sample spreadsheets should be attached whenever applicable. Remove sensitive information.
Code to reproduce problem:
public void Main()
{
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Dati");
DataGenerationWithBigData();
worksheet.Columns().AdjustToContents();
worksheet.PageSetup.PageOrientation = XLPageOrientation.Portrait;
worksheet.PageSetup.PaperSize = XLPaperSize.A4Paper;
workbook.CalculateMode = XLCalculateMode.Auto;
workbook.SaveAs(workbookFile);
}
- I attached a sample spreadsheet. (You can drag files on to this issue)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top GitHub Comments
@Netclick19 … you know you could limit that by yourself …
I just want to add that the AdjustToContents() method still takes a seemingly exorbitant amount of time. 10,000 rows with 32 columns (most of them populated with varying lengths of text) takes the AdjustToContents() method approximately 1 minute 17 seconds, or 130 rows per second. 250,000 rows took 31 minutes 15 seconds (133 rows per second).
This was measured by a System.Diagnostics.Stopwatch object that was started immediately before and stopped immediately after the AdjustToContents() method was called.
In case it’s helpful: Visual Studio 2022 .NET 6.0 ClosedXML v0.100.3 ExcelNumberFormat v1.1.0 OS: Windows Server 2019 CPU: Dual 3.00 GHz Intel Xeon® Gold 6284R RAM: 64 GB HDD: Solid state