We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description
大佬,我这有一个Excel文件:xml文件.zip, 其中F29和G29单元格,格式为t="s",但是没有value:
-<row spans="1:7" r="29"> <c r="A29" t="s" s="11"/> -<c r="B29" t="s" s="18"> <v>103</v> </c> -<c r="C29" t="s" s="18"> <v>104</v> </c> -<c r="D29" t="s" s="12"> <v>105</v> </c> -<c r="E29" t="s" s="16"> <v>106</v> </c> <c r="F29" t="s" s="16"/> <c r="G29" t="s" s="16"/> </row>
这种异常情况在执行GetCellRichText方法时,
// GetCellRichText provides a function to get rich text of cell by given // worksheet. func (f *File) GetCellRichText(sheet, cell string) (runs []RichTextRun, err error) { ws, err := f.workSheetReader(sheet) if err != nil { return } c, _, _, err := ws.prepareCell(cell) if err != nil { return } if c.T == "inlineStr" && c.IS != nil { runs = getCellRichText(c.IS) return } if c.T == "" { return } siIdx, err := strconv.Atoi(c.V) if err != nil || c.T != "s" { return } sst, err := f.sharedStringsReader() if err != nil { return } if len(sst.SI) <= siIdx || siIdx < 0 { return } runs = getCellRichText(&sst.SI[siIdx]) return }
会由于strconv.Atoi(c.V)传入了空的c.V,导致报错strconv.Atoi: parsing "": invalid syntax 这边建议是在执行strconv.Atoi(c.V)前补充判断 把
strconv.Atoi(c.V)
c.V
strconv.Atoi: parsing "": invalid syntax
if c.T == "" { return } siIdx, err := strconv.Atoi(c.V) if err != nil || c.T != "s" { return }
改为
if c.T != "s" { return } if c.V == "" { return } siIdx, err := strconv.Atoi(c.V) if err != nil { return }
修改完的完整方法如下:
// GetCellRichText provides a function to get rich text of cell by given // worksheet. func (f *File) GetCellRichText(sheet, cell string) (runs []RichTextRun, err error) { ws, err := f.workSheetReader(sheet) if err != nil { return } c, _, _, err := ws.prepareCell(cell) if err != nil { return } if c.T == "inlineStr" && c.IS != nil { runs = getCellRichText(c.IS) return } if c.T != "s" { return } if c.V == "" { return } siIdx, err := strconv.Atoi(c.V) if err != nil { return } sst, err := f.sharedStringsReader() if err != nil { return } if len(sst.SI) <= siIdx || siIdx < 0 { return } runs = getCellRichText(&sst.SI[siIdx]) return }
The text was updated successfully, but these errors were encountered:
bebb802
Successfully merging a pull request may close this issue.
Description
大佬,我这有一个Excel文件:xml文件.zip,
其中F29和G29单元格,格式为t="s",但是没有value:
这种异常情况在执行GetCellRichText方法时,
会由于
strconv.Atoi(c.V)
传入了空的c.V
,导致报错strconv.Atoi: parsing "": invalid syntax
这边建议是在执行
strconv.Atoi(c.V)
前补充判断把
改为
修改完的完整方法如下:
The text was updated successfully, but these errors were encountered: