Getting integer value from spreadsheet as Variable
Mon, 23 May 2016 - 11:34 AM
Hi there,
I am trying to get an integer value from Cell(4, 14) this is currently 422 on my spreadsheet, I can get it out as a text, but if I format it on the sheet to a number, all I can get out of this cell is 0. Here is the code I am using, the first one is for text with that cell formatted to text, the second one is for (What I was hoping would be) an Integer:
Dim j As String
oSheet = ThisComponent.CurrentSelection.Spreadsheet
j = oSheet.getCellByPosition(4, 14).Text msgbox j p.
Here the answer I get is 422
Dim j As Integer
oSheet = ThisComponent.CurrentSelection.Spreadsheet
j = oSheet.getCellByPosition(4, 14).Value msgbox j p.
Here the same Cell with the same value (but now formatted to number) give 0.
How do you solve this?
Mon, 23 May 2016 - 11:36 AM
#1
And how do you do a code
And how do you do a code block in this forum, I can’t get that to work either
Tue, 24 May 2016 - 2:21 AM
#2
The value of a cell (when the
When the content of the cell is a String (Text), the value of the cell equals zero.
You can ecamine the type of the cell content by some API functions:
Dim oDoc As Object Dim oSheet As Object Dim oCell As Object
oDoc = ThisComponent oSheet = oDoc.getcurrentcontroller.activesheet oCell = oSheet.getCellByPosition(4,14)
Select Case oCell.Type Case com.sun.star.table.CellContentType.EMPTY MsgBox "Content: Empty" Case com.sun.star.table.CellContentType.VALUE MsgBox "Content: Value" Case com.sun.star.table.CellContentType.TEXT MsgBox "Content: Text" Case com.sun.star.table.CellContentType.FORMULA MsgBox "Content: Formula" End Select
Mon, 23 May 2016 - 11:24 PM
#3
Thank you, this is incredibly
Thank you, this is incredibly useful!