openoffice-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shukla, Mangesh" <>
Subject RE: UNP API
Date Wed, 10 Apr 2013 12:36:03 GMT
Hi ,
   You can use the following Api's in C++. This is some prototype code, I implemented for
my project.


    // 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
        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

        return 0;

-----Original Message-----
From: Andrew Pitonyak [] 
Sent: Wednesday, April 10, 2013 5:54 PM
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" <> wrote:

>How can I select a sheet in calc document?

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:
View raw message