Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub CellAddress
- Dim oConv
- Dim oCell
- Dim oDoc
- Dim oCellAddr As New com.sun.star.table.CellAddress
- oDoc=ThisComponent
- oConv = oDoc.createInstance("com.sun.star.table.CellAddressConversion")
- oCell = ThisComponent.Sheets(0).getCellByPosition(2, 4)
- oConv.Address = oCell.getCellAddress()
- Print oConv.UserInterfaceRepresentation
- print oConv.PersistentRepresentation
- oCellAddr= oCell.getCellAddress()
- print oCellAddr.Sheet
- print oCellAddr.Column
- print oCellAddr.Row
- End Sub
- Rem ---------------------------------------------
- Sub CellType
- Dim CellType as String
- dim oCell
- oCell = ThisComponent.Sheets(0).getCellByPosition(0, 0) 'Cell A1
- Select Case oCell.getType()
- Case com.sun.star.table.CellContentType.EMPTY
- CellType = "Empty"
- Case com.sun.star.table.CellContentType.VALUE
- CellType = "Value"
- Case com.sun.star.table.CellContentType.TEXT
- CellType = "Text"
- Case com.sun.star.table.CellContentType.FORMULA
- CellType = "Formula"
- Case Else
- CellType = "Unknown"
- End Select
- msgbox CellType
- End sub
- Rem ---------------------------------------------
- Function GetCellType(oCell) As String
- Select Case oCell.getType()
- Case com.sun.star.table.CellContentType.EMPTY
- GetCellType = "Empty"
- Case com.sun.star.table.CellContentType.VALUE
- GetCellType = "Value"
- Case com.sun.star.table.CellContentType.TEXT
- GetCellType = "Text"
- Case com.sun.star.table.CellContentType.FORMULA
- GetCellType = "Formula"
- Case Else
- GetCellType = "Unknown"
- End Select
- End Function
- Rem ---------------------------------------------
- Function SimpleCellInfo(oCell) As String
- SimpleCellInfo = oCell.AbsoluteName & " has type " &_
- GetCellType(oCell) & " String(" & oCell.getString() & ") Value(" &_
- oCell.getValue() & ") Formula(" & oCell.getFormula() & ")"
- End Function
- Rem ---------------------------------------------
- Sub Ex1
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(0, 0)
- oCell.setString("Andy")
- s = SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex2
- Dim oCell
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(1, 0)
- s = SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- end sub
- Rem ---------------------------------------------
- Sub Ex3
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(1, 0)
- oCell.setValue(23.2)
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex4
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(2, 0)
- oCell.setString("4")
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex5
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(3, 0)
- oCell.setFormula("=B1")
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex6
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(3, 0)
- oCell.setFormula("")
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex7
- Dim oCell
- Dim s As String
- Dim oDoc
- oDoc = ThisComponent
- oCell = oDoc.Sheets(0).getCellByPosition(0,1)
- oCell.setFormula("=A1+A2+A3")
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
- Rem ---------------------------------------------
- Sub Ex8
- Dim oCell
- Dim s As String
- Dim oDoc
- Dim oSheet
- oDoc = ThisComponent
- oSheet=oDoc.Sheets(0)
- oCell = oDoc.Sheets(0).getCellByPosition(0,1)
- oCell.setValue(oSHeet.getCellByPosition(0,0).getValue()+_
- oSheet.getCellByPosition(1,0).getValue()+_
- oSheet.getCellByPosition(2,0).getValue())
- s = s & SimpleCellInfo(oCell) & CHR$(10)
- MsgBox s, 0, "Cell Values And Types"
- End Sub
Add Comment
Please, Sign In to add comment