2

我在单独的解决方案中有 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项目

正方形.cpp

double _stdcall square (double &x) {
    return x * x;
}

平方.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,但我认为这里不需要它。

4

1 回答 1

0

当在计算机上找不到 xll 使用的 dll 时,就会出现您描述的错误。因此,您必须确保您的 xll 可以访问该 dll。

于 2016-07-04T21:18:00.567 回答