Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/serializer/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,27 @@ func (s *TableSerializer) serializeCellProperties(cell domain.TableCell) *xml.Ta
}
}

// Borders (table cell borders)
borders := cell.Borders()
if s.hasTableBorders(borders) {
props.Borders = &xml.TableBorders{
Top: s.paraSerializer.serializeBorder(borders.Top),
Bottom: s.paraSerializer.serializeBorder(borders.Bottom),
Left: s.paraSerializer.serializeBorder(borders.Left),
Right: s.paraSerializer.serializeBorder(borders.Right),
}
}

return props
}

func (s *TableSerializer) hasTableBorders(borders domain.TableBorders) bool {
return borders.Top.Style != domain.BorderNone ||
borders.Bottom.Style != domain.BorderNone ||
borders.Left.Style != domain.BorderNone ||
borders.Right.Style != domain.BorderNone
}

func (s *TableSerializer) widthTypeToString(wType domain.WidthType) string {
switch wType {
case domain.WidthAuto:
Expand Down
9 changes: 9 additions & 0 deletions internal/serializer/serializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ func TestTableSerializer(t *testing.T) {
// Fill first cell
row0, _ := table.Row(0)
cell, _ := row0.Cell(0)
cell.SetBorders(domain.TableBorders{Top: domain.BorderStyle{
Style: domain.BorderSingle,
Width: 4,
Color: domain.ColorRed,
}})
cellPara, _ := cell.AddParagraph()
cellRun, _ := cellPara.AddRun()
cellRun.SetText("Cell 0,0")
Expand Down Expand Up @@ -212,6 +217,10 @@ func TestTableSerializer(t *testing.T) {
if len(firstCell.Content) == 0 {
t.Fatal("expected at least one element in first cell content")
}

if firstCell.Properties.Borders == nil || firstCell.Properties.Borders.Top == nil {
t.Errorf("expected border top to be set")
}
Comment on lines +221 to +223
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test verifies that the border is present but doesn't validate the actual border properties that were set (style, width, color). Consider adding assertions to verify that the border has the expected values: Style should be "single", Width (Sz) should be 4, and Color should be the hex representation of ColorRed.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

firstPara, ok := firstCell.Content[0].(*xmlstructs.Paragraph)
if !ok {
t.Fatalf("expected first content element to be paragraph, got %T", firstCell.Content[0])
Expand Down