I am trying to create a table in .NET that will be opened by my manager on his iPad when he leaves the office.
The spreadsheet opens perfectly on a Windows PC, but when you try to open it on an iPad, it says “An error occurred while reading a document” (so useful!)
Using the Compare function in the OpenXML SDK Productivity tool with a document that makes it open on iPad, and by manually editing the XML files with notepad errors, I narrowed it down to the xl / _rels / workbook.xml.rels file in which the relations are stored parts in a book.
This is the code I use to create WorkbookPart and links.
WorkbookPart workbookPart1 = document.AddWorkbookPart();
WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart<WorkbookStylesPart>("rId3");
ThemePart themePart1 = workbookPart1.AddNewPart<ThemePart>("rId2");
WorksheetPart worksheetPart1 = workbookPart1.AddNewPart<WorksheetPart>("rId1");
My code generates the following output, which does not open on the 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>
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>
, :
.NET , XML .
!