cspreadsheet,编译不通过

liyang2049 2008-05-06 03:45:15
想操作excel表格,环境是VS2005
添加了cspreadsheet头文件之后,编译不通过。
怎么搞的,是不是宽字符的原因阿?
迷惑

部分错误提示如下:
1>24Channel2Dlg.cpp
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(198) : warning C4244: '=' : conversion from 'INT_PTR' to 'short', possible loss of data
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(206) : warning C4244: '=' : conversion from 'INT_PTR' to 'short', possible loss of data
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(257) : error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [14]' to 'const wchar_t *'
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(310) : warning C4244: '=' : conversion from 'INT_PTR' to 'short', possible loss of data
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(342) : warning C4244: '=' : conversion from 'INT_PTR' to 'short', possible loss of data
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(352) : warning C4129: 'L' : unrecognized character escape sequence
1>c:\documents and settings\lenovo\my documents\visual studio 2005\projects\24channel2\24channel2\cspreadsheet.h(352) : error C2001: newline in constant
...全文
1002 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
royjuventus29 2012-08-27
  • 打赏
  • 举报
回复
想求一个在VS2005上没有错误的CSpreadSheet.h,看了您的帖子,想要一份可以吗?我的邮箱是:1214318641@qq.com
多谢!!!!!!!!!
a515461402 2012-07-04
  • 打赏
  • 举报
回复
太有用了,嘻嘻
zxkang 2011-03-24
  • 打赏
  • 举报
回复
小弟也遇到了这个问题,感谢你的帖子,问题解决了~~~
liyang2049 2008-05-09
  • 打赏
  • 举报
回复
问题解决!

首先解决UNICODE问题,全部添加L
----------

其次,
出现问题:
error C2664: 'SQLGetInstalledDriversW ' : cannot convert parameter 1 from 'char [2001] ' to 'LPWSTR '
SQLGetInstalledDrivers(szBuf,cbBufMax,& cbBufOut)
SQLGetInstalledDriversW的参数1需要宽字符,
修正它!

char szBuf[2001];
char *pszBuf = szBuf;
改为
wchar_t szBuf[2001];
wchar_t *pszBuf = szBuf;
+++++++++++++++++++++++
参考文献:
char转换成LPWSTR的小问题??
http://topic.csdn.net/u/20070422/17/80f22eb8-c0f2-4313-b191-e86b60ef2f5b.html

---------
再次,
出现问题:
error C2665: 'strstr' : none of the 2 overloads could convert all the argument types
把strstr改写成_tcsstr
+++++++++++++++++++++++
参考文献
今天很高兴,又解决了一个问题,感谢牛牛们
http://blog.csdn.net/ehfaafzv/archive/2006/09/20/1253120.aspx
++++++++++++++++++++++

同时会出现问题:
error C2665: 'strchr' : none of the 2 overloads could convert all the argument types
把strchr改写成wcschr
+++++++++++++++++++++++
参考文献
Unicode and find exceldriver
http://www.codeguru.com/forum/showthread.php?threadid=433263

over!
liyang2049 2008-05-09
  • 打赏
  • 举报
回复
另外,还有一个情况是,同样的cspreadsheet头文件,放在徐景周写的excel操作程序里,没有任何问题!

真的是看不出来,该怎么办~
liyang2049 2008-05-09
  • 打赏
  • 举报
回复
196 if (m_atempArray.GetSize() > m_dTotalColumns)
197 {
198 m_dTotalColumns = m_atempArray.GetSize();
199 }

206 m_dTotalColumns = FieldNames.GetSize();

257 m_stempSql.Format ("DROP TABLE %s", SheetName);

310 m_dTotalColumns = RowValues.GetSize();

if (RowValues.GetSize() > m_dTotalColumns)
{
342 m_dTotalColumns = RowValues.GetSize();
}

352 m_stempSql.Format(L"\"%s\L"%s", RowValues.GetAt(i), m_sSeparator);
菜牛 2008-05-06
  • 打赏
  • 举报
回复
是的,最好贴出那几行代码。
an_bachelor 2008-05-06
  • 打赏
  • 举报
回复
看錯誤的提示好像是
全部用_T("")形式並加上_UNICODE宏
或直接用L""看看

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