Search code examples
javascripttypescriptexceljs

How to sum all values in column?


I'm using exceljs and i must sum all values from my column, how can i do this?

at issue on github, i found one solution, but not work for me:

workSheet.getCell(`B${endRow}`).value = { formula: `SUM(B4:B${endRow-1})` };

because vscode throw me: Type '{ formula: string; }' is not assignable to type 'CellValue'. Type '{ formula: string; }' is missing the following properties from type 'CellSharedFormulaValue': sharedFormula, date1904

can somebody tell me how to sum each values from column?


Solution

  • Ciao, try to modify your code like this:

    workSheet.getCell(`B${endRow}`).value = { formula: `SUM(B4:B${endRow-1})`, date1904: false };