Hi Leoluo,
Thanks for your response.
Here is our situation, we have two test-cases with Aspose.Cell one which works and another one fails.
The code which works.
Code snippet.
// When you create a new workbook, a default “Sheet1” is added to the workbook.
Worksheet sheet = wb.Worksheets[0];
// Access the “A1” cell in the sheet.
Cell cell1 = sheet.Cells[“A1”];
Cell cell2 = sheet.Cells[“A2”];
cell1.PutValue(DateTime.Now.ToString());
// Input the “Hello World!” text into the “A1” cell
cell2.PutValue($“Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!Hello World!”);
// Save the Excel file.
byte[] fileContent;
using (MemoryStream myStream = new MemoryStream())
{
wb.Save(myStream, SaveFormat.Xlsx);
fileContent = myStream.ToArray();
}
The code which breaks.
Tried to invoke “this.ExcelWorkBook.Worksheets[i].AutoFitColumns();” ended up with following exception
MessageId: 3194a870-7c0c-4cba-9965-5ccb888383a1 - Exception: System.TypeInitializationException: The type initializer for ‘’ threw an exception.
System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
System.DllNotFoundException: Unable to load shared library ‘libgdiplus’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip…cctor()
— End of inner exception stack trace —
at System.Drawing.SafeNativeMethods.Gdip.GdipStringFormatGetGenericTypographic(IntPtr& format)
at System.Drawing.StringFormat.get_GenericTypographic()
at …cctor()
— End of inner exception stack trace —
at .(String , Font , Double )
at .(Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at .(Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at Aspose.Cells.Worksheet.AutoFitColumns()
Docker file
FROM public.ecr.aws/lambda/dotnet:6 AS base
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim as build
RUN apt-get update && apt-get install -y libgdiplus
COPY src /src
WORKDIR “/src/lambda_function”
RUN dotnet restore “lambda_function.csproj”
RUN dotnet build “lambda_function.csproj” --configuration Release --output /app/build -
FROM build AS publish
RUN dotnet publish “lambda_function.csproj”
–configuration Release \
–runtime linux-x64
–self-contained false \
–output /app/publish
-p:PublishReadyToRun=true
FROM base AS final
WORKDIR /var/task
COPY --from=publish /app/publish .