码迷,mamicode.com
首页 > 其他好文 > 详细

提供一段Excel获取Title的标题,类似于A、AA、AAA,我们操作Excel的时候通常根据次标题来获取一定的操作范围。

时间:2015-11-09 17:16:54      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

/********************************************
FormatExcelColumTitle
    Purpose
        Get excel title like "A","AA","AAB".. by the column index.
        we can use the string to specified single cell with the
        row number.
    Params
        strTitle - [out]which used to receive the title name.
        lColumn - [in]the specified column index.
    Return
        None
*********************************************/
void FormatExcelColumTitle(CString& strTitle, long lColumn )
{
    static bool bFirstFlag = true;

    if (bFirstFlag )
    {
        if (lColumn > 26 )
        {
            lColumn -= 26;
        }
    }
    bFirstFlag = false;
    long lColCountLeft = lColumn/26;
    if ( lColCountLeft > 0  )
    {
        FormatExcelColumTitle(strTitle, lColCountLeft);
        CString strTemp;
        strTemp.Format(_T("%c"),64+lColumn%27);
        strTitle += strTemp;
    }
    else
    {
        CString strTemp;
        strTemp.Format(_T("%c"),64+lColumn);
        strTitle += strTemp;
        bFirstFlag = true;
    }
}

 

提供一段Excel获取Title的标题,类似于A、AA、AAA,我们操作Excel的时候通常根据次标题来获取一定的操作范围。

标签:

原文地址:http://www.cnblogs.com/arronjeck/p/Format_Excel_Colum_Title.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!