Using Services via OLE/COM

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Using Services via OLE/COM

Postby PiJon » Tue Dec 10, 2019 4:21 pm

Hi,
I have a special framework with pascal-similar language.
I'm trying to export some data to OpenOffice Calc.

Code: Select all   Expand viewCollapse view
var App, Instance, Document, Sheet, Cell : variant;

  App := CreateOLEObject('com.sun.star.ServiceManager');
  Instance := App.createInstance('com.sun.star.frame.Desktop');
  Document := Instance.loadComponentFromURL('private:factory/scalc', '_blank', 0, args);
  Sheet := Document.createInstance('com.sun.star.sheet.Spreadsheet');
  Document.Sheets.insertByName('MySheet', Sheet);
  Cell := Sheet.getCellbyPosition(2, 3);
  Cell.String := 'Test Text';

it works correct.
Now I want to justify text in the cell to the right.
Formatting Spreadsheet Documents:
Special cell formatting is handled by the com.sun.star.table.CellProperties service.
HoriJustify (enum): horizontal justification of the text (value from com.sun.star.table.CellHoriJustify)

How can I do it?
Cell.CellProperties? OLE Object doesn't have method CellProperties
Cell.createInstance('com.sun.star.table.CellProperties')? OLE Object doesn't have method...
App.createInstance('com.sun.star.table.CellProperties')? Unsupported type of returned value.

Is the latter way correct? Probably the problem is in my framework.

Thanks.
OpenOffice 4.1.2 on Windows 7
PiJon
 
Posts: 1
Joined: Tue Dec 10, 2019 3:53 pm

Re: Using Services via OLE/COM

Postby Zizi64 » Tue Dec 10, 2019 6:03 pm

Open a prepared template (instead of a new, blank document based on the default template)
and apply an existing, user defined Cell style (instead of the direct formatting method).
Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.0; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8773
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests