Hi,
I am evaluating Aspose.Cells .NET when I get a similar issues that customer get in this thread Aspose.cells: saving excel to pdf don't work on docker container.
image.png (33.1 KB)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Aspose.Cells.CellsException: The type initializer for ‘’ threw an exception.
at Aspose.Cells.Workbook.Save(Stream stream, SaveOptions saveOptions)
at WorkbookManager.SaveWorkbookAsPdf(String templateName) in /workspace/temp_poc_aspoce_cells/ExcelAPI/Program.cs:line 96
at Program.<>c.<<$>b__0_2>d.MoveNext() in /workspace/temp_poc_aspoce_cells/ExcelAPI/Program.cs:line 33
— End of stack trace from previous location —
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
I tried what fixed it for the customer by modifying my docker file to this:
FROM gitpod/workspace-dotnet:latest RUN sudo apt-get install -y libfontconfig1 RUN sudo apt-get install -y libgdiplus RUN cd /usr/lib && sudo ln -s libgdiplus.so gdiplus.dll RUN sudo apt-get install -y --no-install-recommends libc6-dev RUN sudo apt-get install -y cabextract xfonts-utils \ && sudo wget http://ftp.us.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.7_all.deb \ && sudo dpkg -i ttf-mscorefonts-installer_3.7_all.deb \ && sudo fc-cache -f -v
I am using target net7.0 and Aspose.Cells/23.9.0
I also created a runtimeconfig.template.json that I put in the root directory, the application directory and the obj sub folder of the application directory to be sure it’s being used.
{
“configProperties”: {
“System.Drawing.EnableUnixSupport”: true
}
}
I am making sure that the Excel is properly exported to XLSX before I try to export it to PDF.
_workbook = new Workbook($“…/Templates/{templateName}.xlsx”);
_workbook.Save($“…/Output/{templateName}.xlsx”, SaveFormat.Xlsx);
_workbook.Save($“…/Output/{templateName}.pdf”, new PdfSaveOptions());
The XLSX is exported correctly.
Nothing I tried had fixed the issue. What should I do?