Skip to content

Cells merging#133

Open
rlalik wants to merge 1 commit intop-ranav:masterfrom
rlalik:merge_cells
Open

Cells merging#133
rlalik wants to merge 1 commit intop-ranav:masterfrom
rlalik:merge_cells

Conversation

@rlalik
Copy link
Copy Markdown
Contributor

@rlalik rlalik commented Apr 2, 2026

This is feature I think many have waited long: #65

I needed to rewrite a bit internal structures. I see some room for further optimization but in the separate PR as it is not related to my code.

Code example:

  table.add_row(Row_t{"A", "", "", ""});
  table.add_row(Row_t{"B", Merge{}});
  table.add_row(Row_t{"C", Merge{1}});
  table.add_row(Row_t{"D", Merge{2}});
  table.add_row(Row_t{"", "F", Merge{1}});
  table.add_row(Row_t{"", "G", Merge{2}});

  table[0][0].format().width(5);
  table[0][1].format().width(5);
  table[0][2].format().width(5);
  table[0][3].format().width(5);

  table[1][0].format().font_align(FontAlign::center);
  table[2][0].format().font_align(FontAlign::center);
  table[3][0].format().font_align(FontAlign::center);
  table[4][1].format().font_align(FontAlign::center);
  table[5][1].format().font_align(FontAlign::center);

Result:

+-----+-----+-----+-----+
| A   |     |     |     |
+-----------+-----+-----+
|     B     |     |     |
+-----------+-----+-----+
|     C     |     |     |
+-----------------+-----+
|        D        |     |
+-----+-----------+-----+
|     |     F     |     |
+-----+-----------------+
|     |        G        |
+-----+-----------------+

@rlalik
Copy link
Copy Markdown
Contributor Author

rlalik commented Apr 2, 2026

I am also thinking about another improvement, that instead of:

table.add_row(Row_t{"C", Merge{1}});

one can also write:

table.add_row(Row_t{Merge{"C", 2}});

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant