json-as-xlsx icon indicating copy to clipboard operation
json-as-xlsx copied to clipboard

Using functions such as SUM

Open AviFix opened this issue 2 years ago • 2 comments

Hi

Thanks for the great project

Is there any way to use functions such as SUM?

If i use this =SUM(C2:C6) as a value it only shows as a string

Thanks

AviFix avatar Sep 01 '22 09:09 AviFix

Hello,

It's not currently supported, but probably you can get something working by modifying the workbook using a callback

The callback is called just before writing the file

https://github.com/LuisEnMarroquin/json-as-xlsx/blob/6fe347612f8e3036bcf30aa2a8f019de41e216f6/src/index.ts#L146-L158

So you would need to do something similar to the 'format' code, but instead of writing to 'z', you would need to write to 'f'

https://github.com/LuisEnMarroquin/json-as-xlsx/blob/6fe347612f8e3036bcf30aa2a8f019de41e216f6/src/index.ts#L35-L56

Here is an example from SheetJs

https://github.com/SheetJS/sheetjs/issues/1123#issuecomment-392563798

elyse0 avatar Sep 25 '22 07:09 elyse0

As @elyse0 pointed same result can be archieved by processing with JS before writting the file

LuisEnMarroquin avatar Sep 29 '22 15:09 LuisEnMarroquin