Docx: Table cell merging

Created on 26 Aug 2018  路  8Comments  路  Source: dolanmiu/docx

I see that you can merge vertical cells but no mention of horizontal cell merging. Is there any possible way to add this feature? Or does anyone know al of a workaround.

I'm trying to create a 4x2 table and want the first row to be one cell (going to use it as a header) like this:

[-----]
[-] [-]
[-] [-]
[-] [-]

I have tried to delete the first cell (0,0) but then it just looks as follows:

[-]
[-] [-]
[-] [-]
[-] [-]

Maybe I'm in the right track, maybe one can change the cell width of row one to match the width of the rest of the table... But yeah, ideally a horizontal merge would be perfect.

Can anyone point me in the right direction? Or maybe have a suggestion?

feature request

All 8 comments

This is not a feature yet

I will add as a todo :)

@dolanmiu thank you so much for the quick positive reply. I found a workaround for the meantime!

const table = new docx.Table(4, 2);
table.getCell(0, 1).delete();
table.getCell(0, 0).CellProperties.addGridSpan(2);

This API is so awesome!!!

Thank you so much, clean code and clean API is the focus of this library

Good going!

I will make it more intuitive in the future like:

const table = new docx.Table(4, 2);
table.getCell(0, 1).setGridSpan(2);

@soutieslak, Thank you for the workaround!! worked like a charm! @dolanmiu, thank you for this awesome API. I am spending a lot of time with it these days :)

The next update will add a method which means no workaround will be needed!

Thanks all 鉂わ笍

on a semi-related note, I am getting a cellSpan issue that may be a bug, I'll post the issue asap, my work is becoming increasingly reliant on this dope package, so I need to get to the bottom of what is happening.

Here is the PR related to the issue:

https://github.com/dolanmiu/docx/pull/149

Awesome thanks so much!!

Was this page helpful?
0 / 5 - 0 ratings