This short tutorial guides to Install Dotnet in Docker Container to use Aspose.Cells. It contains detailed steps to create the Docker Image for using Aspose.Cells for .NET in it. In the end, you will be able to process Excel in Linux like converting XLSX, XLS, ODS, or XLSM to PDF with the help of a runnable sample code.
Steps to Install Dotnet in Docker Container to use Aspose.Cells
- Pull Docker image for Microsoft Dotnet
- Run the container and update the packages along with the list of packages
- Install wget command
- Install sudo command
- Install dotnet-sdk-3.1 with the help of sudo command
- Install libgdiplus and libc6-dev library
- Run the image by linking and opening your project folder on the host computer in the Docker container
- Run your test program
These steps describe the process to work with Excel on Ubuntu with the help of detailed steps. It is assumed that you have installed Docker software on your system and then you start by pulling the Docker image for Microsoft Dotnet and run this image. In the next step to work with Excel in Ubuntu necessary libraries and SDK is installed to do development and execution of the program in the Docker image and committed on the disk. In the last step, the development folder on the host system is linked with some folder in the Docker image, and the test program is executed.
Script to Install Dotnet in Docker Container to use Aspose.Cells
Environment Setting | |
It is assumed that you have installed docker on your computer and then pulled the microsoft/dotnet container as follows: | |
docker pull microsoft/dotnet | |
After pulling this image run it and run following script one by one in the terminal window. | |
Step 1: | |
apt update && apt upgrade | |
Step 2: | |
apt install wget | |
Step 3: | |
apt-get install sudo | |
Step 4: | |
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
Step 5: | |
sudo dpkg -i packages-microsoft-prod.deb | |
Step 6: | |
sudo apt-get update; \ | |
sudo apt-get install -y apt-transport-https && \ | |
sudo apt-get update && \ | |
sudo apt-get install -y dotnet-sdk-3.1 | |
Step 7: | |
sudo apt-get install libgdiplus | |
ln -s libgdiplus.so gdiplus.dll | |
Step 8: | |
sudo apt-get install libc6-devStep 1: | |
apt update && apt upgrade | |
Create a console-based project and put the following code in it. | |
Sample Code | |
As we are demonstrating the Excel to PDF conversion, your console application may look as follows: | |
// Instantiate new workbook | |
Workbook workbook = new Workbook("sample.xlsx"); | |
// Define PdfSaveOptions | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
// Set the compliance type | |
pdfSaveOptions.Compliance = PdfCompliance.PdfA1b; | |
// Save the file | |
workbook.Save("output.pdf", pdfSaveOptions); | |
You can compile and run this application in your container as SDK is also installed. Link some of the folders on the host operating system and run the saved image having all the required libraries. Use the following command to load the image by connecting to the Desktop folder. | |
docker run -it -v ~/Desktop:/Desktop Microsoft/dotnet /bin/bash | |
Navigate to the project where the .proj file is present and run the application using the following command. It is assumed that the application is compiled already. You can compile it here as well if required. | |
dotnet run |
This script assists in establishing the complete environment to run Aspose.Cells for .NET in the Docker container. While working in Linux spreadsheet can be created and processed with full functionality. You have to prepare the container first by installing the required libraries and then commit it to make the changes permanent.
This tutorial has guided us to work with Excel in Linux. If you want to work with Excel in Python via Java, refer to the article on how to install python to run aspose cells for python via java.