Page 1 of 1

How can i open and read a protected *.xls

Posted: Mon Sep 09, 2013 1:46 pm
by vincent909
i am using delphi7
i want to open and read a protected xls document, i can't do it,

how can i check the excel document status: workbooks protected and worksheet protected?
I can't find any demo code.

and how to use the OnPassword event in delphi 7?
thanks very much.

Re: How can i open and read a protected *.xls

Posted: Mon Sep 09, 2013 6:48 pm
by larsa
Hello

If the file is protected, you don't have to do anything. Protection is just a flag that excel uses to prevent users from editing files. This is not implemented in XLSReadWriteII. Is the file encrypted, and hence requiring a password, there will be an exception telling that. You can provide the password in the OnPassword event.

Re: How can i open and read a protected *.xls

Posted: Tue Sep 10, 2013 2:26 am
by vincent909
Hi

i'm using xlsreadwrite 4

when i open a *.xls document with open password, it is work well. and i can get the sheets count. however, if i want to open a 2007 *.xlsx document, i get a exception"Project project1.exe raised exception chlass EaccessViolation with message "Access violation at address oo17f6af Write of address 01c7f280"" Process stoped Use step or run to continue.


/////////////////////////////////////////////// open *.xls
var xlsto:TXLSReadWriteII4;
begin
xlsto:=TXLSReadWriteII4.Create(xlsto);
xlsto.Filename:='c:\t.xls';
xlsto.Password:='aaa';
xlsto.Read;
ShowMessage(IntToStr(xlsto.Sheets.Count));
xlsto.Free;
end;

///////////////////////////////////////////////// the same code can't work when i open a *.xlsx document
var xlsto:TXLSReadWriteII4;
begin
xlsto:=TXLSReadWriteII4.Create(xlsto);
xlsto.Filename:='c:\t.xlsx';
xlsto.Password:='aaa';
xlsto.Read;
ShowMessage(IntToStr(xlsto.Sheets.Count));
xlsto.Free;
end;

Re: How can i open and read a protected *.xls

Posted: Wed Oct 07, 2015 5:10 pm
by TXDelphi

var xlsto:TXLSReadWriteII4;
begin
xlsto:=TXLSReadWriteII4.Create(xlsto);
xlsto.Filename:='c:\t.xlsx';
xlsto.Password:='aaa';
xlsto.Read;
ShowMessage(IntToStr(xlsto.Sheets.Count));
xlsto.Free;
end;

Having same problem in XE3 is there a fix or workaround?

Thanks

Re: How can i open and read a protected *.xls

Posted: Mon Oct 12, 2015 12:54 pm
by larsa
Hello

Encrypted XLSX files are not supported.