Currently, I am working on a project that involves exporting data into multiple xlsx sheets. One of the sheets requires me to add a formula in cells that meet certain conditions before adding data from the first sheet. Here is an example:
Ref !== null ? worksheet2.getCell('D2').value ={ formula: `IF('dataSheet'!${Ref.address}<>"";'dataSheet'!${Ref.address};"")`, result:Ref.value} : worksheet2.getCell('D2').value = '';
In this case, Ref refers to a cell in the first sheet that contains the "ref" label.
The issue with this formula (or any "IF" formula) is that when I open the Excel document, I receive this error message:
We found a problem with some content in test.xlsx. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.
Upon clicking Yes, the document gets recovered but all the IF formulas are lost. VLOOKUP formulas also do not work properly.
Simple formulas like A1+A2 function correctly, but nothing beyond that seems to work. I have tried using common formulas like SUM or AVERAGE, with no success. I even experimented with adding or removing an "=" sign before the formula, but it did not help. An example of a simple formula that failed to work is formula: '=IF(A1=0;10;0)'
.
Furthermore, I attempted to use another package, XLSX, with IF and SUM formulas, but encountered the same issue.
Lastly, since I work for a French company, all the formulas are written in French (e.g., IF is SI). I initially thought there might be a language discrepancy between ExcelJS and Excel options, but even after switching to English, the error message persisted.