AX函数,将EXCEL列号转为列名

str 10 GetExcelColName( int i_col)
{
        int j;
        str 10 ret;
        int     v_div,v_mod;
        str 10  tmp1,tmp2;
        int i_col_ascii;
        ;
        i_col_ascii = i_col + 64;

        if(i_col>256)
            return ret;
        else
        {
            if( i_col>26)
            {
                v_div = i_col div 26;
                v_mod = i_col mod 26;

                if( v_mod==0)
                {
                    tmp1 = num2char( v_div + 64-1);
                    tmp2 = "Z";
                }
                else    {
                    tmp1 = num2char( v_div + 64);
                    tmp2 = num2char( v_mod+64 );
                }
                ret = tmp1+tmp2;
            }
            else
            {
                ret = num2char(i_col_ascii);
            }
        }
        return ret ;

}

 

posted @ 2016-07-06 14:41  szlailai  阅读(366)  评论(0编辑  收藏  举报