summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2018-03-02 10:19:40 +0800
committerRi Xu <xuri.me@gmail.com>2018-03-02 10:19:40 +0800
commitb1b056e0ebe0f05bae16023bf4972bda226de40c (patch)
treeb7a46e3d2aafda236c47bbbfef68e263624f889c
parent9d7b94d760126aa51485d7d864b1b98a8720017c (diff)
Handle special shared string table file name `xl/SharedStrings.xml`, relate issue #188
-rw-r--r--excelize_test.go9
-rw-r--r--rows.go6
-rwxr-xr-xtest/SharedStrings.xlsxbin0 -> 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")
+}
diff --git a/rows.go b/rows.go
index a6b0738..405717c 100644
--- a/rows.go
+++ b/rows.go
@@ -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
new file mode 100755
index 0000000..7b722d9
--- /dev/null
+++ b/test/SharedStrings.xlsx
Binary files differ