diff --git a/sheet.go b/sheet.go index 351a5372..16b9a604 100644 --- a/sheet.go +++ b/sheet.go @@ -70,7 +70,7 @@ func (f *File) setWorkbook(name string, rid int) { if err != nil { fmt.Println(err) } - f.saveFileList(`xl/workbook.xml`, replaceRelationshipsNameSpace(string(output))) + f.saveFileList(`xl/workbook.xml`, workBookCompatibility(replaceRelationshipsNameSpace(string(output)))) } // Read and unmarshal workbook relationships of XLSX. @@ -118,7 +118,7 @@ func (f *File) setAppXML() { // horrible hack to fix that after the XML marshalling is completed. func replaceRelationshipsNameSpace(workbookMarshal string) string { oldXmlns := `` - newXmlns := `` + newXmlns := `` return strings.Replace(workbookMarshal, oldXmlns, newXmlns, -1) } @@ -200,5 +200,14 @@ func workBookCompatibility(workbookMarshal string) string { workbookMarshal = strings.Replace(workbookMarshal, `>`, ` />`, -1) workbookMarshal = strings.Replace(workbookMarshal, `>`, ` />`, -1) workbookMarshal = strings.Replace(workbookMarshal, `>`, ` />`, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) + workbookMarshal = strings.Replace(workbookMarshal, ``, ``, -1) return workbookMarshal } diff --git a/xmlWorkbook.go b/xmlWorkbook.go index b5c68797..c1969000 100644 --- a/xmlWorkbook.go +++ b/xmlWorkbook.go @@ -37,14 +37,17 @@ type xlsxWorkbook struct { WorkbookProtection xlsxWorkbookProtection `xml:"workbookProtection"` BookViews xlsxBookViews `xml:"bookViews"` Sheets xlsxSheets `xml:"sheets"` + ExternalReferences xlsxExternalReferences `xml:"externalReferences"` DefinedNames xlsxDefinedNames `xml:"definedNames"` CalcPr xlsxCalcPr `xml:"calcPr"` + PivotCaches xlsxPivotCaches `xml:"pivotCaches"` + ExtLst xlsxExtLst `xml:"extLst"` FileRecoveryPr xlsxFileRecoveryPr `xml:"fileRecoveryPr"` } // xlsxFileRecoveryPr maps sheet recovery information. type xlsxFileRecoveryPr struct { - RepairLoad int `xml:"repairLoad,attr"` + RepairLoad int `xml:"repairLoad,attr,omitempty"` } // xlsxWorkbookProtection directly maps the workbookProtection element from the @@ -122,6 +125,43 @@ type xlsxSheet struct { State string `xml:"state,attr,omitempty"` } +// xlsxExternalReferences directly maps the externalReferences element +// of the external workbook references part. +type xlsxExternalReferences struct { + ExternalReference []xlsxExternalReference `xml:"externalReference"` +} + +// xlsxExternalReference directly maps the externalReference element +// of the external workbook references part. +type xlsxExternalReference struct { + RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` +} + +// xlsxPivotCaches element enumerates pivot cache definition parts +// used by pivot tables and formulas in this workbook. +type xlsxPivotCaches struct { + PivotCache []xlsxPivotCache `xml:"pivotCache"` +} + +// xlsxPivotCache directly maps the pivotCache element. +type xlsxPivotCache struct { + CacheID int `xml:"cacheId,attr,omitempty"` + RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` +} + +// extLst element provides a convention for extending spreadsheetML in +// predefined locations. The locations shall be denoted with the extLst +// element, and are called extension lists. Extension list locations +// within the markup document are specified in the markup specification +// and can be used to store extensions to the markup specification, +// whether those are future version extensions of the markup specification +// or are private extensions implemented independently from the markup +// specification. Markup within an extension might not be understood by a +// consumer. +type xlsxExtLst struct { + Ext string `xml:",innerxml"` +} + // xlsxDefinedNames directly maps the definedNames element from the // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main // - currently I have not checked it for completeness - it does as diff --git a/xmlWorksheet.go b/xmlWorksheet.go index be7dcc2c..4752a158 100644 --- a/xmlWorksheet.go +++ b/xmlWorksheet.go @@ -26,6 +26,7 @@ type xlsxWorksheet struct { LegacyDrawing xlsxLegacyDrawing `xml:"legacyDrawing"` Picture xlsxPicture `xml:"picture"` TableParts xlsxTableParts `xml:"tableParts"` + ExtLst xlsxExtLst `xml:"extLst"` } // xlsxDrawing change r:id to rid in the namespace.