Use of the xlsreadwrite control in Delphi (2) --- Basic Application

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.