excel问题?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj,oleCtrls,comCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
i,j:integer;
name:array[1..300] of integer;
SavePath:OleVariant;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var ExcelID,ExcelApp:variant;
var i,j:integer;
begin
ExcelID := CreateOleObject( 'Excel.Application');
ExcelID.Visible := True;
ExcelID.caption := 'sadlf';
ExcelID.WorkBooks.Add;
ExcelID.WorkBooks.Open( 'e:\Excel1.xls' );
ExcelApp := CreateOleObject( 'Excel.Application');
ExcelApp.Visible := True;
ExcelApp.caption := 'sadlf';
ExcelApp.WorkBooks.Open( 'e:\Excel2.xls' );
(*for i:=1 to 262 do
for j:=1 to 14 do
//Name[i]:= quotedStr(ExcelID.Cells[i,1].Value);
begin
ExcelApp.Cells[j,6].Value :=ExcelID.Cells[i,j].Value;
end;
ExcelApp.SaveAs( 'e:\Excel\11.htm' );
ExcelApplication.DisConnect ; *)
ExcelApp.Cells[1,6].Value :=ExcelID.Cells[1,1].Value ;
ExcelApp.SaveAs( 'e:\excel\as.xls' );
end;
end.
以上代码实现的从一个excel表中按行提取数据在另一个表中以保存,然后保存为网页形式,
准备用for循环实现
但是现在在保存这遇到了问题,死活过不去,saveas这用的不正确么?
就是保存不了
其中use 中加入了
oleCtrls,comCtrls,还是不行。
另外各位大侠对我上面的代码有什么建议
改动,希望能修改贴出来,
小弟新手,万分感谢!