Is it possible to dynamically add columns to an excel table using exceljs?
I wrote this code:
let workBook = new excel.Workbook();
let workSheet = workBook.addWorksheet('report');
workSheet.getRow(1).values = columns;
which creates columns with the names in the columns
list.
But I don't know how to add key
's to items in this list.
In normal/static usage I create something like this:
workSheet.columns = [
{key: 'id', name: 'id'},
{key: 'firstName', 'firstName'},
{key: 'lastName', name: 'lastName'}
]
to map object from db to these key
's.
And the problem is, I don't know how to make a pair of key-values(name) where my key and values
would be the same as the object in my list - columns
.
Does anybody have an idea/solution? Thanks for any help :)