How can i open and read a protected *.xls

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
vincent909
Posts: 2
Joined: Mon Sep 09, 2013 1:38 pm

How can i open and read a protected *.xls

Post 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.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

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

Post 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.
Lars Arvidsson, Axolot Data
vincent909
Posts: 2
Joined: Mon Sep 09, 2013 1:38 pm

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

Post 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;
TXDelphi
Posts: 1
Joined: Tue Oct 06, 2015 5:55 pm

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

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

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

Post by larsa »

Hello

Encrypted XLSX files are not supported.
Lars Arvidsson, Axolot Data
Post Reply