worksheet.Columns[i].AutoFit();
This code will raise exception like this when run in a Linux container with .NET 6:
The type initializer for ‘‘Gdip’’ threw an exception.
System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Docs for more information.’, StackTrace: ’ at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)
Not sure if this is a known issue.