xlladdins / xll

Excel add-in library
MIT License
104 stars 23 forks source link

xlAutoOpen implementing example need #1

Closed rentocika closed 3 years ago

rentocika commented 3 years ago

Hello! In previos version version of XLL for global xll purposes and data preparing for calcaluting (calc and fill some tables and structures ) I made following:

static int xll_open(void)
{
    static OPERX oGetName(Excel<XLOPERX>(xlGetName));
    #ifdef EXCEL12
        static std::wstring name_(oGetName.val.str + 1, oGetName.val.str[0]);
        size_t t = name_.find_last_of('\\');
        PathXLL = name_.substr(0, t + 1);
    #else
        static std::string name_(oGetName.val.str + 1, oGetName.val.str[0]);
        size_t t = name_.find_last_of('\\');
        PathXLL = name_.substr(0, t + 1);
    #endif
    DataStructuresPrepare();
   return 1; 
}
static Auto<OpenAfterX> xao_macro(xll_open);

How do the same in this new version? Thank you!

keithalewis commented 3 years ago
static int xll_open(void)
{
    static OPER oGetName(Excel(xlGetName));
    xll::traits<XLOPERX>::xstring name_(oGetName.val.str + 1, oGetName.val.str[0]);
    size_t t = name_.find_last_of('\\');
    PathXLL = name_.substr(0, t + 1);
    DataStructuresPrepare();
    return 1;
}
static Auto<OpenAfter> xao_macro(xll_open);