Y
yyy_as
Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是delphi6的控件:
procedure TfrmFindPrint.Button7Click(Sender: TObject);
var
ExcelApp1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorkSheet1: TExcelWorksheet;
begin
try
ExcelApp := TExcelApplication.Create(Self);
ExcelWorkbook1 := TExcelWorkbook.Create(Self);
ExcelWorkSheet1 := TExcelWorksheet.Create(Self);
except
ShowMessage ('false,no setup Excel2000');
abort;
end;
if FileExists('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls') then try //ɾ³ý¶¯Ì¬Éú³ÉµÄtemp.xls
DeleteFile('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls');
except
end;
ExcelApp.Connect
ExcelApp.Workbooks.Add('D:/yyy_pragram/delphi_test/print_xls/demo.xls', 0);
ExcelWorkBook1.ConnectTo(ExcelApp.Workbooks[1]);
ExcelWorkSheet1.ConnectTo(ExcelWorkBook1.Sheets[1] as _WorkSheet);
ExcelApp.Visible[0]:=True;
ExcelApp.Caption := 'Microsoft Excel';
ExcelApp.Range['A1','A1'].ColumnWidth := 5;
ExcelWorkSheet1.Cells.Item[0,0].Value:=标题;
ExcelWorkBook1.SaveCopyAs('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls');
ExcelApp.Quit;
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApp.Disconnect;
end;
procedure TfrmFindPrint.Button7Click(Sender: TObject);
var
ExcelApp1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorkSheet1: TExcelWorksheet;
begin
try
ExcelApp := TExcelApplication.Create(Self);
ExcelWorkbook1 := TExcelWorkbook.Create(Self);
ExcelWorkSheet1 := TExcelWorksheet.Create(Self);
except
ShowMessage ('false,no setup Excel2000');
abort;
end;
if FileExists('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls') then try //ɾ³ý¶¯Ì¬Éú³ÉµÄtemp.xls
DeleteFile('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls');
except
end;
ExcelApp.Connect
ExcelApp.Workbooks.Add('D:/yyy_pragram/delphi_test/print_xls/demo.xls', 0);
ExcelWorkBook1.ConnectTo(ExcelApp.Workbooks[1]);
ExcelWorkSheet1.ConnectTo(ExcelWorkBook1.Sheets[1] as _WorkSheet);
ExcelApp.Visible[0]:=True;
ExcelApp.Caption := 'Microsoft Excel';
ExcelApp.Range['A1','A1'].ColumnWidth := 5;
ExcelWorkSheet1.Cells.Item[0,0].Value:=标题;
ExcelWorkBook1.SaveCopyAs('D:/yyy_pragram/delphi_test/print_xls' + 'demo.xls');
ExcelApp.Quit;
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApp.Disconnect;
end;