unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Xls;
type
TfrmMain =
class(TForm)
btnMakeXls: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure btnMakeXlsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.DFM}
procedure TfrmMain.btnMakeXlsClick(Sender: TObject);
Var
FileHandle : Integer;
FileNameStr :
String;
begin
FileNameStr := ExtractFilePath(Application.ExeName) + '
Delphi.xls';
FileHandle := Xls_Create(FileNameStr);
Xls_SetFormat(FileHandle,'
yyyy-mm-dd hh:mm:ss');
// user defined additional format 21
// Xls_SetProtection(FileHandle, True); // protect entire worksheet
// Xls_SetAttributeByte1(True, True); // Hidden, Locked -> only works if sheet is protected
// some titles in the first column
Xls_SetString(FileHandle, 0, 0, '
A random string :)');
Xls_SetString(FileHandle, 1, 0, '
A lucky integer');
Xls_SetString(FileHandle, 2, 0, '
Pi (in a box) - yuk :)');
Xls_SetString(FileHandle, 3, 0, '
Today :');
Xls_SetString(FileHandle, 0, 1, '
Hello World');
// couldn't resist the temptation
Xls_SetInteger(FileHandle, 1, 1, 13);
// integer : lucky 13
Xls_SetAttributeByte3(False, True, True, True, True, 0);
// show all borders
Xls_SetDouble(FileHandle, 2, 1, Pi);
// pi = double = 3.141572...
Xls_SetAttributeByte3(False, False, False, False, False, 0);
// reset
Xls_SetAttributeByte2(0, 21);
// use user defined format 21
Xls_SetDouble(FileHandle, 3, 1, Now);
// datetime
Xls_SetAttributeByte2(0, 0);
// reset
Xls_SetColWidth(FileHandle, 0, 17);
// set column width
Xls_SetColWidth(FileHandle, 1, 25);
// set column width
Xls_Close (FileHandle);
// closing stuff
ShowMessage('
done');
end;
end.