You put the string "12345" into the cell which is the only method which will never put a value.
There is method setValue of interface .table.XCell
There is method setFormula(string) of the same interface.
And a single cell has string property FormulaLocal which is the localized formula as shown in the formula bar.
xCell.setValue(1234.56) sets the value directly
xCell.setFormula("1234.56") does effectively the same.
Then there is .sheet.XCellRangeFormula which can write formulas to a whole range. For a single cell it looks like this:
XCellRangeFormula.setFormulaArray( [["1234.56"]] )
and of course XCellRangeData:
XCellRangeData.setDataArray( [[1234.56]] )
OutRange.setPropertyValue("FormulaLocal", "1234.56") does the same but only if the point is the valid decimal separator. Otherwise it will put a string.
What you do by setting the string directly is equivalent to
xCell.setFormula("'1234.56")
XCellRangeFormula.setFormulaArray( [["'1234.56"]] )
OutRange.setPropertyValue("FormulaLocal", "'1234.56")
all formula strings with a leading apostroph
or XCellRangeData.setDataArray( [["1234.56"]] ) [string without apostroph]
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Villeroy wrote:There is method setValue of interface .table.XCell
xCell.setValue(1234.56) sets the value directly
xCell.setFormula("1234.56") does effectively the same.
I can't do it.
Did you a sample code to declare and setting this?
MRI can do that for you. It can record Java with all the type declarations. Changing this to JS is simple. Hint: A text range does not support method setValue
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice