Creating an Open Office spreadsheet file .xls

Re: Creating an Open Office spreadsheet file .xls

Postby anserkk » Fri Nov 04, 2011 4:32 am

Dear Mr.Rick,

Right now, I don't have OpenOffice/Libre Office installed on the Laptop which I am using right now. :( (I have never tried LibreOffice) On a later date, I shall install and check.

1. After a fresh reboot of you PC, please check the process list via your task manager and note whether the soffice.bin or soffice.exe is running in the background
I believe that it will not be there.
2. Open Calc from your PC's menu and then quit OpenOffice Calc.
3. Now please re-check whether soffice.bin/soffice.exe is there in the process list via task manager. I believe that it will be there.

If soffice.bin/soffice.exe is still there in the process list then, I may be wrong, but I think that soffice.exe or soffice.bin remains in the process list even if you close the OpenOffice Calc. I am not sure whether this is done purposefully to enable fast loading (QuickStart) of OpenOffice application OR an OpenOffice bug.

Regards

Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Creating an Open Office spreadsheet file .xls

Postby Rick Lipkin » Fri Nov 04, 2011 1:36 pm

Anser

Soffice.exe and soffice.bin are still present after I close the oBook .. Like you allude to .. there does not seem to be a way to close the oCalc service .. terminate() does not work .. see this thread ..

Rick Lipkin

Rocko wrote:
I didn't find the solution, but I can confirm this is the default behavior of OO 3.0: when you hit the window close button of the last document open then soffice.exe and soffice.bin are killed.


soffice.exe as soffice.bin aren't killed if you close the document with "Window-Close window", "file->Close", or the small "x" in top-right corner (this one only apears when there is only one document opened). What you are doing is the same as Alt+F4.

