Hi,
we are not able to convert a xlsx file to a pdf although our code works fine with other xlsx files.
Here is the code we are using. The xlsx file is attached. We are using dotnet 6.0 with the Syncfusion.XlsIORenderer.Net.Core 20.4.0.38 package.
using Syncfusion.XlsIO;
using Syncfusion.XlsIORenderer;
using var excelEngine = new ExcelEngine();
var application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
using var fileStream = new MemoryStream(File.ReadAllBytes("PermissionsTimings.xlsx"));
var workbook = application.Workbooks.Open(fileStream);
var worksheet = workbook.Worksheets.First();
var renderer = new XlsIORenderer
{
ChartRenderingOptions =
{
ScalingMode = ScalingMode.Best
},
};
var settings = new XlsIORendererSettings
{
EmbedFonts = true
};
var doc = renderer.ConvertToPDF(worksheet, settings);
var pdfStream = new MemoryStream();
doc.Save(pdfStream);
pdfStream.Seek(0, SeekOrigin.Begin);
File.WriteAllBytes("a.pdf", pdfStream.GetBuffer());
It seems to finish rendering after 10 minutes on my machine. But that's not a reasonable time. Either there is a way to improve performance with a trick or we need to cancel the task after say 30 seconds.
Greetings
Jan
Attachment: PermissionsTimings_7fe262e6.zip
Hi Jan,
We are able to reproduce the reported issue at our end and validating it currently. We will share the validation details on January 6th, 2023.
Regards,
Keerthi.
Jan, we have confirmed the issue as Performance delay occurs while converting Excel with conditional formatting to PDF and logged a defect report. We will include the fix for this issue in our weekly NuGet release scheduled for January 17th, 2023.
You can track the status of defect report through below feedback link.
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
For now, as a workaround, we suggest you to enable the sheet calculations to reduce the time for conversion. Please find the code snippet below.
IWorkbook workbook = application.Workbooks.Open(excelStream); workbook.Worksheets[0].EnableSheetCalculations(); |
Jan, we included the fix to resolve the issue Performance delay occurs while converting Excel with conditional formatting to PDF in our weekly NuGet release version 20.4.0.44. Kindly upgrade to this latest version and let us know if the reported issue is resolved.
Latest NuGet Package: https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core/20.4.0.44
Hi,
thank you very much! Still takes a couple of seconds (30 seconds), but acceptable I guess. Considering it took 10 minutes before the fix this is highly appreciated.
Jan
Thanks for your valuable feedback, Jan. Please contact us if you require any other assistance.