From b1b056e0ebe0f05bae16023bf4972bda226de40c Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Fri, 2 Mar 2018 10:19:40 +0800 Subject: [PATCH] Handle special shared string table file name `xl/SharedStrings.xml`, relate issue #188 --- excelize_test.go | 9 +++++++++ rows.go | 6 +++++- test/SharedStrings.xlsx | Bin 0 -> 6462 bytes 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 test/SharedStrings.xlsx 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 0000000000000000000000000000000000000000..7b722d9ee4733d24d5b9956ec0b517570c501560 GIT binary patch literal 6462 zcmbtZ2{@E(_aDZVb+Ru-7;Cc2l4vB^_mMqhA7kuG)(DYZ$WDkiW#2_e_K__Klbw)V zyw<)^ubR~Vdav*M&viZS8PA#DIrs0J=bZbTQC9-uPyzq|0`$cUSi0LEr-lUpMB@Me z6zKmLTu0cuSlGMV*7kI;a5m!gfZM&$R#JV<4??jzhO`?DR$JTy*^c05uxURz*Ek&4 z`s|KD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