/********************************************
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;
}
}