0

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 :)

2
  • Please have a look at this question here. Hope it will be helpful. Commented Jul 29, 2020 at 8:00
  • @AhmerMH no, i see it Commented Jul 29, 2020 at 8:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.