lpoper to string

Aug 15, 2012 at 3:17 PM

Hi,

may i i please get some help regarding this issue:

i have a function which takes in a lpoper input. "input" can be an array with string and doubles. I know that input[0][1] is a excel string (that is a string input in the excel cell).  

inside the c++ code i want to convert input[0][1] to a c++ string.

my code is the following:

static Addin test( "?xll_function", XLL_LPOPER XLL_LPOPER, "test.function", "Number", "example", "create example") 

LPOPER WINAPI xll_function(LPOPER input)

{

std::string st1=input[0][1].toString();

static OPER y = _T("test successful");

return &y;

}

I am not doing the first line correctly and i am getting a compilation error which i am not sure how to rectify.

Question is how do i convert a OPER to a c++ string. It would be very kind to help. I am using visual studio 2008 and excel sdk 2007.

pasting the error below: 

----------------------------

1>c:\excelxll\xll\xll\xloper.h(126) : error C3861: 'xstring': identifier not found

1> c:\excelxll\xll\xll\xoper.h(181) : see reference to function template instantiation 'xll::traits<XLOPER>::xstring xll::toStr<X>(const X &,xll::traits<XLOPER>::xcstr)' being compiled

1> with

1> [

1> X=XLOPER

1> ]

1> c:\excelxll\xll\xll\xoper.h(180) : while compiling class template member function 'std::basic_string<_Elem,_Traits,_Ax> XOPER<X>::toString(const char *) const'

1> with

1> [

1> _Elem=char,

1> _Traits=std::char_traits<char>,

1> _Ax=std::allocator<char>,

1> X=XLOPER

1> ]

1> c:\excelxll\xll\kaushikxll\policyrn.h(12) : see reference to class template instantiation 'XOPER<X>' being compiled

1> with

1> [

1> X=XLOPER

1> ]

 

Coordinator
Aug 16, 2012 at 7:23 PM

To convert an OPER o; with o.xltype == xltypeStr you can use std::string s(o.val.str + 1, o.val.str[0]).