Input matrix of strings

Sep 23, 2014 at 12:12 PM
How can I input a matrix of strings? Obviously FP doesn't work as it is an array of double
Coordinator
Sep 23, 2014 at 12:58 PM
Use LPOPERX
Sep 23, 2014 at 12:59 PM
since you've mentioned LPOPERX, what is the difference between LPOPERX and LPOPER? when should I use which?
Coordinator
Sep 23, 2014 at 1:32 PM
It is either LPOPER or LPOPER12 depending of whether or not EXCEL12 is defined.
Sep 23, 2014 at 2:16 PM
Edited Sep 23, 2014 at 2:23 PM
I was able to convert input from OPER to map, but I can't convert from map to OPER for the output. Any suggestions?
void MapToOper(const std::map<std::string, std::string> &source, OPER &xloDest) {

    size_t i = 0;

    for (std::map<std::string, std::string>::const_iterator it = source.begin(); it != source.end(); it++) {
        xloDest(i, 0) = it->first;
        xloDest(i, 1) = it->second;
        i++;
    }
}
I guess I'm putting the values in the OPER in the wrong place or the wrong way..
Coordinator
Sep 23, 2014 at 2:55 PM
Did you resize the OPER to source.size() by 2?
Sep 23, 2014 at 3:17 PM
Edited Sep 23, 2014 at 3:20 PM
yes, added after i posted
xloDest.xltype = xltypeMulti|xlbitDLLFree;
    xloDest.val.array.rows = source.size();
    xloDest.val.array.columns = 2;
i get error at xloDest(i, 0) = it->first;
no operator matching these operands
no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion)
Coordinator
Sep 23, 2014 at 3:37 PM
No, you need to xloDest.resize(source.size(),2).
Also, you need to call .c_str() on the strings in the assignment.

Before posting, please spent a minute thinking about whether or not you are providing enough information to solve your problem.
Sep 23, 2014 at 3:45 PM
it works, thank you very much. Here's the final solution, in case anybody else needs it
void MapToOper(const std::map<std::string, std::string> &source, OPER &xloDest) {

    xloDest.resize(source.size(),2);

    size_t i = 0;

    for (std::map<std::string, std::string>::const_iterator it = source.begin(); it != source.end(); it++) {
        xloDest(i, 0) = it->first.c_str();
        xloDest(i, 1) = it->second.c_str();
        i++;
    }
}