We’re experiencing an error when using Apose.Cells v7.4.1 and AutoFitColumns method, when used in a Kubernetes Docker container. The exact error we’re seeing is:
System.NullReferenceException: Object reference not set to an instance of an object.
at ..’(String , Int32 , FontStyle )
at ’’..(‘’ , Int32 , RectangleF )
at ’’..(Graphics , Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at ’’..AutoFitColumn(Cells , Int32 , Int32 , Int32 , Int32 , AutoFitterOptions )
at Aspose.Cells.Worksheet.AutoFitColumns()
at Test1_Aspose_Cells._7._4._1.Controllers.ValuesController.Get() in C:\Code\Work\Aspose.Cell.Excel_VersionDockerTest\Test1_Old\Test1_Aspose.Cells.7.4.1\Test1_Aspose.Cells.7.4.1\Controllers\ValuesController.cs:line 46
The following code reproduces the exception above:
try
{
var wb = new Workbook();
var ws = wb.Worksheets[0];
ws.Name = "Test1_Aspose_Cells._7._4._1";
var cellStrings = new string[] { "value1", "value2", "value3", "value4" };
for (int i = 0; i < cellStrings.Length - 1; i++)
{
var cell = ws.Cells[0, 0]; //A1
cell.PutValue($"{cellStrings[i]} - CCCCC ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH ----- MY Long Test String ---------------- HHHHHHHHHHHHHHHHHHHHHHHHH");
var style = cell.GetStyle();
var font = style.Font;
font.Size = 15;
cell.SetStyle(style);
}
ws.AutoFitColumns();
ws.AutoFitRows();
wb.Save("Test1_Aspose_Cells._7._4._1.xlsx");
return true;
}
catch
{
return false;
}
Besides upgrading to the latest version of Cells, is there any means to get this working inside of Docker?