使用外部DLL项目到Excel的c ++ / xll插件
我有两个VS项目在不同的解决scheme。 首先一个DLL,第二个尝试从第一个函数调用。 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进行testing时,我也做了一个defFile,但我不认为它在这里需要。
您正在描述的错误显示当您的xll使用的dll在计算机上找不到。 所以你必须确保dll可以被你的xll访问。