Page 1 of 1

Password protecting files

Posted: Thu Nov 27, 2014 12:25 pm
by DWM35
Hi,

We are trying to create password-protected files. The logic used is:

XLS := TXLSReadWriteII5.Create (Nil);
XLS.FileName := 'SampleFilename.xls'; // also tried 'SampleFileName.xlsx'
XLS.Version := xvExcel97; // also tried xvExcel2007
XLS.Password := 'Password';

// code to fill in the cells

XLS.Write;

The files contain the correct data, however they are not password-protected. This was working with XLSReadWriteII version 4.

We'd be grateful of any help here.

Thanks

-- Dave

Re: Password protecting files

Posted: Fri Nov 28, 2014 10:58 am
by larsa
Hello

Sorry, encrypted files are only supported for XLS files, not XLSX. This will be added in a later update (please don't ask when this update is ready).

Re: Password protecting files

Posted: Fri Nov 28, 2014 12:55 pm
by DWM35
Hi,

I'm not too worried about xlsx files, but passwords don't seem to be working using xls files either. The following code demonstrates the problem. Running this using XLSReadWriteII4 (with suitable change to unit and object names) gives me an exl file which is password protected.

-- Dave

unit Unit10;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, XLSSheetData5, XLSReadWriteII5;

type
TForm10 = class(TForm)
XL: TXLSReadWriteII5;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form10: TForm10;

implementation

{$R *.dfm}
uses XC12Utils5;

procedure TForm10.Button1Click(Sender: TObject);
begin
XL.FileName := 'C:\temp\test.xls';
XL.Version := xvExcel97;
XL.Password := 'password';
XL.Sheets[0].AsString[0,0] := 'Test cell';
XL.Write;

end;

end.