转 Delphi中XLSReadWrite控件的使用(2)---基本应用

时间:2022-09-25 11:32:34

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. GSM模块fibocom G510使用记录

    一、背景:最近在做一个单定位的产品,对低功耗要求较高,选用了G510系列的模块。现在仅做了三块样板,先熟悉下。 二、优点:1.功耗低,和西门子的BGS2差不多;2.注册网络指令简单;3.其他有待发现 ...

  2. PHP 数组 foreach引用导致的bug

    <?php $arr = array('a', 'b', 'c'); foreach($arr as &$v) {} foreach($arr as $v) {} var_dump($a ...

  3. AC自动机 - 多模式串匹配问题的基本运用 &plus; 模板题 --- HDU 2222

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  4. samba 开启

    1.查询samba服务安装好没 2.安装samba服务 3.增加以下几个条目 4.useradd smbuser 5.在重启中注意的问题 5.详细请查看 http://jingyan.baidu.co ...

  5. curl说明

    https://baike.baidu.com/item/curl/10098606?fr=aladdin curl是利用URL语法在命令行方式下工作的开源文件传输工具.它被广泛应用在Unix.多种L ...

  6. liunx必知必会(1)

    一.liunx目录结构: (1)/bin中 - 用户二进制文件 包含二进制可执行文件. 在单用户模式下,你需要使用的常见Linux命令都位于此目录下.系统的所有用户使用的命令都设在这里. (2)/sb ...

  7. direct3d

    DirectX for .Net procedure 1, install DXSDK  https://www.microsoft.com/en-us/download/details.aspx?i ...

  8. C&num;中使用Spire&period;docx操作Word文档

    使用docx一段时间之后,一些地方还是不方便,然后就尝试寻找一种更加简便的方法. 之前有尝试过使用Npoi操作word表格,但是太烦人了,随后放弃,然后发现免费版本的spire不错,并且在莫种程度上比 ...

  9. ES6 常用1

    ( (1)交换变量的值 ) [x, y] = [y, x]; ( (2)从函数返回多个值 // 返回一个数组function example() { return [1, 2, 3]; } var [ ...

  10. idea unicode自动转码设置

    idea unicode自动转码设置 File > Settings > Editor > File Encodings 右侧 Properties Files 中 选中 Trans ...