diff --git a/file.go b/file.go index 034eddab..f22e80c9 100644 --- a/file.go +++ b/file.go @@ -7,6 +7,7 @@ import ( "io" "os" "strconv" + "strings" ) // File is a high level structure providing a slice of Sheet structs @@ -203,6 +204,14 @@ func (f *File) MarshallParts() (map[string]string, error) { return parts, err } + // Make it work with Mac Numbers. + // Dirty hack to fix issues #63 and #91; encoding/xml currently + // "doesn't allow for additional namespaces to be defined in the root element of the document," + // as described by @tealeg in the comments for #63. + oldXmlns := `` + newXmlns := `` + parts["xl/workbook.xml"] = strings.Replace(parts["xl/workbook.xml"], oldXmlns, newXmlns, 1) + parts["_rels/.rels"] = TEMPLATE__RELS_DOT_RELS parts["docProps/app.xml"] = TEMPLATE_DOCPROPS_APP // TODO - do this properly, modification and revision information diff --git a/file_test.go b/file_test.go index 8b276c98..d71cf34d 100644 --- a/file_test.go +++ b/file_test.go @@ -636,8 +636,11 @@ func (l *FileSuite) TestMarshalFile(c *C) { c.Assert(parts["xl/_rels/workbook.xml.rels"], Equals, expectedXLSXWorkbookRels) // workbook.xml + // Note that the following XML snippet is just pasted in here to correspond to the hack + // added in file.go to support Apple Numbers so the test passes. + // `xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"` expectedWorkbook := ` -` +` c.Assert(parts["xl/workbook.xml"], Equals, expectedWorkbook) // [Content_Types].xml