uses( ComObj)
procedure TForm1.Button1Click(Sender: TObject);
var ExcelApp: Variant;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := false;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Open( 'C:\bb.xls' ); //打开已存在的工作簿
ExcelApp.Cells[1,4].Value := 'xcvxvcc';
excelapp.save ;
if not ExcelApp.ActiveWorkBook.Saved then
ExcelApp.ActiveSheet.PrintPreview;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
application.MessageBox('保存成功','系统提示',0);
end;
end.有什么方法可以去掉我这里的对话框呢?我真的无法理解,为什么会这样。
procedure TForm1.Button1Click(Sender: TObject);
var ExcelApp: Variant;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := false;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Open( 'C:\bb.xls' ); //打开已存在的工作簿
ExcelApp.Cells[1,4].Value := 'xcvxvcc';
excelapp.save ;
if not ExcelApp.ActiveWorkBook.Saved then
ExcelApp.ActiveSheet.PrintPreview;
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;
application.MessageBox('保存成功','系统提示',0);
end;
end.有什么方法可以去掉我这里的对话框呢?我真的无法理解,为什么会这样。
var ExcelApp: Variant;
Sheet: Variant;
i,h:integer; j,aa,bb,cc:integer;
sheetname:string;
begin
aa:=strtoint(trim(Edit1.Text));
bb:=strtoint(trim(edit2.Text));
cc:=(bb-aa);
h:=1;
try
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Visible := false;
ExcelApp.Caption := '应用程序调用 Microsoft Excel';
ExcelApp.WorkBooks.Open( 'C:\222.xls' ); //打开已存在的工作簿
Except
ExcelApp.Free;
exit;
end;
while cc>0 do
begin
sheetname:='sheet'+inttostr(h);
Sheet :=ExcelApp.Workbooks[1].WorkSheets[sheetname];
j:=0;
while j<7 do
begin
for i:=0 to 3 do
begin
sheet.cells[j+1, i + 1]:= '0'+inttostr(aa);
aa:=aa+1;
end;
inc(j);
end;
cc:=cc-28;
h:=h+1;
end;
excelapp.Visible := True;
ShowMessage('ok!');
end;