delphi操作excel,总是需要先打开excel,于是就会有excel在桌面快速打开再关闭,很不舒服,有什么办法吗?
1个回答
展开全部
use
...,Excel2000, OleServer, ExcelXP;
type
TForm1 = class(TForm)
ExcelApplication1: TExcelApplication;
ExcelWorkbook1: TExcelWorkbook;
ExcelWorksheet1: TExcelWorksheet;
...
ExcelApplication1 := TExcelApplication.Create(Application);
ExcelWorkbook1 := TExcelWorkbook.Create(Application);
ExcelWorksheet1 := TExcelWorksheet.Create(Application);
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Open(CurInfo.CurFile,null,null,null,null,null,null,null,null,null,null,null,null,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _worksheet);
...
ExcelWorksheet1.Disconnect;
ExcelWorkbook1.Disconnect;
ExcelApplication1.Disconnect;
ExcelApplication1.Workbooks.Close(0);
ExcelApplication1.Quit;
ExcelWorksheet1.Free;
ExcelWorkbook1.Free;
ExcelApplication1.Free;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |