1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-04 23:30:25 +08:00

fix: empty getAtt

This commit is contained in:
源文雨
2023-02-24 12:19:01 +08:00
parent be9f9e9672
commit 1e5dbea998
5 changed files with 86 additions and 52 deletions

View File

@@ -484,14 +484,22 @@ func (r *WTableCellProperties) UnmarshalXML(d *xml.Decoder, start xml.StartEleme
switch tt.Name.Local {
case "tcW":
r.TableCellWidth = new(WTableCellWidth)
r.TableCellWidth.W, err = strconv.ParseInt(getAtt(tt.Attr, "w"), 10, 64)
v := getAtt(tt.Attr, "w")
if v == "" {
continue
}
r.TableCellWidth.W, err = strconv.ParseInt(v, 10, 64)
if err != nil {
return err
}
r.TableCellWidth.Type = getAtt(tt.Attr, "type")
case "gridSpan":
r.GridSpan = new(WGridSpan)
r.GridSpan.Val, err = strconv.Atoi(getAtt(tt.Attr, "val"))
v := getAtt(tt.Attr, "val")
if v == "" {
continue
}
r.GridSpan.Val, err = strconv.Atoi(v)
if err != nil {
return err
}