Free Support Forum - aspose.com

Create formulas Desktop.Grid

Hi

I am using Desktop.Grid with VB.Net

I want to place a formula in a cell - eg SUM of part of column.

I know the range of numbers involved in the SUM they are contained in 2 variables relating to the coordinates of the start cell and end cell ie

Start cell is Cell(subLoop + 1, 1)
End cell is Cell(iLoop - 1, 1)

However, I don't know the cell names eg A1 or B2

How do I create a SUM formula in Cell(iLoop) totalling the entries from Start cell to End cell

Regards

Bob Hamill

Hi Bob,

I think you may try GridCell.Name. May the following code helps you for your need.

Dim subLoop, iLoop As Integer
subLoop = 0
iLoop = 4
Dim scell As Aspose.Grid.Desktop.GridCell = GridDesktop1.Worksheets(0).Cells(subLoop + 1, 1)
Dim ecell As Aspose.Grid.Desktop.GridCell = GridDesktop1.Worksheets(0).Cells(iLoop - 1, 1)
Dim startcell As String = scell.Name
Dim endcell As String = ecell.Name
Dim fcell As Aspose.Grid.Desktop.GridCell = GridDesktop1.Worksheets(0).Cells(iLoop, 1)
fcell.Value = "=SUM(" & startcell & ":" & endcell & ")" '.....Formula will be ("=SUM(B2:B4)")

Thank you.

Thanks again Amjad - works a treat!