0

I'm using ExcelJs to convert an excel to .csv. Many a columns in the determined based on formulae.

    var workbook = new Excel.Workbook();

    workbook.xlsx.load(results.rows[0].map) //reading from PostGres bytea field
        .then(function () {
            function getMap() {
                return new Promise(resolve => {
                    workbook.csv
                    .writeFile(__dirname+ '/./uploads/'+results.rows[0].name+'.csv')
                    .then(function () {
                        resolve('done');
                    })

                })
            }
        }

The .csv file thus generated ignores the formula columns. The cells just come in empty.

When I convert the same excel in Microsoft Excel to .csv, all the formulae are respected and the row contains the real values determined by the formulae.

How do I achieve the same behavior via ExcelJS?

lonelymo
  • 3,972
  • 6
  • 28
  • 36

1 Answers1

0

I finally figured this out. The formulae are converted to real data in the MS Excel application. There's no way for either exceljs or any other npm to do this automatically.

That said, there's a solution. A cumbersome one though. You will have to sift through all the formulae, explicitly do the conversion and write it back to the fields. https://gist.github.com/davidhq/0afed70985842cac6fc4e00f88a71bd2

lonelymo
  • 3,972
  • 6
  • 28
  • 36