全部博文(788)
分类:
2008-09-16 14:57:51
主要代码如下
iHandle :=FileOpen(XlsFileName, fmShareExclusive);
if (iHandle < 0) then
IsOpen:=True
else
IsOpen:=false ;
Excelapplication.Workbooks.Open(XlsFileName,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,0);//打开指定的EXCEL 文件
ExcelWorkbook.ConnectTo(ExcelApplication.ActiveWorkbook);//ExcelWorkbook1与Eexcelapplication1建立连接
ExcelWorksheet.ConnectTo(ExcelWorkbook.Worksheets[Num] as _Worksheet);//Excelworksheet1与Excelworkbook1建立连接
...//中间进行若干读操作
ExcelApplication.Disconnect;//出现异常情况时关闭
if IsOpen<>true then
ExcelWorkbook.Close;
继续在线等....