Declarative tables

This commit is contained in:
Dolan
2019-09-13 00:51:20 +01:00
parent 59fc1ed632
commit 418adca9f3
21 changed files with 978 additions and 536 deletions

View File

@ -1,17 +1,35 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const table = new Table({
rows: 4,
columns: 4,
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Hello")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("World")],
}),
],
}),
],
});
table.getCell(2, 2).add(new Paragraph("Hello"));
doc.addSection({
children: [table],
});