Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

DOCX Demo 4

node v10.24.1
version: 6.0.0
endpointsharetweet
const docx = require('docx@6.0.1'); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const { Document, Packer, Paragraph, Table, TableCell, TableRow } = docx; app.get("/", async (req, res) => { const table = new Table({ 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")], }), ], }), ], }); const doc = new Document({ sections: [{ children: [table], }], }); const b64string = await Packer.toBase64String(doc); res.setHeader('Content-Disposition', 'attachment; filename=My Document.docx'); res.send(Buffer.from(b64string, 'base64')); });
Loading…

1 comment

  • posted 3 years ago by jdslkf
    dklsdjf

sign in to comment