首页 > 其他 > 详细

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

时间:2015-11-09 17:13:53      阅读:268      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!