diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs index f47f720..2d2f211 100644 --- a/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/Excel/XLWorkbook_Load.cs @@ -588,7 +588,7 @@ { if (pf.AverageSubTotal != null) pivotField.AddSubtotal(XLSubtotalFunction.Average); - if (pf.CountASubtotal != null) + if (pf.CountASubtotal != null) pivotField.AddSubtotal(XLSubtotalFunction.Count); if (pf.CountSubtotal != null) pivotField.AddSubtotal(XLSubtotalFunction.CountNumbers); @@ -826,8 +826,12 @@ Xdr.ShapeProperties spPr = anchor.Descendants().First(); picture.Placement = XLPicturePlacement.FreeFloating; - picture.Width = ConvertFromEnglishMetricUnits(spPr.Transform2D.Extents.Cx, GraphicsUtils.Graphics.DpiX); - picture.Height = ConvertFromEnglishMetricUnits(spPr.Transform2D.Extents.Cy, GraphicsUtils.Graphics.DpiY); + + if (spPr?.Transform2D?.Extents?.Cx.HasValue ?? false) + picture.Width = ConvertFromEnglishMetricUnits(spPr.Transform2D.Extents.Cx, GraphicsUtils.Graphics.DpiX); + + if (spPr?.Transform2D?.Extents?.Cy.HasValue ?? false) + picture.Height = ConvertFromEnglishMetricUnits(spPr.Transform2D.Extents.Cy, GraphicsUtils.Graphics.DpiY); if (anchor is Xdr.AbsoluteAnchor) { diff --git a/ClosedXML_Tests/ClosedXML_Tests.csproj b/ClosedXML_Tests/ClosedXML_Tests.csproj index cf2d274..a47cead 100644 --- a/ClosedXML_Tests/ClosedXML_Tests.csproj +++ b/ClosedXML_Tests/ClosedXML_Tests.csproj @@ -303,6 +303,7 @@ + diff --git a/ClosedXML_Tests/Excel/Loading/LoadingTests.cs b/ClosedXML_Tests/Excel/Loading/LoadingTests.cs index e376449..cafd8d1 100644 --- a/ClosedXML_Tests/Excel/Loading/LoadingTests.cs +++ b/ClosedXML_Tests/Excel/Loading/LoadingTests.cs @@ -34,7 +34,8 @@ @"Misc\TableWithNameNull.xlsx", @"Misc\DuplicateImageNames.xlsx", @"Misc\InvalidPrintArea.xlsx", - @"Misc\Date1904System.xlsx" + @"Misc\Date1904System.xlsx", + @"Misc\LoadImageWithoutTransform2D.xlsx" }; foreach (var file in files) diff --git a/ClosedXML_Tests/Resource/Misc/LoadImageWithoutTransform2D.xlsx b/ClosedXML_Tests/Resource/Misc/LoadImageWithoutTransform2D.xlsx new file mode 100644 index 0000000..f02d8c0 --- /dev/null +++ b/ClosedXML_Tests/Resource/Misc/LoadImageWithoutTransform2D.xlsx Binary files differ