Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Commented Unassigned: Error Save when [state="veryHidden" r:id=""] is in workbook.xml [14852]

$
0
0
Hello, I found a issue that an exception would be thrown out when save a Excel if there is __state="veryHidden" r:id=""__ in workbook.xml. Because __r:id__ is empty.

here is the workbook.xml:
```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="9302" codeName="{00000000-0000-0000-0000-000000000000}" />
<workbookPr codeName="ThisWorkbook" />
<bookViews>
<workbookView xWindow="360" yWindow="225" windowWidth="12390" windowHeight="7800" tabRatio="784" />
</bookViews>
<sheets>
<sheet name="BPOP" sheetId="1" r:id="rId1" />
<sheet name="Module_Main" sheetId="2" state="veryHidden" r:id="" /> ---> HERE Throw Error..
<sheet name="Funds_Module" sheetId="3" state="veryHidden" r:id="" />
<sheet name="dlg_Options" sheetId="4" state="hidden" r:id="rId2" />
<sheet name="ModuleBPOP" sheetId="5" state="veryHidden" r:id="" />
</sheets>
<functionGroups builtInGroupCount="17" />
<definedNames>
<definedName name="Fund">'BPOP'!$A$5</definedName>
</definedNames>
<calcPr calcId="144525" />
</workbook>
```

Here is the stack:

```
System.InvalidOperationException: Error saving file C:\TEMP\Test\TEST_signed.xlsm ---> System.ArgumentNullException: Value cannot be null.
Parameter name: name
at System.Xml.XmlConvert.VerifyNCName(String name)
at MS.Internal.IO.Packaging.InternalRelationshipCollection.ThrowIfInvalidXsdId(String id)
at System.IO.Packaging.PackagePart.GetRelationshipHelper(String id)
at System.IO.Packaging.PackagePart.GetRelationship(String id)
at OfficeOpenXml.ExcelWorksheets..ctor(ExcelPackage pck, XmlNamespaceManagernsm, XmlNode topNode) in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelWorksheets.cs:line 79
at OfficeOpenXml.ExcelWorkbook.get_Worksheets() in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelWorkbook.cs:line 254
at OfficeOpenXml.ExcelWorkbook.Save() in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelWorkbook.cs:line 614
at OfficeOpenXml.ExcelPackage.Save() in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelPackage.cs:line 710
--- End of inner exception stack trace ---
at OfficeOpenXml.ExcelPackage.Save() in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelPackage.cs:line 763
at OfficeOpenXml.ExcelPackage.SaveAs(FileInfo file) in C:\Proj\epplus_d09aa5eaced9\EPPlus\ExcelPackage.cs:line 786
at test.Program.Main(String[] args) in C:\Proj\epplus_d09aa5eaced9\test\Program.cs:line 54
```

here is a temp fix:


```
foreach (XmlNode sheetNode in topNode.ChildNodes)
{
string name = sheetNode.Attributes["name"].Value;
//Get the relationship id
string relId = sheetNode.Attributes["r:id"].Value;

//temp fix by leon
if (String.IsNullOrEmpty(relId))
continue;

int sheetID = Convert.ToInt32(sheetNode.Attributes["sheetId"].Value);

//Hidden property
eWorkSheetHidden hidden = eWorkSheetHidden.Visible;
XmlNode attr = sheetNode.Attributes["state"];
if (attr != null)
hidden = TranslateHidden(attr.Value);

PackageRelationship sheetRelation = pck.Workbook.Part.GetRelationship(relId); ------->here the exception threw because relId is empty.
Uri uriWorksheet = PackUriHelper.ResolvePartUri(pck.Workbook.WorkbookUri, sheetRelation.TargetUri);

//add the worksheet
_worksheets.Add(positionID, new ExcelWorksheet(_namespaceManager, _pck, relId, uriWorksheet, name, sheetID, positionID, hidden));
positionID++;
}
```

Comments: I am not allowed to upload the Excel file, but one thing I'd like to say is: Module_Main, Funds_Module and ModuleBPOP are all VBA Module names.

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>