[Solved] Detect open spreadsheet

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Bingo
Posts: 3
Joined: Wed Jun 09, 2021 9:58 am

[Solved] Detect open spreadsheet

Post 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
Last edited by Bingo on Thu Jun 17, 2021 11:44 am, edited 1 time in total.
OpenOffice 4.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Detect open spreadsheet

Post by Villeroy »

https://www.openoffice.org/api/docs/com ... oader.html returns the document specified by its URL and loads it if required.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Bingo
Posts: 3
Joined: Wed Jun 09, 2021 9:58 am

Re: Detect open spreadsheet

Post 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
OpenOffice 4.1 on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Detect open spreadsheet

Post by Villeroy »

No idea other than catching the IO error.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Bingo
Posts: 3
Joined: Wed Jun 09, 2021 9:58 am

Re: Detect open spreadsheet

Post 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
OpenOffice 4.1 on Windows 10
Post Reply