problem returning an array to Excel

Jan 9, 2013 at 6:33 PM
Edited Jan 9, 2013 at 6:35 PM

Hi, thank you for the library which makes very convenient coding the functions in Excel.

While trying to implement a simple test case of a calculator, using handles and cpp domain classes, all works except for ability to return an array with results.

Read several times through the FP page and ARRAY addin examples - still no intended result, getting "1.09327E+16" instead of 3 cells filled in - am I missing something obvious? The code is below:

Any help is much appreciated!



static AddInX xai_viewBasicStats(
	FunctionX(XLL_FP, _T("?xll_viewBasicStats"), _T("Calculator.viewBasicStats"))
	.Arg(XLL_HANDLEX, _T("Handle"), _T("is a handle to BasicStats object "))
	.FunctionHelp(_T("Displays the given BasicStats instance as a row"))
		_T("Calculator.viewBasicStats - Displays the given BasicStats instance as a row")

xll_viewBasicStats(HANDLEX h)
	static FPX output;
	try {
		handle<BasicStats> stats_(h);
		ensure (stats_);

		output.reshape(4, 1);
		ensure (output.size() >= 4);

		output[0] = stats_->getCount();
		output[1] = stats_->getAvg();
		output[2] = stats_->getSum();	
	catch (const std::exception& ex) {

	return output.get();