Calling this function on a 9M xlsx file takes about 2 minutes time. In contrast, saving the file only takes several seconds.
My profiling shows the hotspot is Bitmap creation in FontBaseExtensions.GetWidth function (or maybe GraghUtils.MeasureString?). Maybe a quick fix is to cache the bitmap object (or the graphics object instead) in MeasureString to avoid creating them every time.
Here's my profiling result:
![Image]()
![Image]()
My profiling shows the hotspot is Bitmap creation in FontBaseExtensions.GetWidth function (or maybe GraghUtils.MeasureString?). Maybe a quick fix is to cache the bitmap object (or the graphics object instead) in MeasureString to avoid creating them every time.
Here's my profiling result:

