【发布时间】:2014-09-29 09:30:42
【问题描述】:
我在不同的解决方案中有 2 个 VS 项目。第一个是 dll,第二个是 xll,试图从第一个调用函数。虽然它编译没有错误,但 Excel 说
"The file you are trying to open, 'test.xll', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
如果我按下是,我会看到一堆类似中文的字母。如果我不从 dll 项目中调用该函数,则 xll 可以正常工作。我究竟做错了什么?使用 VS2010 和 Excel 2010 x86。
第一个是dll项目
square.cpp
double _stdcall square (double &x) {
return x * x;
}
square.h
#pragma once
__declspec(dllexport) double _stdcall square (double &x);
第二个项目是xll项目
static AddIn xai_exp(
"?xll_exp", XLL_DOUBLE XLL_DOUBLE,
"XLL.EXP", "Number"
);
double WINAPI xll_exp(double number) {
#pragma XLLEXPORT
return square(number);
}
当我使用 VBA 进行测试时,我还制作了一个 defFile,但我认为这里不需要它。
【问题讨论】:
-
我也遇到了同样的问题,你找到解决办法了吗?
-
是的,但那是前一段时间了,所以我真的不记得怎么做了。如果有什么想法我会告诉你的
标签: c++ excel visual-studio-2010 add-in xll