OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

insert OLE object of Calc sheet in writer document

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
manishpithwa
General User
General User


Joined: 25 Oct 2007
Posts: 17

PostPosted: Sun Oct 28, 2007 8:13 pm    Post subject: insert OLE object of Calc sheet in writer document Reply with quote

I want to insert OLE object of calc sheet in writer document programatically. I also want to insert page of different orientation (Portrait/Landscape) in same writer document. for example if writer is have portrait orientation then I want to insert page of Landscape orientation. How can I do this programatically?
Back to top
View user's profile Send private message
vitcaro
OOo Advocate
OOo Advocate


Joined: 20 Feb 2007
Posts: 256
Location: Italy

PostPosted: Mon Oct 29, 2007 12:43 am    Post subject: Reply with quote

This is a simlpe example of how to insert a spreadsheet document into a writer document. I hope this can help for your problem.
Code:
sub Main
oDoc = ThisComponent
txt=oDoc.getText
Set TextCursor = txt.createTextCursor
Set TextEmbeddedObject = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
Dim asize As New com.sun.star.awt.Size
asize.Height =10000
asize.Width = 10000
TextEmbeddedObject.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
txt.insertTextContent TextCursor, TextEmbeddedObject, False
TextEmbeddedObject.setSize asize
Set SpreadSheetDoc = TextEmbeddedObject.getEmbeddedObject
oSheets=SpreadSheetDoc.getSheets
oSheet = oSheets.getByIndex(0)
oCell = oSheet.getCellByPosition(0, 0)
oCell.setString "ABCD"
end sub
Back to top
View user's profile Send private message
vbms
Power User
Power User


Joined: 13 Aug 2007
Posts: 63

PostPosted: Mon Oct 29, 2007 1:14 am    Post subject: Reply with quote

or in java for powerpoint something like this...

Code:

        XMultiServiceFactory xmsf = (XMultiServiceFactory)
           UnoRuntime.queryInterface(XMultiServiceFactory.class, documentComponent);

           // create an ole2shape
            XShape oleShape = (XShape)UnoRuntime.queryInterface(com.sun.star.drawing.XShape.class,
                  xmsf.createInstance("com.sun.star.drawing.OLE2Shape"));
           
            // insert the shape
            oleShape.setPosition(new Point(500,500));
            oleShape.setSize(new Size(27000,20000));
           xShapes.add(oleShape);
           
            // make the ole2shape a spreadsheet
            XPropertySet aShapeProp = (XPropertySet)
               UnoRuntime.queryInterface(XPropertySet.class, oleShape);
            aShapeProp.setPropertyValue("CLSID", 47BBB4CB-CE4C-4E80-a591-42d9ae74950f);
           
           // get the spreadsheets model
           XComponent xComponent = (XComponent)
              UnoRuntime.queryInterface(XComponent.class,
                    aShapeProp.getPropertyValue("Model"));


Last edited by vbms on Wed Oct 31, 2007 12:52 am; edited 1 time in total
Back to top
View user's profile Send private message
manishpithwa
General User
General User


Joined: 25 Oct 2007
Posts: 17

PostPosted: Wed Oct 31, 2007 12:22 am    Post subject: Reply with quote

where is calc file path, name and writer file path, name? which calc file I wil insert?
can I specify how many pages to insert?
Back to top
View user's profile Send private message
manishpithwa
General User
General User


Joined: 25 Oct 2007
Posts: 17

PostPosted: Wed Oct 31, 2007 8:01 pm    Post subject: Reply with quote

vitcaro wrote:
This is a simlpe example of how to insert a spreadsheet document into a writer document. I hope this can help for your problem.
Code:
sub Main
oDoc = ThisComponent
txt=oDoc.getText
Set TextCursor = txt.createTextCursor
Set TextEmbeddedObject = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
Dim asize As New com.sun.star.awt.Size
asize.Height =10000
asize.Width = 10000
TextEmbeddedObject.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
txt.insertTextContent TextCursor, TextEmbeddedObject, False
TextEmbeddedObject.setSize asize
Set SpreadSheetDoc = TextEmbeddedObject.getEmbeddedObject
oSheets=SpreadSheetDoc.getSheets
oSheet = oSheets.getByIndex(0)
oCell = oSheet.getCellByPosition(0, 0)
oCell.setString "ABCD"
end sub


Where is Calc file name and writer file name ?
How will OO know which calc file is to be inserted in which writer file?
Please give me complete code...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group