[Solved] Opening a Spreadsheet invisible

The Application Programming Interface and the OASIS Open Document Format

[Solved] Opening a Spreadsheet invisible

Postby Peter18 » Fri Oct 07, 2011 11:50 am

A friendly hallo to anybody,

I open a spreadsheet, read data from it and close it. It would be nice, to open the spreadsheet invisible, because it may confuse a user if a window appeares an disappeares.

Thank you and have a nice day!

Peter
Last edited by Peter18 on Mon Oct 10, 2011 1:18 pm, edited 1 time in total.
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Opening a Spreadsheet invisible

Postby FJCC » Fri Oct 07, 2011 2:48 pm

There is an example of using the Hidden propertyvalue here
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7535
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Opening a Spreadsheet invisible

Postby Peter18 » Fri Oct 07, 2011 4:01 pm

Hallo FJCC,

thank you for your answer! I tried to do it with Delphi 4:
Code: Select all   Expand viewCollapse view
    OpenOffice   := CreateOleObject('com.sun.star.ServiceManager');
    Par          := OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    Par.Name     := 'Hidden';
    Par.Value    := False;

    StarDesktop  := OpenOffice.createInstance('com.sun.star.frame.Desktop');
    sv           := OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider');
    Path         := sv.getFileURLFromSystemPath('', FilePath);
    excel        := StarDesktop.loadComponentFromURL( Path, '_blank', 0, Par );
    Sheet        := Vertrieb.excel.Sheets.getByName( WorkSheet );

But I get an OLE error: typeconflikt with "StarDesktop.loadComponentFromURL( Path, '_blank', 0, Par );" :(
With empty "Par" there is no error.

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Opening a Spreadsheet invisible

Postby FJCC » Fri Oct 07, 2011 4:23 pm

The fourth argument of loadComponentFromURL has to be an array of PropertyValues. In Basic this could be done with
Code: Select all   Expand viewCollapse view
Dim args(0) as New com.sun.star.beans.PropertyValue
args(0).Name = "Hidden"
args(0).Value = False
...

and then using args() as the fourth argument of loadComponentFromURL. I expect in Delphi you would just declare an array of length one and set its element to be your variable Par.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7535
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Opening a Spreadsheet invisible

Postby Peter18 » Fri Oct 07, 2011 6:19 pm

Hallo FJCC.

thank you again. "Par" is a Variant. "OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');" creates a Structure of OO. Even if I declare "Par" as "Array of Variant" with length of 1, there is the same error. I think "Par.Value" is not ok. Delphi normaly uses 1 Byte for a Boolean, but in API I sometimes found "Longboolean". But it does'nt work too.

Greetings

Peter
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm

Re: Opening a Spreadsheet invisible

Postby FJCC » Fri Oct 07, 2011 8:50 pm

You may well be right that the Value of the PropertyValue is causing trouble. I don't have any direct suggestions to deal with that. You might try installing the XRay object inspection tool and try different ways of setting the Value and then inspecting the result. There is a section in the XRay manual about using it with Delphi. There is also a mention of a Delphi_OOo tool that seems still to be available. That must surely have a way of dealing with PropertyValues.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7535
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Opening a Spreadsheet invisible

Postby Peter18 » Mon Oct 10, 2011 1:17 pm

Hello FJCC,

thank you for your answer. I forgot the line "Par := VarArrayCreate([0, 0], varVariant);" There were too much trees, so I didn't see the forest. ;)
Code: Select all   Expand viewCollapse view
    Par          := VarArrayCreate([0, 0], varVariant);
    OpenOffice   := CreateOleObject('com.sun.star.ServiceManager');
    Par[0]       := OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    Par[0].Name  := 'Hidden';         
    Par[0].Value := True;             

    StarDesktop  := OpenOffice.createInstance('com.sun.star.frame.Desktop');
    sv           := OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider');
    Path         := sv.getFileURLFromSystemPath('', FilePath);
    excel        := StarDesktop.loadComponentFromURL( Path, '_blank', 0, Par );
    Sheet        := Vertrieb.excel.Sheets.getByName( WorkSheet );


Greetings
OpenOffice 3.3; OpenOffice 4.1.1
Peter18
 
Posts: 99
Joined: Thu May 12, 2011 1:01 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest