我正在尝试在.NET中生成一个电子表格,当他不在办公室时,我的经理将在iPad上打开它.
电子表格在Windows PC上打开很好,但是当试图在iPad上打开时,它会显示"阅读文档时出错"(非常有用!)
通过使用OpenXML SDK Productivity工具上的"比较"功能和在iPad 上打开的文档,并通过在记事本中手动编辑错误文档的XML文件,我将其缩小到文件xl/_rels/workbook .xml.rels,用于存储工作簿中各部分的关系.
这是我用来生成WorkbookPart和引用的代码
WorkbookPart workbookPart1 = document.AddWorkbookPart();
WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId3");
ThemePart themePart1 = workbookPart1.AddNewPart<ThemePart>("rId2");
WorksheetPart worksheetPart1 = workbookPart1.AddNewPart<WorksheetPart>("rId1");
Run Code Online (Sandbox Code Playgroud)
我的代码生成以下输出,该输出无法在iPad上打开.
<?xml version="1.0" encoding="utf-8" ?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="/xl/styles.xml" Id="rId3" />
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="/xl/theme/theme.xml" Id="rId2" />
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="/xl/worksheets/sheet.xml" Id="rId1" />
</Relationships>
Run Code Online (Sandbox Code Playgroud)
如果我更改Target属性的值以使用相对引用路径,给出以下输出,则它会在iPad上打开.
<?xml version="1.0" encoding="utf-8" ?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" Id="rId3" />
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme.xml" Id="rId2" />
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet.xml" Id="rId1" />
</Relationships>
Run Code Online (Sandbox Code Playgroud)
所以问题是:
如何更改我的.NET代码,以便输出具有相对路径的XML的第二个版本.
感谢所有的帮助!