ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

c – 如何为excel创建xll?

2019-09-03 11:08:12  阅读:334  来源: 互联网

标签:c xll


我正在尝试创建一个简单的xll文件,但我不能
我已经按照msdn网站上的教程进行了操作
http://support.microsoft.com/kb/178474
但本教程适用于Microsoft Excel 97 Developer’s Kit,我只有2007版本
视觉工作室2005,所以这可能是导致错误的原因:

1>------ Build started: Project: Anewxll, Configuration: Debug Win32 ------
1>Compiling...
1>Anewxll.cpp
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(97) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1>        c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5031): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1>        c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5033): or 'int AfxMessageBox(UINT,UINT,UINT)'
1>        while trying to match the argument list '(const char [21], long)'
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(140) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1>        c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5031): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1>        c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5033): or 'int AfxMessageBox(UINT,UINT,UINT)'
1>        while trying to match the argument list '(char [8192], long)'
1>c:\nam\test\anewxll\anewxll\anewxll.cpp(174) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

解决方法:

您拥有的错误消息与Excel或Excel SDK无关.前两个错误是由于您使用AfxMessageBox(一个MFC API)而第三个是因为参数与Win32消息框API不匹配.导致这些错误的原因是您的项目是一个Unicode应用程序(导致TCHAR评估为wchar_t和宏,如MessageBox,以评估MessageBoxW而不是MessageBoxA).最简单的解决方法是将您的应用程序从Unicode更改为MBCS.

但是 – 如果我可以提出建议 – 请考虑使用Add-in express或ExcelDNA来创建UDF / RTD.我猜你对Win32 C编程不太满意.如果是这种情况,您将在使用普通C和Excel SDK创建UDF / RTD / Addins时遇到很多麻烦.

相反,如果你选择加载快递或excel dna – 它们会解决将xlopers转换为直观.net类型和其他各种管道的所有麻烦,让您可以专注于业务逻辑.

免责声明:我与加载快递或excel dna无关.我刚好碰巧使用过它们.

标签:c,xll
来源: https://codeday.me/bug/20190903/1797739.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有