采用OLE方式对excel文件进行操作,参考了网上的一些教程,如http://www.cppblog.com/greatws/archive/2008/09/21/62423.html
但还是遇到了很多问题,我按照教程中的方式导入类型库、和相应的类,然后在C**Dlg.h中添加
相应头文件,并定义对象。在没有进行下一步操作时进行编译就会出现大量错误,请高手指导一下
不胜感激!
一共有460个错误,70个警告,下面列出一部分作为参考
exceltest.cpp
1>e:\exceltest\exceltest\debug\excel.tlh(1595) : error C2371: “FontPtr”: 重定义;不同的基类型
1> d:\program files\microsoft visual studio 9.0\vc\include\comdef.h(314) : 参见“FontPtr”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2786: “BOOL (__stdcall *)(HDC,int,int,int,int)”: __uuidof 的操作数无效
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2923: “_com_IIID”:“Rectangle”不是参数“<未知>”的有效 <未知> 类型变量
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(3667) : 参见“Rectangle”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C3203: “_com_IIID”: 未专用化的类 模板 不能用作 模板 变量,该变量属于 模板 参数“_IIID”,应为 real 类型
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2955: “_com_IIID”: 使用类 模板 需要 模板 参数列表
1> d:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : 参见“_com_IIID”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C2786: “BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)”: __uuidof 的操作数无效
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C2923: “_com_IIID”:“Arc”不是参数“<未知>”的有效 <未知> 类型变量
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(2914) : 参见“Arc”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C3203: “_com_IIID”: 未专用化的类 模板 不能用作 模板 变量,该变量属于 模板 参数“_IIID”,应为 real 类型
1>e:\成套所\网络平台\exceltest\exceltest\debug\excel.tlh(1677) : error C2955: “_com_IIID”: 使用类 模板 需要 模板 参数列表
1> d:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : 参见“_com_IIID”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1684) : error C2371: “PicturePtr”: 重定义;不同的基类型
1> d:\program files\microsoft visual studio 9.0\vc\include\comdef.h(328) : 参见“PicturePtr”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(2220) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2262) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2364) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C2146: 语法错误 : 缺少“;”(在标识符“GetRGB”的前面)
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : warning C4183: “GetRGB”: 缺少返回类型;假定为返回“int”的成员函数
1>e:\exceltest\exceltest\debug\excel.tlh(2387) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2409) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2411) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2434) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2571) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2610) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2693) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C2146: 语法错误 : 缺少“;”(在标识符“Crop”的前面)
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2745) : error C2146: 语法错误 : 缺少“;”(在标识符“GetTransparencyColor”的前面)
但还是遇到了很多问题,我按照教程中的方式导入类型库、和相应的类,然后在C**Dlg.h中添加
相应头文件,并定义对象。在没有进行下一步操作时进行编译就会出现大量错误,请高手指导一下
不胜感激!
一共有460个错误,70个警告,下面列出一部分作为参考
exceltest.cpp
1>e:\exceltest\exceltest\debug\excel.tlh(1595) : error C2371: “FontPtr”: 重定义;不同的基类型
1> d:\program files\microsoft visual studio 9.0\vc\include\comdef.h(314) : 参见“FontPtr”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2786: “BOOL (__stdcall *)(HDC,int,int,int,int)”: __uuidof 的操作数无效
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2923: “_com_IIID”:“Rectangle”不是参数“<未知>”的有效 <未知> 类型变量
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(3667) : 参见“Rectangle”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C3203: “_com_IIID”: 未专用化的类 模板 不能用作 模板 变量,该变量属于 模板 参数“_IIID”,应为 real 类型
1>e:\exceltest\exceltest\debug\excel.tlh(1673) : error C2955: “_com_IIID”: 使用类 模板 需要 模板 参数列表
1> d:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : 参见“_com_IIID”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C2786: “BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)”: __uuidof 的操作数无效
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C2923: “_com_IIID”:“Arc”不是参数“<未知>”的有效 <未知> 类型变量
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(2914) : 参见“Arc”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1677) : error C3203: “_com_IIID”: 未专用化的类 模板 不能用作 模板 变量,该变量属于 模板 参数“_IIID”,应为 real 类型
1>e:\成套所\网络平台\exceltest\exceltest\debug\excel.tlh(1677) : error C2955: “_com_IIID”: 使用类 模板 需要 模板 参数列表
1> d:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : 参见“_com_IIID”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(1684) : error C2371: “PicturePtr”: 重定义;不同的基类型
1> d:\program files\microsoft visual studio 9.0\vc\include\comdef.h(328) : 参见“PicturePtr”的声明
1>e:\exceltest\exceltest\debug\excel.tlh(2220) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2262) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2364) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C2146: 语法错误 : 缺少“;”(在标识符“GetRGB”的前面)
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2385) : warning C4183: “GetRGB”: 缺少返回类型;假定为返回“int”的成员函数
1>e:\exceltest\exceltest\debug\excel.tlh(2387) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2409) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2411) : error C2061: 语法错误 : 标识符“MsoRGBType”
1>e:\exceltest\exceltest\debug\excel.tlh(2434) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2571) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2610) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2693) : error C2504: “_IMsoDispObj”: 未定义基类
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C2146: 语法错误 : 缺少“;”(在标识符“Crop”的前面)
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2713) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>e:\exceltest\exceltest\debug\excel.tlh(2745) : error C2146: 语法错误 : 缺少“;”(在标识符“GetTransparencyColor”的前面)
解决方案 »
- 右键单击listctrl弹出菜单时,如何让listctrl不失去焦点?
- CFileDialog与CFile使用后,再用CFile::Open文件,一直失败
- CDialog::OnInitDialog();做了哪些事情?可以在我下面几行代码中删除吗
- c调用对话框
- 为什么迅雷 就能把他的 xunleiBHO_now.dll 注入到Explorer .exe 里面
- 'Debug/Geos.pch': No such file or directory,这个问题怎么解决?
- 如何制作Window汉字库?
- hook隐藏窗口的问题
- 请教消息传递问题---
- 在线程中运行ACE, 为什么handle_timeout不响应
- 关于结构体赋值与结构体解析
- MFC中怎么将文本文件中的按字符串将0读出来然后转换为正确的数字?
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename ("EOF", "adoEOF")
头文件里:
namespace EXCEL
class ExcelClass
{
}
CPP文件里:
using namespace EXCEL
这样,想使用这个类里的变量或类时,就EXCEL.类.变量名(也有可能是EXCEL::类.变量名,忘了,你可以查下命名空间的用法),把有关EXCEL的类文件改完后,你就可以在以后的工程里使用了,
#import "C:\Program Files\Common Files\microsoft shared\OFFICE14\MSO.DLL"rename("RGB", "MSORGB")rename("IAccessible","ExcelIAccessible")rename("_IMsoOleAccDispObj","Excel_IMsoOleAccDispObj")rename("CommandBar","ExcelCommandBar")rename("CommandBarControl","ExcelCommandBarControl")
using namespace Office;
#import "C:\Program Files\Common Files\microsoft shared\VBA\VBA6\VBE6EXT.OLB"
using namespace VBIDE;
#import "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE" rename("DialogBox", "ExcelDialogBox")rename("RGB", "ExcelRGB")rename("CopyFile", "ExcelCopyFile")rename("ReplaceText", "ExcelReplaceText")其实就是根据编译错误将所有出现冲突的地方都进行rename就好了