3

I'm trying to add the values of two adjacent columns using SheetJS. The resulting sheet needs to contain the formula.

From an Excel perspective

  • A1 = B1 + C1
  • A2 = B2 + C2
  • A3 = B3 + C3
  • ... and so on

I get the desired result using the approach below:

const range = { s: { c: 0, r: 0 }, e: { c: 10, r: 50 } };

for (let i = 0; i < 50; i++) {
    wSheet[`A${i}`] = { f: `B${i} + C${i}`};
}

wSheet['!ref'] = xlsx.utils.encode_range(range);

However, is there a more elegant way of doing so by defining a formula column range and thereby avoiding a loop? Maybe I'm not looking at the documentation correctly https://github.com/SheetJS/sheetjs#cell-object.

Thanks in advance

Fisk
  • 227
  • 1
  • 12
  • 1
    Check this bit of the doco: https://github.com/SheetJS/sheetjs#formulae re decompression of shared formulae. This implies the answer to your question is 'no'. – Robin Mackenzie Jun 01 '21 at 11:00

0 Answers0