Improve API

This commit is contained in:
Dolan
2018-10-15 21:54:33 +01:00
parent a9167b4809
commit 9f0b2f7074
2 changed files with 23 additions and 30 deletions

View File

@ -5,33 +5,29 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc
.createTable(2, 2)
.getCell(0, 0)
.addContent(new Paragraph("Hello"))
.setHorizontalSpan(2);
let table = doc.createTable(2, 2);
table.getCell(0, 0).addContent(new Paragraph("Hello"));
table.getRow(0).mergeCells(0, 1);
doc.createParagraph("Another table").heading2();
doc
.createTable(2, 3)
.getCell(0, 0)
.addContent(new Paragraph("World"))
.setHorizontalSpan(3);
table = doc.createTable(2, 3);
table.getCell(0, 0).addContent(new Paragraph("World"));
table.getRow(0).mergeCells(0, 2);
doc.createParagraph("Another table").heading2();
const table = doc.createTable(2, 4);
table
.getCell(0, 0)
.addContent(new Paragraph("Foo"))
.setHorizontalSpan(4);
table = doc.createTable(2, 4);
table.getCell(0, 0).addContent(new Paragraph("Foo"));
table.getCell(1, 0).addContent(new Paragraph("Bar1"));
table.getCell(1, 1).addContent(new Paragraph("Bar2"));
table.getCell(1, 2).addContent(new Paragraph("Bar3"));
table.getCell(1, 3).addContent(new Paragraph("Bar4"));
table.getRow(0).mergeCells(0, 3);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {