I try to write to an existing file with QFile, which works as expected. However, the problem is that if the file is open in Excel, writing to the file from my program fails.
I try to test the permissions with QFileInfo and have all read and write permissions on the file. The test
bool opened = file-> open (QIODevice :: WriteOnly)
returns true.
The same problem does not occur when the file is opened with notepad++.
How can I check if the file is locked and can't be written to?
Excel locks its open files for exclusive use. You can't write to an open file, move or delete it. There is no way to bypass this lock.