Question

I'm use Excel 2010 and the 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 (??). When xlValues array size is 10 it returns to Excel a #NUM error. What is the right way to return array to Excel?

P.S. I use such template this article http://blogs.msdn.com/b/andreww/archive/2007/12/09/building-an-excel-xll-in-c-c-with-vs-2008.aspx

Was it helpful?

Solution

You need to make xlValues static too. Using https://xll.codeplex.com will make your life easier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top