如下代码:
interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ExcelApp: Variant;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
m: integer;
index: integer;
begin
ExcelApp:=CreateOleObject('Excel.Application');
ExcelApp.WorkBooks.Open('D:\Demo.xls');
ExcelApp.workbooks[1].sheets[1].Range['A1:W1'].Font.Bold:=True;
ExcelApp.Workbooks[1].Sheets[1].Range['A1:W1'].Font.Name:='宋体';
index:=0;
for i:=1 to 5000 do
begin
if ExcelApp.workbooks[1].sheets[1].cells[i,1].value= '' then
ExcelApp.workbooks[1].sheets[1].cells[i,1].value := 11;
ExcelApp.workbooks[1].sheets[1].cells[i,2].value := 22;
index := index + 1;
if index>1 then break;
end;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
ExcelApp:=Unassigned;
end;end.
interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
ExcelApp: Variant;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
m: integer;
index: integer;
begin
ExcelApp:=CreateOleObject('Excel.Application');
ExcelApp.WorkBooks.Open('D:\Demo.xls');
ExcelApp.workbooks[1].sheets[1].Range['A1:W1'].Font.Bold:=True;
ExcelApp.Workbooks[1].Sheets[1].Range['A1:W1'].Font.Name:='宋体';
index:=0;
for i:=1 to 5000 do
begin
if ExcelApp.workbooks[1].sheets[1].cells[i,1].value= '' then
ExcelApp.workbooks[1].sheets[1].cells[i,1].value := 11;
ExcelApp.workbooks[1].sheets[1].cells[i,2].value := 22;
index := index + 1;
if index>1 then break;
end;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
ExcelApp:=Unassigned;
end;end.
解决方案 »
- 见鬼!求高手指教!combobox赋值和截取字符串问题!
- dephi是我们一辈子的依靠吗?
- TIpSocket中的BIND函数不能调用,请各位高手帮忙
- Excel相关
- 大家来谈谈使用线程的好处?
- 怎样把新建的控件加入到新建一栏中,就象quickreport一样?
- 又是字符串,怎么总与我过不去
- 动态链接库的问题。
- 关于给iis设置虚拟路径的问题
- 我用adoquery执行sql语句的delete后,怎样将做了删除标记的记录物理删除?(local dbf表,不使用BDE,昨天没有解决)
- 高手帮忙看看,我写的代码是不是那里错了,这代码的作用是判断一个图像切片里面黑色像素所占百分比的
- 菜鸟问题,高手请帮忙看看!!以下代码怎么不能实现?
有这句话当然跳出来啦!!!