First usage of ClosedXML.Report in each app run takes ages

184 Views Asked by At

I am considering to use ClosedXML.Report for generating simple report in my app. The problem is, that just reading a template gets 11 seconds and generating a file gets another 8 seconds. Saving then takes just one second.

All mentioned times are in Debug mode. In Release mode the times are approximately half, but still too slow.

Interesting is, that when I call the same routine during app run a while later, all mentioned processes lasts only circa 400ms.

The program I am using:

            var resultData = new MeasurementProtocolResultsData(listOfResults);

            var reportTemplate = new XLTemplate(@"Configuration/ExcelTemplate.xlsx");

            reportTemplate.AddVariable(resultData);
            reportTemplate.Generate();

The mentioned template has one row with 12 columns. The MeasurementProtocolResultsData class is just immutable data holder with a List that has 14 properties (short strings and doubles) and 30 items. Really not a big deal at all.

I'm using ClosedXML.Report 0.2.8 with ClosedXML 0.101.0. I cannot upgrade ClosedXML as it throws Method not found: 'ClosedXML.Excel.IXLRange ClosedXML.Excel.IXLPivotTable.get_SourceRange() with a newer versions. Everything with .NET Framework 4.8

I was trying some pre-caching by loading the ClosedXML.Report assembly during app start or even generating stub Excel file but interestingly that shortens the times only marginally if at all.

0

There are 0 best solutions below