Currency format can't be used in formula #3038

Closed
opened 2023-11-29 07:58:01 +00:00 by Martin-Hogge · 1 comment

Hi,

I try to export a sheet with currency formatted cells. Based on https://github.com/SheetJS/sheetjs/issues/242#issuecomment-301882390 I set my currency format like this: ws[cellName].z = '#,##0.00\\ "€"';

But their is something weird: cells are being recognized as a currency and can be summed by using the '+' operator but they cannot be summed by using the SUM() excel function (called SOMME() in my example because it's in french).

image
image

Cells are recognized as currency:
image

Can someone explain me why and what should I do for being able to use formula with my currency formatted cells ?
Thank you.

Hi, I try to export a sheet with currency formatted cells. Based on https://github.com/SheetJS/sheetjs/issues/242#issuecomment-301882390 I set my currency format like this: `ws[cellName].z = '#,##0.00\\ "€"';` But their is something weird: cells are being recognized as a currency and can be summed by using the '+' operator but they cannot be summed by using the `SUM()` excel function (called `SOMME()` in my example because it's in french). ![image](/attachments/5458a112-b02c-4929-8cad-4a5f24593a29) ![image](/attachments/163d4188-b174-44b7-a2d0-2923d36d5e79) Cells are recognized as currency: ![image](/attachments/58f7a7b3-23bc-4a0e-8cdd-17b3581545d0) Can someone explain me why and what should I do for being able to use formula with my currency formatted cells ? Thank you.
Owner

You stumbled upon a quirk in Excel.

Based on the screenshots, cells A2 and A3 are text. Check your starting point and ensure you are generating numeric cells.

For example, if you are using aoa_to_sheet, the string "12" will be translated to a text cell while the number 34 will be a numeric cell:

var ws = XLSX.utils.aoa_to_sheet([
  ["12", "<-- this cell will be text"],
  [34, "<-- this cell will be numeric"]
]);

If you'd like a more detailed explanation of Excel's inconsistent behavior, feel free to ask in the chat

You stumbled upon a quirk in Excel. Based on the screenshots, cells A2 and A3 are text. Check your starting point and ensure you are generating numeric cells. For example, if you are using `aoa_to_sheet`, the string `"12"` will be translated to a text cell while the number `34` will be a numeric cell: ```js var ws = XLSX.utils.aoa_to_sheet([ ["12", "<-- this cell will be text"], [34, "<-- this cell will be numeric"] ]); ``` If you'd like a more detailed explanation of Excel's inconsistent behavior, feel free to ask [in the chat](https://sheetjs.com/chat)
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3038
No description provided.