Ziv-Barber / officegen

Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.
MIT License
2.65k stars 471 forks source link

How to insert a link into Node.js officegen table #366

Open eugensunic opened 4 years ago

eugensunic commented 4 years ago

The following code generates a table in officegen, If you provide a raw string to val prop inside the table it generates the text, but how would you provide link?

Tried with creating a paragraph and enhancing it to a link but to no avail.

let pObj = docx.createP();
linkObj = pObj.addText('link', { link: 'http://www.google.com' });

const titleCell = (cellValue) => ({
        val: cellValue,
        opts: {
            cellColWidth: 2500,
            b: true,
            sz: '12',
            fontFamily: 'Times New Roman'
        }
    })

 const table = [
        [titleCell('name'), titleCell(linkObj)],
 ]

See stack-overflow question: https://stackoverflow.com/questions/62522872/how-to-insert-a-link-into-node-js-officegen-table

eugensunic commented 4 years ago

Here is the solution:

https://stackoverflow.com/questions/62522872/how-to-insert-a-link-into-node-js-officegen-table/62656561#62656561