问题
I wrote a very simple xll file in VC++ 2010, and the Excel I am using is Excel 2007. The library contains only one function:
extern "C" LPXLOPER12 WINAPI tsMkErr() {
static XLOPER12 x;
x.xltype = xltypeErr;
x.val.err = xlerrNull;
return &x;
}
and the necessary xlAutoOpen function. I compiled and dll file, change the name to xll, and double click it to open in Excel. Everything works just as I expected.
However, if I am trying to open this file on another PC, the Excel just keeps telling me that:
The file you are trying to open, '.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?
When I click yes, garbage pops out.
I also tried to load it via Add-in Manager. In this case I can open the file, but cannot find my function tsMkErr().
I would be grateful to all suggestions ...
btw, I don't really know how to choose a reply as an answer. If you know how to do it, please also let me know :)
... I am going to publish my tool this week ... now I just realized it only works on my PC ... please help ... T_T
回答1:
Do yourself a favor and use http://xll.codeplex.com.
回答2:
The main reasons are :
you try to open an xll with a wrong architecture (ex : 32 bit xll with excel 64 bits )
some externals dll are missing.(see Dependency Walker tool) Note that if you are building in debug mode and try to open it via visual studio, in this case your environment path variable may be not available and the xll is missing some dlls.
回答3:
The possible reason could be missing dependencies (crt dlls, etc.). You can check by using Dependency Walker tool.
回答4:
It seems like you're building the solution in debug mode. If you build a solution in debug mode, visual studio links the xll with the debug library which is rarely installed on another computer. Therefore make sure you set the build configuration to release and it should work on other computers (if they have the normal ms c++ redistributable library installed).
来源:https://stackoverflow.com/questions/14760755/addin-xll-is-in-a-different-format-issue-cannot-open-the-xll-i-created-by-mys