Official response
Mario at GemBox
Hi,
Please try using the latest GemBox.Spreadsheet for .NET Standard.
It has cross-platform support for AutoFit methods, it doesn't have Windows Forms dependency.
Regards,
Mario
Comments (7)
We have recently released a GemBox.Spreadsheet for .NET Core 3.0 which does support AutoFit methods on Windows.
Currently, there is no cross-platform support.
To use it in desktop applications you'll need to use "Microsoft.NET.Sdk.WindowsDesktop" SDK and set the "UseWPF" property to "true".
To use it in a web application you'll need to add a framework reference for "Microsoft.WindowsDesktop.App".
Also, if your cells contain single font then perhaps you could create some approximation that would be based on text length and font size.
For instance, you could calculate the average widths of some characters, like numbers, lower case letters, and upper case letters, and use that to auto fit the content.
Additionally, you could perhaps handle separately the characters that have narrow font glyphs (for example those are typically letters 'i', 'I', 'j', etc.) and wide font glyphs ('O', 'W', etc.).
Hopefully, that would provide you decent accuracy for your requirement.
Regards,
Mario
Thanks for tackling this issue knowing how hard it is. If GemBox was to support it for most of the common fonts (Arial, Tahoma, Courier, Calibri, etc.) it would satisfy most needs. Perhaps with an overload for adjustment (ex. AutoFit(decimal pctAdjust).
For now, I am fine with Windows only. WinForm and WPF support is also Windows Core only so that is a safe approach that covers most scenarios.
My opinion, of course.
Thanks for everything.
Support for AutoFit in .NET Core on Windows has been implemented and is available in the latest versions of GemBox.Spreadsheet for .NET 3.0.
Because most of these requests were for .NET Core on Windows, we'll mark this request as "Completed".
Regards,
Mario