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:[email protected]] 
Sent: Wednesday, April 10, 2013 5:54 PM
To: [email protected]
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" <[email protected]> wrote:

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

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

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

Reply via email to