| View previous topic :: View next topic |
| Author |
Message |
makrandmane Newbie

Joined: 22 Apr 2008 Posts: 2
|
Posted: Tue Apr 29, 2008 12:03 am Post subject: How to get cell Range from selected area |
|
|
Hello
I am developing new Extension for open office Cal(Spreadsheet)
For that I am using Net Beans 5.5 , JDK 6.0 OpenOffice 3.0
I want to get cell rage of selected area
Scenario
If I open a new spreadsheet and select some Cell by using Mouse then I want cell Range Address for selected cells so I can access data from cell
Please tell me how to get cell Range from selected area
Thanks |
|
| Back to top |
|
 |
radhika_24 General User

Joined: 10 Nov 2008 Posts: 19
|
Posted: Thu Nov 20, 2008 3:23 am Post subject: |
|
|
Please Please can anyone help me!!!
i want to access the cells that have been currently selected by the user and then put the data in the cell adjacent to the selected cells...
I m totally lost ... last time i had a got a very prompt response from here
hope to the same soon !!! thanks a ton !!
Radhika |
|
| Back to top |
|
 |
vitcaro OOo Advocate


Joined: 20 Feb 2007 Posts: 256 Location: Italy
|
Posted: Thu Nov 20, 2008 6:53 am Post subject: |
|
|
This example is Basic: | Code: |
CellRange = oDocument.getCurrentSelection()
RangeAddress = CellRange.getRangeAddress
|
|
|
| Back to top |
|
 |
radhika_24 General User

Joined: 10 Nov 2008 Posts: 19
|
Posted: Thu Nov 20, 2008 11:43 pm Post subject: |
|
|
Thanks for that really..!
But When i print the value of RangeAddress - it says Basic Runtime error.
And can you tell me what could be the format of RangeAddress, i assume its in vector form as in 2,3 or something.
Thanks for the help
Radhika |
|
| Back to top |
|
 |
vitcaro OOo Advocate


Joined: 20 Feb 2007 Posts: 256 Location: Italy
|
Posted: Fri Nov 21, 2008 12:48 am Post subject: |
|
|
Example of use of CellRangeAddress: | Code: |
c1 = RangeAddr.StartColumn
r1 = RangeAddr.StartRow
c2 = RangeAddr.EndColumn
r2 = RangeAddr.EndRow
sh = RangeAddr.Sheet
|
|
|
| Back to top |
|
 |
radhika_24 General User

Joined: 10 Nov 2008 Posts: 19
|
Posted: Mon Nov 24, 2008 4:39 am Post subject: |
|
|
hey guys thanks a lot for the help!!!
i have compiled the code together and now if anyone needs to access the cells dynacmically according to the user's selection, can readily use this code
Sub Main
Dim oDocument As Object, oSheet As Object, oCell As Object, bCell As Object
oDocument=ThisComponent
Dim oSelection as Object
Dim oRange as Object
Dim r,c as integer
Dim oRangeAddress as New com.sun.star.table.CellRangeAddress
oDocument = StarDesktop.ActiveFrame.Controller.Model
oSheet = oDocument.CurrentController.getActiveSheet() ' get actual sheet
oSelection = oDocument.CurrentController.getSelection
oRangeAddress = oSelection.getRangeAddress ' get actual range / obtiene el rango actual
r = oRangeAddress.StartRow 'current row / la fila actual
c = oRangeAddress.StartColumn 'current column / la columna actual
oCell=oSheet.getCellByPosition(c,r)
End Sub
Enjoy,
Radhika  |
|
| Back to top |
|
 |
|