首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi 操作excel解决办法

2014-06-01 
delphi 操作excel我一个程式在操作excel当delphi打开excel时,用户需要先编辑excel,这时,我需要delphi程式

delphi 操作excel
我一个程式在操作excel

当delphi打开excel时,用户需要先编辑excel,这时,我需要delphi程式停住

然后关闭excel时,delphi再继续运新,读取excel内容



  ExcelApp:=createoleobject('Excel.application');
  ExcelApp.WorkBooks.Open(fName);
  ExcelApp.WorkSheets[1].Activate;
  ExcelApp.Visible := True;


我目前写了这段,打开excel的代码


这个功能可以实现麽
[解决办法]


PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo; //This is an [in] parameter
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field
if(CreateProcess("c:\\winnt\\notepad.exe", NULL,
     NULL,NULL,FALSE,0,NULL,
     NULL,&StartupInfo,&ProcessInfo))
{
     WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
     CloseHandle(ProcessInfo.hThread);
     CloseHandle(ProcessInfo.hProcess);
     //等Excel编辑结束后在用Delphi打开
}  
else
{
     MessageBox("The process could not be started...");
}

热点排行