B4J Question Export to Excel creates ReadOnly file

Victor Pavlov

Member
Licensed User
Longtime User
We created Excel file through jexcel library the file stays in ReadOnly mode. The message from Excel is: The file is locked for editing by "".

Please, advice.
 

alienhunter

Active Member
Licensed User
Longtime User
hmmm
i noticed that too everything that fx writes is locked , but like erel wrote I copy it in a different place to be able to open a file with another application when fx is running
 
Upvote 0

Crock

Member
Licensed User
Longtime User
Even though the workbook is closed, NumberOfSheets returns 1 and I get no error.
...
B4X:
'add some cells etc
wb.Write
wb.Close
Log("sheetcount=" & wb.NumberOfSheets)

But if I try another wb.close it raises an error, as expected.

Unlike alienhunter's experience, I find that if the jar is still running, I still cannot open the xls from another Windows folder. I wonder if wb.close is not properly closing the file and releasing the lock. Can someone confirm the above?
 
Last edited:
Upvote 0

Crock

Member
Licensed User
Longtime User
wb.Close calls the native close method.

Have you tried the code I posted in post #2?

Thanks, I can see that is a workaround but it makes no sense that the native close method keeps a file locked. Is this a Java "feature"?
 
Upvote 0

Crock

Member
Licensed User
Longtime User
It is not related to Java. It seems like an issue with the native JXL library.

Thanks Erel. I just had a good search and found nothing about this read-only issue. If I find anything else I'll post back here.
 
Upvote 0
Top