UNP API

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

UNP API

k.misha
Hi!

How can I select a sheet in calc document?

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: UNP API

Andrew Pitonyak
I think I demonstrate this in AndrewMacro.odt, but am unable to verify at this time. Utilities were accidentally cut outside my house yesterday.

"k.misha" <[hidden email]> wrote:

>Hi!
>
>How can I select a sheet in calc document?
>
>Thanks!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: UNP API

Shukla, Mangesh
Hi ,
   You can use the following Api's in C++. This is some prototype code, I implemented for my project.

Thanks
Mangesh



    // This API sets the active Spreadsheet in the Calc document
    int Calc::SetActiveWorksheet(Reference<XSpreadsheet> rSheet)
    {
        ////create xSheetDocument
        Reference<XSpreadsheetDocument> xSheetDocument (rComponent,UNO_QUERY);
     
        Reference< XModel > xSpreadsheetModel (xSheetDocument, UNO_QUERY);

        // then get the current controller from the model
        Reference< XController > xSpreadsheetController = xSpreadsheetModel->getCurrentController();
 
        // get the XSpreadsheetView interface from the controller, we want to call its method
        // setActiveSheet
        Reference< XSpreadsheetView > xSpreadsheetView (xSpreadsheetController, UNO_QUERY);
 
        // make our newly inserted sheet the active sheet using setActiveSheet
        xSpreadsheetView->setActiveSheet(rSheet);
               
        return 0;
    }

    // Sets the active sheet to the index provided
    // Sheet number starts with 0,1 .Therefore index 1 indicates second sheet.
    int Calc::SetSheetNumber(int index)  
    {
        //create xSheetDocument
        Reference<XSpreadsheetDocument> xSheetDocument (rComponent,UNO_QUERY);

        //create an instance of XSpreadsheets, which is a worksheets collection
        Reference<XSpreadsheets> xSheets = xSheetDocument->getSheets();

        //create a class to interact with single worksheets;

        //the single worksheets are referenced by an XIndexAccess interface
        Reference<XIndexAccess> xIndex (xSheets,UNO_QUERY);

        //take the first worksheet (index=0)...
        Any any=xIndex->getByIndex(index -1);
       
        // create an instance of Xspreadsheet, able to manage
        //single worksheets;
        Reference<XSpreadsheet> xSheet;

        //finally, assign the first worksheet to xSheet
        any >>= xSheet;
       
        // Set the sheet as active sheet
        SetActiveWorksheet(xSheet);

        return 0;
    }



-----Original Message-----
From: Andrew Pitonyak [mailto:[hidden email]]
Sent: Wednesday, April 10, 2013 5:54 PM
To: [hidden email]
Subject: Re: UNP API

I think I demonstrate this in AndrewMacro.odt, but am unable to verify at this time. Utilities were accidentally cut outside my house yesterday.

"k.misha" <[hidden email]> wrote:

>Hi!
>
>How can I select a sheet in calc document?
>
>Thanks!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: UNP API

JOE Conner-2
In reply to this post by k.misha
On 04/10/2013 03:34 AM, k.misha wrote:
> Hi!
>
> How can I select a sheet in calc document?
>
> Thanks!
>
>
Just click on the tab at the bottom.

-- Joe Conner, Poulsbo, WA USA

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: UNP API

k.misha
Very funny, Joe =)<неи<неи<неи-----Original Message-----<неиFrom: JOE CONNER
[mailto:[hidden email]] <неиSent: Wednesday, April 10, 2013 8:16
PM<неиTo: [hidden email]<неиSubject: Re: UNP API<неи<неиOn
04/10/2013 03:34 AM, k.misha wrote:<неи> Hi!<неи><неи> How can I select a
sheet in calc document?<неи><неи> Thanks!<неи><неи><неиJust click on the tab
at the bottom.<неи<неи-- Joe Conner, Poulsbo, WA
USA<неи<неи-----------------------------------------------------------------
----<неиTo unsubscribe, e-mail: [hidden email]<неиFor
additional commands, e-mail: [hidden email]<неи<неи


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: UNP API

Bernard Marcelly
In reply to this post by k.misha
Message de k.misha  date 2013-04-10 12:34 :
>
> How can I select a sheet in calc document?
>

You probably mean : display a particular sheet of a spreadsheet document.
The currently displayed sheet is called the Active Sheet.
You have to set it with the desired sheet object as argument.

REM -- With OpenOffice Basic easy coding ! ---
Dim myDoc As Object, mySheet As Object
myDoc = ThisComponent
mySheet =  myDoc.Sheets.getByName("October")
myDoc.CurrentController.ActiveSheet = mySheet


With Java or C++ you will have to query and use the methods:

Method        from  interface
.getSheets()  com.sun.star.sheet.XSpreadsheetDocument
.getCurrentController() com.sun.star.frame.XModel
.setActiveSheet(mySheet)  com.sun.star.sheet.XSpreadsheetView


Regards
   Bernard

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]