summaryrefslogtreecommitdiff
path: root/styles.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-12-27 23:34:14 +0800
committerxuri <xuri.me@gmail.com>2021-12-27 23:49:28 +0800
commit89b85934f60ba0012f3de6da03eb12959e4b4b72 (patch)
tree3d913c2bdabf06b79b7c2f223cfe26b64aacd8cc /styles.go
parent6b1e592cbc7b1412da5f6d0badeaf1083117c762 (diff)
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
Diffstat (limited to 'styles.go')
-rw-r--r--styles.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/styles.go b/styles.go
index d9e3e8f..da532fd 100644
--- a/styles.go
+++ b/styles.go
@@ -1078,7 +1078,7 @@ func (f *File) stylesReader() *xlsxStyleSheet {
if f.Styles == nil {
f.Styles = new(xlsxStyleSheet)
- if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML("xl/styles.xml")))).
+ if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathStyles)))).
Decode(f.Styles); err != nil && err != io.EOF {
log.Printf("xml decode error: %s", err)
}
@@ -1092,7 +1092,7 @@ func (f *File) stylesReader() *xlsxStyleSheet {
func (f *File) styleSheetWriter() {
if f.Styles != nil {
output, _ := xml.Marshal(f.Styles)
- f.saveFileList("xl/styles.xml", f.replaceNameSpaceBytes("xl/styles.xml", output))
+ f.saveFileList(defaultXMLPathStyles, f.replaceNameSpaceBytes(defaultXMLPathStyles, output))
}
}
@@ -1101,7 +1101,7 @@ func (f *File) styleSheetWriter() {
func (f *File) sharedStringsWriter() {
if f.SharedStrings != nil {
output, _ := xml.Marshal(f.SharedStrings)
- f.saveFileList("xl/sharedStrings.xml", f.replaceNameSpaceBytes("xl/sharedStrings.xml", output))
+ f.saveFileList(dafaultXMLPathSharedStrings, f.replaceNameSpaceBytes(dafaultXMLPathSharedStrings, output))
}
}