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 --- cell_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cell_test.go') diff --git a/cell_test.go b/cell_test.go index 4a78a06..03de73b 100644 --- a/cell_test.go +++ b/cell_test.go @@ -649,3 +649,20 @@ func TestFormattedValue2(t *testing.T) { v = f.formattedValue(1, "43528", false) assert.Equal(t, "43528", v) } + +func TestSharedStringsError(t *testing.T) { + f, err := OpenFile(filepath.Join("test", "Book1.xlsx"), Options{UnzipXMLSizeLimit: 128}) + assert.NoError(t, err) + f.tempFiles.Store(dafaultXMLPathSharedStrings, "") + assert.Equal(t, "1", f.getFromStringItemMap(1)) + + // Test reload the file error on set cell cell and rich text. The error message was different between macOS and Windows. + err = f.SetCellValue("Sheet1", "A19", "A19") + assert.Error(t, err) + + f.tempFiles.Store(dafaultXMLPathSharedStrings, "") + err = f.SetCellRichText("Sheet1", "A19", []RichTextRun{}) + assert.Error(t, err) + + assert.NoError(t, f.Close()) +} -- cgit v1.2.1