Skip to content

Commit b1b056e

Browse files
committed
Handle special shared string table file name xl/SharedStrings.xml, relate issue qax-os#188
1 parent 9d7b94d commit b1b056e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Diff for: excelize_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -1009,3 +1009,12 @@ func TestTitleToNumber(t *testing.T) {
10091009
t.Error("Conver title to number failed")
10101010
}
10111011
}
1012+
1013+
func TestSharedStrings(t *testing.T) {
1014+
xlsx, err := OpenFile("./test/SharedStrings.xlsx")
1015+
if err != nil {
1016+
fmt.Println(err)
1017+
return
1018+
}
1019+
xlsx.GetRows("Sheet1")
1020+
}

Diff for: rows.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ func (f *File) GetRowHeight(sheet string, row int) float64 {
149149
func (f *File) sharedStringsReader() *xlsxSST {
150150
if f.SharedStrings == nil {
151151
var sharedStrings xlsxSST
152-
xml.Unmarshal([]byte(f.readXML("xl/sharedStrings.xml")), &sharedStrings)
152+
ss := f.readXML("xl/sharedStrings.xml")
153+
if ss == "" {
154+
ss = f.readXML("xl/SharedStrings.xml")
155+
}
156+
xml.Unmarshal([]byte(ss), &sharedStrings)
153157
f.SharedStrings = &sharedStrings
154158
}
155159
return f.SharedStrings

Diff for: test/SharedStrings.xlsx

6.31 KB
Binary file not shown.

0 commit comments

Comments
 (0)