From bcb49d9c62540394689396f79b2c18e78d3f2af6 Mon Sep 17 00:00:00 2001 From: Wang YiFam <33279693+HDmonsterShen@users.noreply.github.com> Date: Wed, 23 Apr 2025 17:12:13 +0800 Subject: [PATCH] feat: new support for nested tables in word tables (#51) Co-authored-by: wangyifan <348544801@qq.com> --- structtable.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/structtable.go b/structtable.go index 5a2727c..055d965 100644 --- a/structtable.go +++ b/structtable.go @@ -536,6 +536,7 @@ type WTableCell struct { XMLName xml.Name `xml:"w:tc,omitempty"` TableCellProperties *WTableCellProperties Paragraphs []*Paragraph `xml:"w:p,omitempty"` + Tables []*Table `xml:"w:tbl,omitempty"` file *Docx } @@ -568,6 +569,13 @@ func (c *WTableCell) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error { return err } c.TableCellProperties = &value + case "tbl": + var table Table + table.file = c.file + if err = d.DecodeElement(&table, &tt); err != nil && !strings.HasPrefix(err.Error(), "expected") { + return err + } + c.Tables = append(c.Tables, &table) default: err = d.Skip() // skip unsupported tags if err != nil {