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*)
(* 显示字符串 *)
XLS.Sheets[0].AsString[0,1] := 'Cell 1';
(* 字符串颜色 *)
XLS.Sheets[0].Cell[0,1].FillPatternForeColor := xcYellow;
(* 字体 *)
XLS.Sheets[0].Cell[0,1].FontStyle := [xfsBold,xfsItalic];

(*Format a number cell (3 decimals and thousand separator)
(* 格式化字符串,显示小数点后三位,千位和百位之间加个空格 *)
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';
(* 单元格赋值 *)
(* Set the font size of the cells in the area.
(* 改变区域内的字体大小 *)
XLS.Sheet[0].Range.Items[1,0,3,3].FontSize := 14;
(* Set the color of the cells. *)
(* 设置区域的颜色 *)
XLS.Sheet[0].Range.ItemsRef['B1:D4'].FillPatternForeColor := xcYellow;
(* Set a outline border. *)
(* 设置外框线的外形、颜色 *)
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. *)
(* 区域复制 *)
XLS.Sheet[0].Range.ItemsRef['B1:D4'].Copy(8,10);
(* Move the cells. *)
(* 区域移动 *)
XLS.Sheet[0].Range.ItemsRef['B1:D4'].Move(8,2);
end;

procedure TfrmMain.Button1Click(Sender: TObject);
begin
AddFormats;
XLS.Filename := edFilename.Text;
(* 保存文件 *)
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.

转 Delphi中XLSReadWrite控件的使用(2)---基本应用的更多相关文章

  1. [转载]: delphi中XLSReadWrite控件的使用(1)---简介

    XLSReadWrite控件简介: 一个你需要的,能在Delphi和.NET下访问Excel文件的完美解决方案. 一个经典的读写Excel的控件,对于使用Excel 开发很有帮助 官方网站: http ...

  2. 转Delphi中XLSReadWrite控件的使用(1)---简介

    XLSReadWrite控件简介: 一个你需要的,能在Delphi和.NET下访问Excel文件的完美解决方案. 一个经典的读写Excel的控件,对于使用Excel 开发很有帮助 官方网站: http ...

  3. [转载]: delphi中XLSReadWrite控件的使用(2)---delphi XE下安装

    一.下载 官方下载网址: http://www.axolot.com/components/download.htm 从这里可以下载到从Delphi5到DelphiXE全部支持的版本. 二.软件安装 ...

  4. [转载]: delphi中XLSReadWrite控件的使用(3)---基本应用

    这是自带的一个例子,看懂这一点东西,基本的操作应该没问题了.... unit Main; interface uses Windows, Messages, SysUtils, Variants, C ...

  5. 转Delphi中XLSReadWrite控件的使用(3) 读和写Excel

    unit OpExcell; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Fo ...

  6. Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决

    Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决 EmbeddedWBWebBrowserDelphi  最近用E ...

  7. Delphi中TxmlDocument控件的用法 转

    Delphi中对XML文件的解析做的很好,比直接使用MS的MSXML2_TLB中的接口要方便很多,现称述于下面. 在讲之前先给出一个XML实例,在讲某些部分是要结合实例比较容易理解. 1<?xm ...

  8. delphi中panel控件应用

    delphi中的panel控件是怎么使用的?研究了很久了,还是搞不懂,只知道把它放到form上面,其他操作一律不懂了,有谁可以请教一下,如何把其他控件放到里面去呢?谢谢 提问者采纳   直接把控件放到 ...

  9. delphi中DateTimePicker控件同时输入日期和时间

    将DateTimePicker的Format属性中加入日期格式设成 'yyyy-MM-dd HH:mm',注意大小写 , 将kind设置为dtkTime即可,可以在每次Form onShow时将Dat ...

随机推荐

  1. Tomcat设置欢迎页问题

    今天下载了tomat9,配置到eclipse后拉起来,想跑个欢迎页看看是否起好了,随手写了个index.jsp放到项目Struts2的WebContent根目录下,直接打开网页输入http://loc ...

  2. C# messagebox 居中父窗体

    在右边项目上点击右键->Add->class,添加MessageBoxEx类: using System; using System.Windows.Forms; using System ...

  3. 事务之二:spring事务(事务管理方式,事务5隔离级别,7个事务传播行为,spring事务回滚条件)

    事物管理对于企业应用来说是至关重要的,好使出现异常情况,它也可以保证数据的一致性. spring支持编程式事务管理和声明式事务管理两种方式. 编程式事务管理使用TransactionTemplate或 ...

  4. 微信企业号支付个人php实现

    导语:分销商,微商提现怎么提? 直接用微信支付. 实现如下: 微信支付配置 /*微信支付*/ 'PAY_WEIXIN' => array( 'appid' => 'XXXX', 'apps ...

  5. python学习(五) 条件、循环和其他语句

    第五章 条件.循环和其他语句 5.1 print和import的更多信息 5.1.1 使用逗号输出 >>> print('age',43,45)         // 可以用逗号隔开 ...

  6. shell命令getopts

    #!/bin/bash set -e cmd="ls" while getopts :a:t:sn opt; do case $opt in a) cmd=$cmd" - ...

  7. pandas层级索引

    层级索引(hierarchical indexing) 下面创建一个Series, 在输入索引Index时,输入了由两个子list组成的list,第一个子list是外层索引,第二个list是内层索引. ...

  8. WARNING: cell0 mapping not found - not syncing cell0

    WARNING: cell0 mapping not found - not syncing cell0

  9. python--numpy学习(一)

    NumPy 部分功能如下: ndarray,一个具有矢量运算符和复杂广播能力的快速节省空间的多维数组 用于对数组数据进行快速运算的标准数学函数 用于读写磁盘数据的工具以及用于操作内存映射文件的工具 线 ...

  10. leetcode427

    本题不会做,从网上找到了python3的解法,记录如下. class Solution: def construct(self, grid): def dfs(x, y, l): if l == 1: ...