Free Support Forum - aspose.com

Create Formula problem

I am using Desktop.Grid and VB.Net 2005 Professional.

I have created a grid and added the line -

sheet.Cells(0, 0).Formula = "B1/B2"

I get the following error - Property 'Formula' is 'ReadOnly'.

Can You advise

Regards Bob Hamill

Hi,

Well, GridCell.Formula is indeed a read-only property, it is just used to get the formula of a cell. Please use:

  • GridCell.Value (property).........Gets or sets a cell value. If value is formula, the set method of this property will call GridDesktop.RunAllFormulas method automatic. So, if there are many formulas, using SetCellValue method instead of this property. SetCellValue method will enhance performance.
  • GridCell.SetCellValue() (method).............If the value is a formula,this method set cell's value as FormulaType, but not calculate formula. To calculate formula,need call GridDesktop.RunAllFormulas manually. If multi values to be set,call this method multi times, finally,call GridDesktop.RunAllFormulas method manually to calculate formulas. This is more effective.

Please consult the following example for your need:

Dim cell As GridCell = gridDesktop1.Worksheets(0).Cells(0, 0)
cell.SetCellValue("=B1/B2")
gridDesktop1.RunAllFormulas()