I have several 1000 Excel-Files, which are opened one after the other. One file seems to be corrupted, because Flexcel reports the index 1.048.577 is wrong. This number is 1 bigger than the possible max index for xlsx-Files.
How would it be possible to stop execution before the error occured?
You could try recovery mode and see if FlexCel can open it:
Recovery mode isn't fool-proof and it might work or not depending on where the error is, but it might be worth a try.
Other idea would be to use virtual mode to read the file, and stop when you get to the error. You can see an example of how to read only the first 50 rows of a file here:
Instead of reading 50 rows, you could stop when there is an error.
Those are the 2 things I can think of, depending on the file and what you want to do with it, there might be other solutions. If you want, you can send me the file to email@example.com and I can take a look.
Thanks for your answer.
I cannot send you the corrupted file, because I do not yet know which file is the culprit.
So a short procedure to test corruptness would be usefull.
Can't you just do:
for i :=1 to 1000 do
on e:Exception do
Log(filename[i] + ' cannot be opened');