diff options
author | Ri Xu <xuri.me@gmail.com> | 2018-03-02 10:19:40 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2018-03-02 10:19:40 +0800 |
commit | b1b056e0ebe0f05bae16023bf4972bda226de40c (patch) | |
tree | b7a46e3d2aafda236c47bbbfef68e263624f889c | |
parent | 9d7b94d760126aa51485d7d864b1b98a8720017c (diff) |
Handle special shared string table file name `xl/SharedStrings.xml`, relate issue #188
-rw-r--r-- | excelize_test.go | 9 | ||||
-rw-r--r-- | rows.go | 6 | ||||
-rwxr-xr-x | test/SharedStrings.xlsx | bin | 0 -> 6462 bytes |
3 files changed, 14 insertions, 1 deletions
diff --git a/excelize_test.go b/excelize_test.go index ca705e5..0d0fdf1 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -1009,3 +1009,12 @@ func TestTitleToNumber(t *testing.T) { t.Error("Conver title to number failed") } } + +func TestSharedStrings(t *testing.T) { + xlsx, err := OpenFile("./test/SharedStrings.xlsx") + if err != nil { + fmt.Println(err) + return + } + xlsx.GetRows("Sheet1") +} @@ -149,7 +149,11 @@ func (f *File) GetRowHeight(sheet string, row int) float64 { func (f *File) sharedStringsReader() *xlsxSST { if f.SharedStrings == nil { var sharedStrings xlsxSST - xml.Unmarshal([]byte(f.readXML("xl/sharedStrings.xml")), &sharedStrings) + ss := f.readXML("xl/sharedStrings.xml") + if ss == "" { + ss = f.readXML("xl/SharedStrings.xml") + } + xml.Unmarshal([]byte(ss), &sharedStrings) f.SharedStrings = &sharedStrings } return f.SharedStrings diff --git a/test/SharedStrings.xlsx b/test/SharedStrings.xlsx Binary files differnew file mode 100755 index 0000000..7b722d9 --- /dev/null +++ b/test/SharedStrings.xlsx |