【请问】VC2005读取Excel2003的有关问题
【请教】VC2005读取Excel2003的问题
VC2005+Excel2003
用网上提供的例子做了一下,运行后出现提示“没有安装Excel驱动”,请教高手是怎么回事?
//其他函数中调用GetExcelDriver();
OnRead()
{
// 检索是否安装有Excel驱动 "Microsoft Excel Driver (*.xls) "
sDriver = GetExcelDriver();
if (sDriver.IsEmpty())
{
// 没有发现Excel驱动
AfxMessageBox(_T( "没有安装Excel驱动! "));
return;
}
}
GetExcelDriver(void)
{
char szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
char *pszBuf = szBuf;
CString sDriver;
// Get the names of the installed drivers ( "odbcinst.h " has to be included )
if(!SQLGetInstalledDrivers(LPWSTR(szBuf),cbBufMax,& cbBufOut))
return _T( " ");
// Search for the driver...
do
{
if( strstr( pszBuf, "Excel " ) != 0 )
{
// Found !
sDriver = CString( pszBuf );
break;
}
pszBuf = strchr( pszBuf, '\0 ' ) + 1;
}
while( pszBuf[1] != '\0 ' );
return sDriver;
}
------解决方案--------------------
没遇到过这问题,学习!!
VC2005+Excel2003
用网上提供的例子做了一下,运行后出现提示“没有安装Excel驱动”,请教高手是怎么回事?
//其他函数中调用GetExcelDriver();
OnRead()
{
// 检索是否安装有Excel驱动 "Microsoft Excel Driver (*.xls) "
sDriver = GetExcelDriver();
if (sDriver.IsEmpty())
{
// 没有发现Excel驱动
AfxMessageBox(_T( "没有安装Excel驱动! "));
return;
}
}
GetExcelDriver(void)
{
char szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
char *pszBuf = szBuf;
CString sDriver;
// Get the names of the installed drivers ( "odbcinst.h " has to be included )
if(!SQLGetInstalledDrivers(LPWSTR(szBuf),cbBufMax,& cbBufOut))
return _T( " ");
// Search for the driver...
do
{
if( strstr( pszBuf, "Excel " ) != 0 )
{
// Found !
sDriver = CString( pszBuf );
break;
}
pszBuf = strchr( pszBuf, '\0 ' ) + 1;
}
while( pszBuf[1] != '\0 ' );
return sDriver;
}
------解决方案--------------------
没遇到过这问题,学习!!