Skip to content

Commit bcb49d9

Browse files
feat: new support for nested tables in word tables (#51)
Co-authored-by: wangyifan <[email protected]>
1 parent 2be4b0a commit bcb49d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

structtable.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ type WTableCell struct {
536536
XMLName xml.Name `xml:"w:tc,omitempty"`
537537
TableCellProperties *WTableCellProperties
538538
Paragraphs []*Paragraph `xml:"w:p,omitempty"`
539+
Tables []*Table `xml:"w:tbl,omitempty"`
539540

540541
file *Docx
541542
}
@@ -568,6 +569,13 @@ func (c *WTableCell) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error {
568569
return err
569570
}
570571
c.TableCellProperties = &value
572+
case "tbl":
573+
var table Table
574+
table.file = c.file
575+
if err = d.DecodeElement(&table, &tt); err != nil && !strings.HasPrefix(err.Error(), "expected") {
576+
return err
577+
}
578+
c.Tables = append(c.Tables, &table)
571579
default:
572580
err = d.Skip() // skip unsupported tags
573581
if err != nil {

0 commit comments

Comments
 (0)