sCellName = object.getCellByPosition().AbsoluteName
sCellRangeName = object.getCellRangeByPosition().AbsoluteName
AbsoluteName property is presented in Calc A1
formula syntax (grammar).
But if you are working with row and column indices, then you may find it more convenient to put together the formula using the Excel R1C1
syntax. Then don’t forget to add 1 to the indices. Using the SetFormulaR1C1() function, you can assign an R1C1 formula to a cell, but it will be displayed correctly, depending on the selected formula syntax option.
Excel R1C1
: R means row, C means column
C2
- absolute reference to column B
RC[-1]
refers to the column to the left of the formula cell in the current row (R
without index).
sFormulaR1C1 = "=RC2+RC[-1]" 'where 2 is one of your indices increased by 1
Call SetFormulaR1C1(sFormulaR1C1, oCell)
Sub SetFormulaR1C1(sFormulaR1C1$, oCell As Object)
Dim oParser As Object
oParser = ThisComponent.CreateInstance("com.sun.star.sheet.FormulaParser")
oParser.FormulaConvention = com.sun.star.sheet.AddressConvention.XL_R1C1
oCell.Tokens = oParser.parseFormula(sFormulaR1C1, oCell.CellAddress)
End Sub
Yes, yes, thanks to @Lupp and the one who helped him with this technique (@librebel)…
Updated