I’m trialling the Dotnet Core C# version of Aspose for a project and plan to use it on a Linux machine.
I’ve written some code that opens an XLSX file that was created in Excel, does stuff with the contents, and then saves the file to a different folder. Everything is working fine when run on a Windows machine.
However, when I run the code on Linux I get a NullReferenceException when saving the file.
EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)
The method signature in the error has filename and saveoptions, but I’m calling the save method which takes just a filename wb.Save(fullSavePath);
If I change it to wb.Save(fullSavePath, SaveFormat.Xlsx.); I get the same error.
It saves a file, but it is corrupt.
Details, steps I’ve taken and other info that might help
Linux is Debian running in WSL.
Aspose.Cells is the current version, 19.7.0
I’ve installed TTF fonts in Linux, and set the Font Folder
I save charts from the worksheet and these are saving fine on linux
Using wb.Save(savePath + “test.xlsx”, SaveFormat.Xlsx); Throws the null exception and creates a corrupt file
Using wb.Save(savePath + “test.csv”, SaveFormat.CSV); works and saves the first sheet
Using wb.Save(savePath + “test.pdf”, SaveFormat.Pdf); works, and saves a PDF with all the sheets
Using wb.Save(savePath + “test.xlsb”, XlsbSaveOptions(SaveFormat.Xlsb)); Throws the null exception and creates a corrupt file
@chris-7,
You may send us your runnable console application along with the template XLSX file, the program output file and expected output file created by Excel for our reference. We will use this application for testing this issue and provide our feedback after detailed analysis.
And install libc6-dev: apt-get install -y --no-install-recommends libc6-dev
After all these steps I saved one of my sample XLSX file as XLSB and got no error. Would you please check your scenario again by following these steps and share the feedback? If you still find some issue, please share your sample XLSX file for our reference.
HI!
I tried as you said, but it still doesn’t work.
This is my code:
dockerfile dockerfile.png (8.9 KB)
Error message excel报错.png (23.7 KB)
system message linux.png (5.7 KB)
Ordinary excel .xlsx files can reproduce this problem.
Open the .xlsx file and save the .xlsx will cause an error
@tianmin,
I have tried the complete scenario again by creating a new Debian docker container and then installed .NET Core 5.0. Following sample code is executed which runs fine without any error. Could you please follow the steps below and try the scenario again:
Pull the image as follows:
docker pull debian
Start the Debian image and then execute the following commands in the container:
@tianmin,
Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.