Unit Main;
Interface
Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, stdctrls, xlsreadwriteii4, xlsfonts4, cellformats4, biffrecsii4;
Type
Tfrmmain = Class (tform)
Label1: tlabel;
Button1: tbutton;
Edfilename: tedit;
Button2: tbutton;
Button3: tbutton;
Dlgsave: tsavedialog;
XLS: txlsreadwriteii4;
Procedure button1click (Sender: tobject );
Procedure button2click (Sender: tobject );
Procedure button3click (Sender: tobject );
Private
Procedure addformats;
Public
{Public declarations}
End;
VaR
Frmmain: tfrmmain;
Implementation
{$ R *. DFM}
Procedure tfrmmain. addformats;
Begin
(* Format a single cell *)
(* Display string *)
XLS. Sheets [0]. asstring [0, 1]: = 'cell 1 ';
(* String color *)
XLS. Sheets [0]. Cell [0, 1]. fillpatternforecolor: = xcyellow;
(* Font *)
XLS. Sheets [0]. Cell [0, 1]. fontstyle: = [xfsbold, xfsitalic];
(* Format a number cell (3 decimals and thousand separator)
(* Format the string and display the last three digits of the decimal point. A space is added between the number of digits and the number of digits *)
XLS. Sheets [0]. asfloat [0, 0]: = 12335985394.895634;
XLS. Sheets [0]. Cell [0, 0]. numberformat: = '### 0.000 ';
(* Write a string cell .*)
XLS. Sheet [0]. asstringref ['c2']: = 'hello ';
(* Cell assignment *)
(* Set the font size of the cells in the area.
(* Change the font size in the area *)
XLS. Sheet [0]. range. items [,]. fontsize: = 14;
(* Set the color of the cells .*)
(* Set the region color *)
XLS. Sheet [0]. range. itemsref ['b1: D4 ']. fillpatternforecolor: = xcyellow;
(* Set a outline border .*)
(* Set the shape and color of the outer frame line *)
XLS. Sheet [0]. range. itemsref ['b1: D4 ']. borderoutlinestyle: = cbsthick;
(* Set color of the outline border .*)
XLS. Sheet [0]. range. itemsref ['b1: D4 ']. borderoutlinecolor: = xcred;
(* Make a copy of the cells .*)
(* Region replication *)
XLS. Sheet [0]. range. itemsref ['b1: D4 ']. Copy (8, 10 );
(* Move the cells .*)
(* Move the region *)
XLS. Sheet [0]. range. itemsref ['b1: D4 ']. Move (8, 2 );
End;
Procedure tfrmmain. button1click (Sender: tobject );
Begin
Addformats;
XLS. filename: = edfilename. text;
(* Save file *)
XLS. Write;
End;
Procedure tfrmmain. button2click (Sender: tobject );
Begin
Dlgsave. filename: = edfilename. text;
If dlgsave. Execute then
Edfilename. Text: = dlgsave. filename;
End;
Procedure tfrmmain. button3click (Sender: tobject );
Begin
Close;
End;
End.
Use of the xlsreadwrite control in Delphi (2) --- Basic Application