misterspeedy / FsExcel

An F# Excel spreadsheet generator
MIT License
143 stars 18 forks source link

Error in AutoFitting section of Tutorial.dib #41

Open misterspeedy opened 1 year ago

misterspeedy commented 1 year ago

On Ubuntu, get this error in the Autofitting section of the tutorial:

Error: System.ArgumentException: Unable to find font Calibri or fallback font Microsoft Sans Serif. Install missing fonts or specify a different fallback font through 'LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine("Fallback font name")'.
misterspeedy commented 1 year ago

Also occurs in "Tables from Types" section.

misterspeedy commented 1 year ago

...and "Enable Only" section of "Filters" section.

misterspeedy commented 1 year ago

...and "Apply AutoFilter" section.

misterspeedy commented 1 year ago

Added this code above the first usage of AutoFit in the tutorial:

// For non-Windows runtime environments you will have to add these lines to use AutoFit.
// This is because ClosedXML needs a font to work with when computing sizes. You may have
// to use a different font name if Liberation Sans is not installed on the target system.
open System.Runtime.InteropServices
if not (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) then
    LoadOptions.DefaultGraphicEngine <- new ClosedXML.Graphics.DefaultGraphicEngine("Liberation Sans") 
//

This seems the simplest solution. We could do something similar within the library code, but that doesn't solve the problem of what fonts are installed.

adelarsq commented 1 year ago

@misterspeedy Using a font name still can turn in a problem on non Windows systems. I think into two altenatives:

What you think?