Password protecting files

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
DWM35
Posts: 2
Joined: Thu Nov 27, 2014 12:20 pm

Password protecting files

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

Re: Password protecting files

Post 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).
Lars Arvidsson, Axolot Data
DWM35
Posts: 2
Joined: Thu Nov 27, 2014 12:20 pm

Re: Password protecting files

Post 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.
Post Reply