Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Microservices, in conjunction with containerization make it possible to easily combine technologies. Docker allows you to easily integrate Aspose.Cells functionality into your application, regardless of what technology is in your development stack.
In case you are targeting microservices, or if the main technology in your stack is not .NET, C++ or Java, but you need Aspose.Cells functionality, or if you already use Docker in your stack, then you may be interested in utilizing Aspose.Cells in a Docker container.
Docker must be installed on your system. For information on how to install Docker on Windows or Mac, refer to the links in the “See Also” section.
Also, note that Visual Studio 2019, .NET Core 3.1 SDK is used in the example, provided below.
In this example, you create a simple Hello World console application that makes a “Hello World!” document and saves it in all supported save formats. The application can then be built and run in Docker.
To create the Hello World program, follow the steps below:


using System;
namespace Aspose.Cells.Docker
{
class Program
{
static void Main(string[] args)
{
Workbook workbook = new Workbook();
workbook.Worksheets[0].Cells[0, 0].PutValue("Hello from Aspose.Cells!!!");
foreach (SaveFormat sf in Enum.GetValues(typeof(SaveFormat)))
{
if (sf != SaveFormat.Unknown)
{
try
{
// The folder specified will be mounted as a volume when run the application in Docker image.
var fileName = string.Format("out{0}", FileFormatUtil.SaveFormatToExtension(sf));
workbook.Save(fileName, sf);
Console.WriteLine("Saving {0}\t\t[OK]", sf);
}
catch
{
Console.WriteLine("Saving {0}\t\t[FAILED]", sf);
}
}
}
}
}
}
Note that the “TestOut” folder is specified as an output folder for saving output documents. When running the application in Docker, a folder on the host machine will be mounted to this folder in the container. This will enable you to easily view the output generated by Aspose.Cells in the Docker container.
The next step is to create and configure the Dockerfile.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster
COPY fonts/* /usr/share/fonts/
WORKDIR /app
COPY . ./
RUN apt-get update && \
apt-get install -y --allow-unauthenticated libgdiplus libc6-dev
RUN dotnet publish "Aspose.Cells.Docker.csproj" -c Release -o /app/publish
ENTRYPOINT ["dotnet", "publish/Aspose.Cells.Docker.dll"]The above is a simple Dockerfile, which contains the following instructions:
Now the application can be built and run in Docker. Open your favorite command prompt, change directory to the folder with the application (folder where the solution file and the Dockerfile are placed) and run the following command:
docker build -t actest .The first time this command is executed it may take longer, since Docker needs to download the required images. Once the previous command is completed, run the following command:
docker run --mount type=bind,source=C:\Temp,target=/TestOut --rm actest from Docker1. To run the application in Windows Server 2019
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2019
WORKDIR /app
COPY . ./
RUN dotnet publish "Aspose.Cells.Docker.csproj" -c Release -o /app/publish
ENTRYPOINT ["dotnet", "publish/Aspose.Cells.Docker.dll"]docker build -t actest .docker run --mount type=bind,source=C:\Temp,target=c:\TestOut --rm actest from Docker2. To run the application in Linux
namespace Aspose.Cells.Docker.Fonts
{
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
try
{
// Set font folders on linux.
string[] fonts = { "/Fonts" };
FontConfigs.SetFontFolders(fonts, true);
// build workbook
Workbook workbook = new Workbook();
MemoryStream memoryStream = new MemoryStream();
workbook.Worksheets[0].Cells[0, 0].PutValue("Hello from Aspose.Cells!!!");
Style style = workbook.CreateStyle();
style.Font.Name = "Arial";
style.Font.Size = 16;
workbook.Worksheets[0].Cells[0, 0].SetStyle(style);
workbook.Save("/TestOut/TestFontsOut.xlsx");
}
catch (Exception e)
{
Console.WriteLine("Saving outfonts.xlsx\t\t[FAILED],{0}", e.Message);
}
}
}
}
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster
WORKDIR /app
COPY . ./
RUN apt-get update && \
apt-get install -y --allow-unauthenticated libgdiplus libc6-dev
WORKDIR /app
COPY . ./
RUN dotnet publish "Aspose.Cells.Docker.Fonts.csproj" -c Release -o /app/publish
ENTRYPOINT ["dotnet", "publish/Aspose.Cells.Docker.Fonts.dll"]docker build -t actest .docker run --mount type=bind,source=C:\Windows\Fonts,target=/Fonts --mount type=bind,source=C:\Temp,target=/TestOut --rm actest from DockerFor the .NET6 (or later) platforms, compare to previous platforms (.netcore31 or before), an important difference is about the graphics library. In this official Microsoft Document, it explains for .NET6 or later releases the graphics library “System.Drawing.Common” will be only supported on Windows, and gives recommendations to replace the graphics library.
So, Aspose.Cells provides a solution that relies on the SkiaSharp graphics library on non-Windows platforms. We recommend using SkiaSharp as the library on macOS, which also means that there is no need to install libgdiplus.
For information on how to install Aspose.Cells on non-Windows platforms and use SkiaSharp as graphics library, please refer to the following article: How to Run Aspose.Cells for .Net6
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.