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.

最新文章

  1. C++操作MySQL大量数据插入效率低下的解决方法
  2. skiing
  3. 在ubuntu中安装jdk
  4. 数据结构与算法实验题7.1 M 商人的求救
  5. JAVA~多线程:sleep、yield方法
  6. 转】MyEclipse10安装Log4E插件
  7. HDU 5862 Counting Intersections (树状数组)
  8. cocos2d-x mac or windows eclipse android ------ Eclipse工程里面还会有许多警告
  9. "ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效"的快速解决方法
  10. (三)CodeMirror - Event
  11. CentOS查询 杀死进程
  12. openvpn部署之快速入门实战+一键部署openvpn脚本
  13. 再谈RunLoop
  14. MySQL Connector/C++ 8.0 源码编译
  15. vue中 this.$set的用法
  16. Androi开发 ---Fragment片段布局案例
  17. android 通用 Intent
  18. 递归C++
  19. angular $http服务详解
  20. 69. Sqrt(x)(二分查找)

热门文章

  1. 机器人操作系统(ROS)教程22:ROS的3D可视化工具—rviz
  2. php单链表实现
  3. 中小公司的Java工程师应该如何逆袭冲进BAT?
  4. 1052 Linked List Sorting
  5. python学习(十三) 数据库支持
  6. BugkuCTF 逆向
  7. Python Twisted系列教程6:抽象地利用Twisted
  8. 配置key认证登陆Ubuntu (下)
  9. 上传图片用图片文件的对象hash哈希值判断图片是否一样,避免重复提交相同的图片到服务器中
  10. Sublime Text 套件介紹:Pretty JSON