v0.97 : ToAdjustContents() crash on Azure pipeline.
See original GitHub issueRead and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
- Bug
- Feature
- Question
Did you test against the latest CI build?
- Yes
- No
If you answered No
, please test with the latest development build first.
Version of ClosedXML
0.97.0
What is the current behavior?
Hi, I have a unit test executing using ToAdjustContents method. This unit test is OK when I run it on local. When deployed to azure pipeline, I have the following error:
Error Message: 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")'. Stack Trace: at ClosedXML.Graphics.DefaultGraphicEngine.LoadFont(MetricId metricId) at System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key, Func2 valueFactory) at ClosedXML.Graphics.DefaultGraphicEngine.GetFont(MetricId metricId) at ClosedXML.Graphics.DefaultGraphicEngine.GetFont(IXLFontBase fontBase) at ClosedXML.Graphics.DefaultGraphicEngine.GetTextWidth(String text, IXLFontBase fontBase, Double dpiX) at ClosedXML.Excel.XLColumn.GetWidthInCharacters(String text, IXLFontBase font) at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow, Double minWidth, Double maxWidth) at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow, Int32 endRow) at ClosedXML.Excel.XLColumn.AdjustToContents(Int32 startRow) at ClosedXML.Excel.XLColumn.AdjustToContents() at ClosedXML.Excel.XLColumns.<>c.<AdjustToContents>b__13_0(XLColumn c) at ClosedXML.Excel.EnumerableExtensions.ForEach[T](IEnumerable
1 source, Action1 action) at ClosedXML.Excel.XLColumns.AdjustToContents()
The issue appeared on release 0.97. It works fine on release 0.96.
What is the expected behavior or new feature?
Same behaviour as previous release.
Is this a regression from the previous version?
Yes.
Reproducibility
This is an important section. Read it carefully. Failure to do so will cause a ‘RTFM’ comment. Code to reproduce problem: The code looks like this:
public void Main()
{
` var workbook = new XLWorkbook();
IXLWorksheet worksheet = workbook.AddWorksheet(ExcelExportSheetName);
IXLRow headerRow = worksheet.Row(1);
row.Cell("A").SetValue("data1");
row.Cell("B").SetValue("data2");
...
row.Cell("AB").SetValue("dataN");
worksheet.Columns("Z").AdjustToContents();
for (int i = 0; i < orders.Count; i++)
{
var rowNumber = i + HeaderRowNumber + ExcelIndexOffset;
IXLRow xlRow = worksheet.Row(rowNumber);
xlRow.Cell("A").SetValue("some data");
...
xlRow.Cell("AB").SetValue("some data");
}
worksheet.Columns("A:Y").AdjustToContents();
worksheet.Columns("AA:AB").AdjustToContents();
`
}
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
If someone else is checking why this crashes on Linux distros. I did it like this:
And call
UpdateGraphicsEngineFonts()
BEFORE creating a workbook withusing XLWorkbook workbook = new();
.Thanks !
It works by adding:
LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine("DejaVu Sans");