summaryrefslogtreecommitdiff
path: root/cell_test.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 /cell_test.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 'cell_test.go')
-rw-r--r--cell_test.go17
1 files changed, 17 insertions, 0 deletions
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())
+}