[英]Returning array in Excel XLL
I'm use Excel 2010 and the Excel 2010 XLL SDK. 我正在使用Excel 2010和Excel 2010 XLL SDK。 I try with this function:
我尝试使用此功能:
__declspec(dllexport) LPXLOPER12 WINAPI dfutil(void)
{
static XLOPER12 xlArray;
XLOPER12 xlValues[4];
int i;
double z = 3.1456;
for (i = 0; i < 4; ++i)
{
xlValues[i].val.num = i*z;
xlValues[i].xltype = xltypeNum;
}
xlArray.xltype = xltypeMulti;
xlArray.val.array.lparray = xlValues;//&xlValues[0];
xlArray.val.array.rows = 1;
xlArray.val.array.columns = 4;
return (LPXLOPER12) &xlArray;
}
Definition: 定义:
{
L"dfutil",
L"QU",
L"dfutil",
L"",
L"1",
L"SimpleXll2007",
L"",
L"",
L"ReturnArray function help",
L"",
L""
},
When xlValues
array size is 4 then returns to excel 4 values, but the 3rd value is TRUE (??). 当
xlValues
数组大小为4时,将返回excel 4值,但第3个值为TRUE(??)。 When xlValues
array size is 10 it returns to Excel a #NUM error. 当
xlValues
数组大小为10时,它将向Excel返回#NUM错误。 What is the right way to return array to Excel? 什么是将数组返回Excel的正确方法?
PS I use such template this article http://blogs.msdn.com/b/andreww/archive/2007/12/09/building-an-excel-xll-in-cc-with-vs-2008.aspx PS我使用这样的模板本文http://blogs.msdn.com/b/andreww/archive/2007/12/09/building-an-excel-xll-in-cc-with-vs-2008.aspx
You need to make xlValues static too. 您还需要使xlValues静态。 Using https://xll.codeplex.com will make your life easier.
使用https://xll.codeplex.com将使您的生活更轻松。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.