From 70191af9fb2104d9a23466da578ef2b02cc84013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D1=80=D1=81=D1=82=D1=8E=D0=BA=20=D0=9C=D0=B8?= =?UTF-8?q?=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 17 May 2022 15:41:28 +0500 Subject: [PATCH] Fix "picture names cannot be empty" on Excel file opening Files created in Excel may contain pictures without a name, but you still want to open them. Fix with minimal impact on the core logic. --- ClosedXML/Excel/XLWorkbook_Load.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ClosedXML/Excel/XLWorkbook_Load.cs b/ClosedXML/Excel/XLWorkbook_Load.cs index 65e29b404..e163c7466 100644 --- a/ClosedXML/Excel/XLWorkbook_Load.cs +++ b/ClosedXML/Excel/XLWorkbook_Load.cs @@ -1125,7 +1125,7 @@ private void LoadDrawings(WorksheetPart wsPart, IXLWorksheet ws) stream.CopyTo(ms); var vsdp = GetPropertiesFromAnchor(anchor); - var picture = (ws as XLWorksheet).AddPicture(ms, vsdp.Name, Convert.ToInt32(vsdp.Id.Value)) as XLPicture; + var picture = (ws as XLWorksheet).AddPicture(ms, String.IsNullOrWhiteSpace(vsdp.Name) ? "noname" : (string)vsdp.Name, Convert.ToInt32(vsdp.Id.Value)) as XLPicture; picture.RelId = imgId; Xdr.ShapeProperties spPr = anchor.Descendants().First();