Add more table demos

This commit is contained in:
Dolan
2018-09-12 21:03:06 +01:00
parent 11ce9a5206
commit f1b176670c
2 changed files with 44 additions and 0 deletions

18
demo/demo28.ts Normal file
View File

@ -0,0 +1,18 @@
// 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, VerticalAlign } from "../build";
const doc = new Document();
const table = doc.createTable(4, 4);
table
.getCell(2, 2)
.addContent(new Paragraph("This text should be in the middle of the cell"))
.CellProperties.setVerticalAlign(VerticalAlign.CENTER);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});