mganss / ExcelMapper

An Excel to object mapper. Maps POCOs to and from Excel. Configuration via convention, attributes, or fluent methods.
MIT License
793 stars 122 forks source link

Incompatibility of library versions? #278

Closed fox-15 closed 1 year ago

fox-15 commented 1 year ago

Hello! After the release of the ExcelMapper 5.2.542 update, an error appeared when using the ClosedXML.Report 0.2.8 library. When calling the ClosedXML.Report function var template = new XLTemplate(file); an error started appearing: MissingMethodException: Method not found:

'System.Collections.Generic.IEnumerable`1 SixLabors.Fonts.FontMetrics.GetGlyphMetrics(SixLabors.Fonts.Unicode.CodePoint, SixLabors.Fonts.ColorFontSupport)'.

But how did this become possible? These are different libraries!

While version ExcelMapper 5.2.535 works fine!

What could be causing this error?

Sincerely, Alexander

Full error text: MissingMethodException: Method not found: 'System.Collections.Generic.IEnumerable`1 SixLabors.Fonts.FontMetrics.GetGlyphMetrics(SixLabors.Fonts.Unicode.CodePoint, SixLabors.Fonts.ColorFontSupport)'. ClosedXML.Graphics.DefaultGraphicEngine.CalculateMaxDigitWidth(MetricId metricId) System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey key, Func<TKey, TValue> valueFactory) ClosedXML.Graphics.DefaultGraphicEngine.GetMaxDigitWidth(IXLFontBase fontBase, double dpiX) ClosedXML.Excel.XLWorkbook.CalculateColumnWidth(double charWidth, IXLFont font, XLWorkbook workbook) ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet) ClosedXML.Excel.XLWorkbook.LoadSheets(string fileName) ClosedXML.Report.XLTemplate..ctor(string fileName) Dragon.Areas.Report.Controllers.RechtController.Excel_061Async(int id, int doc, EmployeeViewModel em, ParamViewModel dm) in Recht_Excel_061.cs

MagicAndre1981 commented 1 year ago

https://github.com/ClosedXML/ClosedXML.Report/issues/326

NPOI, the lib used by ExcelMapper, made some nuget updates. Install SixLabors.Fonts 1.0 (non beta) to your project.

fox-15 commented 1 year ago

Installed SixLabors.Fonts 1.0.0 (11.08.2023) but the result is the same, cannot execute var template = new XLTemplate(file);

Method not found: 'System.Collections.Generic.IEnumerable`1 SixLabors.Fonts.FontMetrics.GetGlyphMetrics(SixLabors.Fonts.Unicode.CodePoint, SixLabors.Fonts.ColorFontSupport)'.

MagicAndre1981 commented 1 year ago

try to add this entry to csproj:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

fox-15 commented 1 year ago

For some reason this parameter line destroyed the entire project, but it’s okay, I’ll stay on the old version, it’s not critical. Thanks for trying to help

MagicAndre1981 commented 1 year ago

wait until the other project releases a new version which also uses te stable version of SixLabors.Fonts

tonyqus commented 1 year ago

ExcelMapper 5.2.542 is actually using SixLabors.Fonts 1.0 (Since NPOI 2.6.2 is using SixLabors.Font 1.0).

I confirmed that ClosedXML.Report 0.2.8 also uses SixLabors.Fonts 1.0. I think this issue is nothing to do with ExcelMapper or NPOI. Can you open a issue in ClosedXML.Report repo?

fox-15 commented 1 year ago

I went back to version 5.2.528, it works without errors

mganss commented 1 year ago

Closing this for now. ExcelMapper just has a direct dependency on NPOI, so the issue is likely somewhere else.