浏览代码

fix reading wrong string from xml such as below
<sheetData><row r="1"><c r="A1" s="1" t="s"><v>0</v></c><c r="B1" s="1" t="s"></c></row></sheetData>

foxmeder 5 年之前
父节点
当前提交
59f6af21a3
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      rows.go

+ 6 - 4
rows.go

@@ -301,10 +301,12 @@ func (f *File) sharedStringsReader() *xlsxSST {
 func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) {
 	switch xlsx.T {
 	case "s":
-		xlsxSI := 0
-		xlsxSI, _ = strconv.Atoi(xlsx.V)
-		if len(d.SI) > xlsxSI {
-			return f.formattedValue(xlsx.S, d.SI[xlsxSI].String()), nil
+		if xlsx.V != "" {
+			xlsxSI := 0
+			xlsxSI, _ = strconv.Atoi(xlsx.V)
+			if len(d.SI) > xlsxSI {
+				return f.formattedValue(xlsx.S, d.SI[xlsxSI].String()), nil
+			}
 		}
 		return f.formattedValue(xlsx.S, xlsx.V), nil
 	case "str":