如何操作Excel????
- Delphi(Pascal) code
ExcelApp := CreateOleObject('Excel.Application'); ExcelApp .WorkBooks.Open(Path);//Path:excel的路径 ExcelApp .visible := False;
为啥这个不能用呢上面的代码,我从网上看看的代码大量都是这样的。。。。。。。。
[解决办法]
贴出完整的代码,刚这两句看不出什么。
[解决办法]
- Delphi(Pascal) code
function My_CreateOleObject(const ClassName: string; out Ole_Handle: IDispatch): Boolean;var ClassID: TCLSID; l_Result: HResult;begin Result := False; l_Result := CLSIDFromProgID(PWideChar(WideString(ClassName)), ClassID); if (l_Result and $80000000) = 0 then begin l_Result := CoCreateInstance(ClassID, nil, CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER, IDispatch, Ole_Handle); if (l_Result and $80000000) = 0 then Result := True; end;end;