Calling oDocument.close(False) is not the same thing. Here you are calling ".uno:CloseDoc" or maybe ".uno:CloseWin" (still don't understand the difference). To close the office you must call oDesktop:terminate() - I imagine that OOo internaly calls ".uno:Quit"

So, to kill soffice.exe and soffice.bin you must trigger oDesktop:terminate() if the document is the last one opened.

I hope it's more clear now Smile
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1297
Location: France

PostPosted: Sat Nov 15, 2008 10:14 am Post subject: Reply with quote
Hi,
You must close(True) your document.
After closing your document, check if there is still another component.
Code:
Call oDocument.Close(True)
set DocsColls = oDesktop.Components.createEnumeration
if not DocsColls.hasMoreElements then
oDesktop.terminate
end if
Set oDocument = Nothing
Set oDesktop = Nothing
Set oServiceManager = Nothing
______
Bernard
Back to top
View user's profile Send private message Visit poster's website
Rocko
General User
General User


Joined: 04 Nov 2008
Posts: 17


PostPosted: Sun Nov 16, 2008 9:46 am Post subject: Reply with quote
Thanks, that worked.
Back to top
View user's profile Send private message
BrianS
General User
General User


Joined: 10 Jun 2008
Posts: 38


PostPosted: Mon Nov 17, 2008 6:46 am Post subject: Reply with quote
B Marcelly wrote:
Hi,
You must close(True) your document.
After closing your document, check if there is still another component.
Code:
Call oDocument.Close(True)
set DocsColls = oDesktop.Components.createEnumeration
if not DocsColls.hasMoreElements then
oDesktop.terminate
end if
Set oDocument = Nothing
Set oDesktop = Nothing
Set oServiceManager = Nothing
______
Bernard


Are you sure this works if Quickstarter is running? From what I experienced, the desktop.terminate method won't work with Quickstarter... I had to do this to handle Quickstarter:
Code:

Call objQuickstart.setFastPropertyValue(0, False)
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1297
Location: France

PostPosted: Mon Nov 17, 2008 12:20 pm Post subject: Reply with quote
Hi,
BrianS wrote:
Are you sure this works if Quickstarter is running?

The previous discussion let me suppose that the user does not use the Quickstarter.
To circumvent the possible use of the Quickstarter do this:
Code:
oDesktop.SuspendQuickstartVeto = True
oDesktop.terminate
Back to top
View user's profile Send private message Visit poster's website
BrianS
General User
General User


Joined: 10 Jun 2008
Posts: 38


PostPosted: Mon Nov 17, 2008 12:50 pm Post subject: Reply with quote
B Marcelly wrote:
Hi,
BrianS wrote:
Are you sure this works if Quickstarter is running?

The previous discussion let me suppose that the user does not use the Quickstarter.
To circumvent the possible use of the Quickstarter do this:
Code:
oDesktop.SuspendQuickstartVeto = True
oDesktop.terminate


Thanks... That works the same as what I had done with setFastPropertyValue, but is a bit cleaner and is a bit more descriptive, so I'll use that instead...

User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Creating an Open Office spreadsheet file .xls

Postby ShumingWang » Sat Nov 05, 2011 1:58 am

oSheet:GetCellByPosition( 0, nRow ):SetString :="aaa"
should change into
oSheet:GetCellByPosition( 0, nRow ):SetString ("aaa")
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: Creating an Open Office spreadsheet file .xls

Postby Rick Lipkin » Sat Nov 05, 2011 1:03 pm

Shuming

Tell me what the difference is with using SetString( "aaa" ) and assigning the value with the in-line equal operator ?? .. Using a character string makes it more difficult to write this :

oSheet:GetCellByPosition( 0, nRow ):SetString := D->address

Do you know how to close the oCalc object from the ServiceManager ?

oCalc := CreateObject( "com.sun.star.ServiceManager" )

It seems that the Office "stub" needs to stay resident in memory .. I have found no way to end(), Quit(), Terminate() the object ?

Rick
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Creating an Open Office spreadsheet file .xls

Postby ADutheil » Sat Nov 05, 2011 3:07 pm

You can try a brute force solution:

FUNCTION KillOO( cTask ) // cTask is the name of the OO stub
LOCAL nShel := fCreate( "kill.bat" )

fWrite( nShel, "taskkill /F /IM " + cTask )
fClose( nShel )
ShellExecute( 0, "open", "kill.bat",,, )
fErase( "kill.bat" )
RETURN ( NIL )
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Creating an Open Office spreadsheet file .xls

Postby Rick Lipkin » Sat Nov 05, 2011 3:23 pm

André

Thanks .. I thought about that .. I figure Open Office and it successors do not want the ServiceManager closed .. my guess is it may effect other Open office programs already open if you close it :(

Rick
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Creating an Open Office spreadsheet file .xls

Postby goosfancito » Wed Oct 14, 2015 2:37 pm

Hello!

Some solution?

Thank´s
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: Creating an Open Office spreadsheet file .xls

Postby Maurizio » Fri Mar 24, 2017 4:27 pm

Hello
// This Close
  oBook:Close(.t.)
  oDesktop:Terminate()


Code: Select all  Expand view  RUN
TRY
             oText := GetActiveObject( "com.sun.star.ServiceManager" )
       CATCH
          ? "Open Office non installato"
           Return nil
        END
  oDesktop := oText:CreateInstance( "com.sun.star.frame.Desktop" )
  aProp:={}
  AAdd(aProp,GetPropertyValue(oText, "Hidden", .T. )  )
  oBook   := oDesktop:LoadComponentFromURL( "file:///"+ cFile , "_blank", 0, aProp )
  oFoglio   := oBook:GetSheets():GetByIndex( 0 )

  //-------------------------------------------
  // This Close
  oBook:Close(.t.)
  oDesktop:Terminate()

 


Maurizio
http://www.nipeservice.com
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: Creating an Open Office spreadsheet file .xls

Postby goosfancito » Fri Mar 24, 2017 8:48 pm

thanks
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests