From 89b85934f60ba0012f3de6da03eb12959e4b4b72 Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 27 Dec 2021 23:34:14 +0800 Subject: This closes #1096, memory usage optimization and another 4 changes - Unzip shared string table to system temporary file when large inner XML, reduce memory usage about 70% - Remove unnecessary exported variable `XMLHeader`, we can using `encoding/xml` package's `xml.Header` instead of it - Using constant instead of inline text for default XML path - Rename exported option field `WorksheetUnzipMemLimit` to `UnzipXMLSizeLimit` - Unit test and documentation updated --- templates.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'templates.go') diff --git a/templates.go b/templates.go index 56588c4..1783d7c 100644 --- a/templates.go +++ b/templates.go @@ -14,13 +14,22 @@ package excelize -// XMLHeader define an XML declaration can also contain a standalone declaration. -const XMLHeader = "\n" +import "encoding/xml" var ( // XMLHeaderByte define an XML declaration can also contain a standalone // declaration. - XMLHeaderByte = []byte(XMLHeader) + XMLHeaderByte = []byte(xml.Header) +) + +const ( + defaultXMLPathContentTypes = "[Content_Types].xml" + dafaultXMLPathDocPropsApp = "docProps/app.xml" + dafaultXMLPathDocPropsCore = "docProps/core.xml" + dafaultXMLPathCalcChain = "xl/calcChain.xml" + dafaultXMLPathSharedStrings = "xl/sharedStrings.xml" + defaultXMLPathStyles = "xl/styles.xml" + defaultXMLPathWorkbook = "xl/workbook.xml" ) const templateDocpropsApp = `0Go Excelize` -- cgit v1.2.1