简体   繁体   English

如何为excel创建一个xll?

[英]How to create a xll for excel?

I'm trying to create just a simple xll file but I can not I've followed the tutorial in the msdn site http://support.microsoft.com/kb/178474 But this tutorial is for Microsoft Excel 97 Developer's Kit, i just have the version 2007 an visual studio 2005, so this is maybe what cause the error: 我正在尝试创建一个简单的xll文件,但我不能遵循msdn网站http://support.microsoft.com/kb/178474中的教程但是本教程适用于Microsoft Excel 97 Developer's Kit,i只是2007版本的Visual Studio 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

The error messages that you have are not related to Excel or the Excel SDK. 您拥有的错误消息与Excel或Excel SDK无关。 The first 2 errors are due to your usage of AfxMessageBox (an MFC API) and the 3rd is because of parameter mismatch with the Win32 message box API. 前两个错误是由于您使用AfxMessageBox(一个MFC API)而第三个是因为参数与Win32消息框API不匹配。 These errors are caused because your project is an Unicode application (causing TCHAR to evaluate to wchar_t and macros such as MessageBox to evaluate to MessageBoxW as opposed to MessageBoxA). 导致这些错误的原因是您的项目是一个Unicode应用程序(导致TCHAR评估为wchar_t和宏,如MessageBox,以评估MessageBoxW而不是MessageBoxA)。 The simplest fix would be to change your application from Unicode to MBCS. 最简单的解决方法是将您的应用程序从Unicode更改为MBCS。

However - if I may make a suggestion - consider using Add-in express or ExcelDNA to create your UDF/RTDs. 但是 - 如果我可以提出建议 - 请考虑使用Add-in express或ExcelDNA来创建UDF / RTD。 I am guessing you are not very comfortable with Win32 C++ programming. 我猜你对Win32 C ++编程不太满意。 If that is the case you will face a lot of trouble creating UDFs/RTDs/Addins with plain C++ and the Excel SDK. 如果是这种情况,您将在使用普通C ++和Excel SDK创建UDF / RTD / Addins时遇到很多麻烦。

If instead you go with add-in express or excel dna - they take care of all the headaches of converting xlopers to intuitive .net types and other assorted plumbing, leaving you free to concentrate on your business logic. 相反,如果你选择加载快递或excel dna - 它们会解决将xlopers转换为直观.net类型和其他各种管道的所有麻烦,让您可以专注于业务逻辑。

Disclaimer: I am in no way associated with either add-in express or excel dna. 免责声明:我与加载快递或excel dna无关。 I have just happened to have used them on and off. 我刚好碰巧使用过它们。

如果你可以安装MSVC ++ 2010 Express,那么http://xll.codeplex.com会给你带来很多麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM