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.
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).