Issue in Cell.Formula function

I am encountering an issue after upgrading Aspose.Cells from version 17.12 to 25.5 .
When executing the following line of code:

cell.Formula = “Paid in C”;

the application throws the error below in version 25.5:

Aspose.Cells.CellsException:“Invalid text (cell reference) for the defined name. (Based on cell Report!G20)”

The same line of code was working correctly in Aspose.Cells 17.12 without any exceptions.

I have attached:
Paid_in_C.zip (3.7 MB)
Input excel file.zip (12.4 KB)

  • A sample project to reproduce the issue
  • The input Excel file

@Rit3sh

You reported an issue with the Cell.Formula property in Aspose.Cells version 25.5, where setting cell.Formula = "Paid in C"; throws a CellsException stating “Invalid text (cell reference) for the defined name. (Based on cell Report!G20)” . This worked fine in version 17.12.

This could be due to stricter validation or changes in how formula strings are processed in newer versions . There is also a related forum discussion about changes in how single quotes are handled in sheet names within formulas , which might reflect broader updates in formula parsing logic between versions.

As a potential workaround, try wrapping your formula in single quotes like this: cell.Formula = "'Paid in C'"; . If that does not resolve the issue, a minimal reproducible example would help investigate further.

A support engineer will follow up in this thread if needed.

@Rit3sh
“Paid in C" is not a valid formula. Even if it’s parsed successfully, 3 invalid defined names will be inserted into the file, the result of the formula is “#Name!”.
Do you need to enter a string value? Please use Cell.PutValue() method.
Please confirm wether you really need to enter “Paid in C" as a formula.

@Rit3sh,

Also, if you would still like to proceed and insert your desired string as a formula, you might consider trying this approach.:
cell.Formula = "=\"Paid in C\"";

I have tested using the above formula (string) and it works fine and It does insert the formula as ="Paid in C" into the G20 cell in the worksheet fine when viewing the output file in MS Excel manually (after re-saving/generating the Excel file via Aspose.Cells).