Cells[#- #].Formula = multiplication not supported?

Hi I am trying to put a formula (that contains multiplication) into a cell, but the cell comes up blank whenever I use the * symbol.

The following line works fine:
cells[currentRow, 8].Formula = ("=K114+J114");
The cell winds up being populated with =K114+J114

The following line results in the cell not being populated
cells[currentRow, 8].Formula = ("=K114+J1142");

I have the same problem when I add a “)” inside a formula string. Does aspose’s formulas not support symbols like '
’ and ‘(’ or is this a bug?

It failed under version 1.0.1152 and 1.5.2.

Much appreciated,

Glenn

Dear Glenn,

Thanks for your consideration.

Currently Aspose.Excel only supports simple formulas, such as “=A1+B1”, “=A1*2”.

To solve your problem, you can use the following code:

[C#]
cells[“A1”].Formula = “=K114 * 2”;
cells[“A1”].IsFormulaVisible = false; //The formula in A1 is transitional, set it to invisible
cells[“L114”].Formula = “=J114 + A1”;

[Visual basic]
cells(“A1”).Formula = "=K114 * 2"
cells(“A1”).IsFormulaVisible = False 'The formula in A1 is transitional, set it to invisible
cells(“L114”).Formula = "=J114 + A1"

We will support complex formulas soon thanks for your patience.

@ihs,
We recommend you to try the following sample code for working with formulas:

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();

// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];

// Adding a value to "A1" cell
worksheet.Cells["A1"].PutValue(1);

// Adding a value to "A2" cell
worksheet.Cells["A2"].PutValue(2);

// Adding a value to "A3" cell
worksheet.Cells["A3"].PutValue(3);

// Adding a SUM formula to "A4" cell
worksheet.Cells["A4"].Formula = "=SUM(A1:A3)";

// Calculating the results of formulas
workbook.CalculateFormula();

// Get the calculated value of the cell
string value = worksheet.Cells["A4"].Value.ToString();

// Saving the Excel file
workbook.Save(dataDir + "output.xls");

For more details have a look at the following article:
Using Formulas or Functions to Process Data
Supported Formula Functions

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.