Page 1 of 1

[Solved] Detect open spreadsheet

Posted: Wed Jun 09, 2021 10:12 am
by Bingo
Hi
I use Delphi with Hojacalc to connect to my spreadcheet
But when the spreadsheet is Open I receive an error message when I send HojaCalc.saveDoc
How I can detected if the spreadsheet is allready open in another program

Thanks

Re: Detect open spreadsheet

Posted: Wed Jun 09, 2021 8:24 pm
by Villeroy
https://www.openoffice.org/api/docs/com ... oader.html returns the document specified by its URL and loads it if required.

Re: Detect open spreadsheet

Posted: Thu Jun 10, 2021 8:54 am
by Bingo
Hi

I am using the loadComponentFromURL function to open the spreadsheet and it works
My problem is not when I load the spreadsheet, if the worksheet is open (with OOCalc) the document can open it. But when I want to update the worksheet an I/O error occurs due to locking by OOCalc
I want to check if the spreadsheet is locked when I open it and open a message dialog to inform the user. Exception sends a generic IO error message (the same as when the file exists not)

Thankyou

Re: Detect open spreadsheet

Posted: Thu Jun 10, 2021 9:08 am
by Villeroy
No idea other than catching the IO error.

Re: Detect open spreadsheet

Posted: Thu Jun 17, 2021 11:40 am
by Bingo
Hi

I solved my problem by checking, in the directory, if the file with the name ".~lock.filename,ods#" exists
This file is created by openoffice when it opens the file (not if readonly)

Thank