|
| 1 | +import Automizer, { CmToDxa, modify, TableData } from '../src/index'; |
| 2 | + |
| 3 | +test('update row hight/column width in a nested table', async () => { |
| 4 | + const automizer = new Automizer({ |
| 5 | + templateDir: `${__dirname}/pptx-templates`, |
| 6 | + outputDir: `${__dirname}/pptx-output`, |
| 7 | + }); |
| 8 | + |
| 9 | + const pres = automizer |
| 10 | + .loadRoot(`RootTemplate.pptx`) |
| 11 | + .load(`NestedTables.pptx`, 'tables'); |
| 12 | + |
| 13 | + await pres |
| 14 | + .addSlide('tables', 4, async (slide) => { |
| 15 | + const tableData: TableData = { |
| 16 | + body: [ |
| 17 | + { values: ['top left', 123, 345, 'subsub3-1', 'subsub3-2', 'Last'] }, |
| 18 | + { values: [undefined, 't1', 't2', 't3', 't3', ''] }, |
| 19 | + { values: ['label 0', 1, 2, 3, 3, 'l0'] }, |
| 20 | + { values: ['label 1', 123, 345, 4563, 4671, 'l1'] }, |
| 21 | + { values: ['label 2', 123, 345, 4562, 4672] }, |
| 22 | + { values: ['label 3', 123, 345, 4561, 4673, 'l3'] }, |
| 23 | + { values: [undefined, 'Foo', 'ter', 4564, 4674, ''] }, |
| 24 | + ], |
| 25 | + }; |
| 26 | + |
| 27 | + slide.modifyElement('NestedTable3', [ |
| 28 | + modify.setTable(tableData, { |
| 29 | + expand: [ |
| 30 | + { |
| 31 | + mode: 'row', |
| 32 | + tag: '{{each:row}}', |
| 33 | + count: 3, |
| 34 | + }, |
| 35 | + { |
| 36 | + mode: 'column', |
| 37 | + tag: '{{each:subSub3}}', |
| 38 | + count: 1, |
| 39 | + }, |
| 40 | + ], |
| 41 | + }), |
| 42 | + // Update first column width to 8cm |
| 43 | + modify.updateColumnWidth(0, CmToDxa(8)), |
| 44 | + // Update last row's height to 3cm |
| 45 | + modify.updateRowHeight(6, CmToDxa(3)), |
| 46 | + // Will also work on non-nested tables |
| 47 | + ]); |
| 48 | + }) |
| 49 | + .write(`modify-nested-table-grid-size.test.pptx`); |
| 50 | + |
| 51 | + // expect(data.length).toBe(12); |
| 52 | +}); |
0 commit comments