Page 1 of 1

Error openinng xls files.

Posted: Mon Jun 19, 2017 5:44 am
by AllanGMorris
Hi,

I have an issue opening xls files (excel97-2003 format), I am getting a strange error of Missing Password and XLSX files are read OK without any issue.

I have tried to open with a specific version by setting the version:
SampleWorkbook:= TXLSReadWriteII5.Create(Nil);
SampleWorkbook.Filename := 'a.xls';
SampleWorkbook.Version:=xvExcel97;
SampleWorkbook.read;

and it still has an error??

Thanks
Allan

Re: Error openinng xls files.

Posted: Mon Jun 19, 2017 4:28 pm
by larsa
Hello

Your code shall work ok. Can you send me the XLS file and I will take a look at it?

Re: Error openinng xls files.

Posted: Tue Jul 11, 2017 1:17 pm
by David
Hi

I am receiving the same error when trying to open xls files: "Missing Password".
I have tried both:
XLSReader := TXLSReadWriteII5.Create(nil);
XLSReader.Filename := 'file.xls';
XLSReader.Version := xvExcel97;
XLSReader.Read;
and
XLSReader := TXLSReadWriteII5.Create(nil);
XLSReader.Version := xvExcel97;
XLSReader.LoadFromFile(file.xls);

I can read in xlsx files without getting the above error.

Was this issue previously resolved?

Thanks
David

Re: Error openinng xls files.

Posted: Wed Jul 12, 2017 11:10 am
by David
Hi

I have now debugged through the code using the source files instead of the complied code fields and found out where I am receiving the "Missing Password" error.
Although I set the version of Excel upfront before calling the Read procedure, within the TXLSReadWriteII5.LoadFromFile
procedure which is called from Read, it tries to determine what version of Excel is being used by examining the file extension.
The file is only processed as an Excel 97 file if the extension is '.xls' or '.xlm'. Else it gets treated as an Excel 2007 file and when
the code tries to process it i fails.
As we assign temporary names to files stored in a database this is why our .xls files are not being read as the file extension is no .xls
at this point.

Regards
David