请各位高手围观,小弟遇到难题了,抓狂!
小弟昨天从论坛里面找到了的C++ Builder操作Excel 的帖子,今天应用它并把数据库的数据存入Excel中,早上还运行得好好的,但是下午编译的时候出错了,我仔细看过了,程序代码没有什么错误,就是接口出错了····
请哪位大哥指点小弟,走出迷途,感激不尽!
这是编译的时候出现的错误:
[C++ Error] ComCtrls.hpp(2638): E2015 Ambiguity between 'Windows' and 'Excel_2k::Windows'
[C++ Error] ComCtrls.hpp(2839): E2015 Ambiguity between 'Windows' and 'Excel_2k::Windows'
[C++ Error] ComCtrls.hpp(3430): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3431): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3435): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3477): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3577): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3640): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3641): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3652): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3657): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3699): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(3706): E2015 Ambiguity between 'Menus' and 'Excel_2k::Menus'
[C++ Error] ComCtrls.hpp(4140): E2015 Ambiguity between 'Windows' and 'Excel_2k::Windows'
[C++ Error] ComCtrls.hpp(4259): E2015 Ambiguity between 'Windows' and 'Excel_2k::Windows'
[C++ Error] ComCtrls.hpp(4429): E2015 Ambiguity between 'Windows' and 'Excel_2k::Windows'
老是编译不通过,小弟真是抓狂······
[解决办法]
说是头文件注意先后顺序
#include <ComCtrls.hpp>
#include <Excel_2K_SRVR.h>
[解决办法]
--头文件#ifndef Unit1H#define Unit1H//---------------------------------------#include <Classes.hpp>#include <Controls.hpp>#include <StdCtrls.hpp>#include <Forms.hpp>#include "Excel_2K_SRVR.h"#include <OleServer.hpp>----cpp文件#include <vcl.h>#pragma hdrstop#include "Unit1.h"//---------------------------------------#pragma package(smart_init)#pragma link "Excel_2K_SRVR"#pragma resource "*.dfm"
[解决办法]
既然是用OLE代码来操作Office, 包含Excel_2K_SRVR.h头文件纯属多余,就里面的那几个Office常量,直接用数字来代替即可。
[解决办法]
定义这四个常量
const xlNone = 0xFFFFEFD2;
const xlContinuous = 1;
const xlThin = 2;
const xlAutomatic = 0xFFFFEFF7;
然后将 #include "Excel_2K_SRVR.h" 这一行删掉即可,可以加快编译速度。
[解决办法]
恩,顶楼上,顶楼上的楼上的楼上;
我之前也遇到这样的问题,把头文件的位置更改了之后貌似就好了,你试试