Files
docx-js/demo/demo43.ts

21 lines
554 B
TypeScript
Raw Normal View History

2019-03-04 22:50:04 +00:00
// Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
2019-03-18 23:50:21 +00:00
const table = doc.createTable({
rows: 4,
columns: 4,
});
2019-03-04 22:50:04 +00:00
table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
table.getColumn(3).mergeCells(1, 2);
// table.getCell(3, 2).addParagraph(new Paragraph("Hello"));
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});