Open 18876293672 opened 4 years ago
Hi, I had a similar problem to group in pptx My solution was modify the source code of officegen:
At genofficetable.js in lib/pptx
_getCell: function(val, options, idx, row_idx) {
...
'a:tc': {
'@gridSpan': options.gridSpan || '1',
'@hMerge': options.hMerge ? options.hMerge : '0',
'@rowSpan': options.rowSpan || '1',
'@vMerge': options.vMerge ? options.vMerge : '0',
...
With this you can add new options to cell:
// Merge Rows
let cell_opts = {font_size: fontSize, font_face: 'Arial', rowSpan=<n>}; // first cell to merge vertically
let cell_opts = {font_size: fontSize, font_face: 'Arial', vMerge="1"}; // next cells
// Merge Columns
let cell_opts = {font_size: fontSize, font_face: 'Arial', gridSpan=<n>}; // first cell to merge horizontally
let cell_opts = {font_size: fontSize, font_face: 'Arial', hMerge="1"}; // next cells
@CristobalBL thank you
for Word table, this is the pr and a small example. #348
as @Rackar wrote pr link, my example based on it
const table = [];
const row1 = [
{val: 'test 1', opts: {vMerge: 'restart'}},
{val: 'test 2'},
{val: 'test 3'},
];
const row2 = [
{opts: {vMerge: 'continue'}},
{val: 'test 5'},
{val: 'test 6'},
];
table.push(row1);
table.push(row2);
docx.createTable(table);
----------------------------
| test 1 | test 2 | test 3 |
| |--------|--------|
| | test 5 | test 6 |
----------------------------
Environment
node -v
: [fill]npm -v
: [fill]npm ls officegen
: [fill]Steps to Reproduce
[fill]
Expected Behavior
[fill]
Actual Behavior
[fill]
An example code will be the best. The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself.