回帖:漏了两个,赶紧补上
//@brief 设置单元格文本字体及字体颜色,fontColor有效时设置字体颜色,否则不设置字体颜色
void MSExcel::SetCellFont(QAxObject *pRange,const QFont& font,const QColor fontColor /* = QColor */)
{
#if defined(Q_OS_WIN)
if(NULL != pRange)
{
QAxObject *pFont = pRange->querySubObject("Font") ;
if(NULL == pFont)
return ;
pFont->dynamicCall("SetName(const QVariant&)",font.family()) ;
pFont->dynamicCall("SetSize(const QVariant&)",font.pointSize()) ;
if(font.bold())
pFont->dynamicCall("SetBold(const QVariant&)",font.weight()) ;
if(font.italic())
pFont->dynamicCall("SetItalic(const QVariant&)",font.italic()) ;
//下划线画不出来,为什么?
if(font.underline())
pFont->dynamicCall("SetUnderline(const QVariant&)",font.underline()) ;
if(font.strikeOut())
pFont->dynamicCall("SetStrikethrough",font.strikeOut()) ;
if(fontColor.isValid())
pFont->dynamicCall("SetColor(const QVariant&)",fontColor) ;
delete pFont ;
pFont = NULL ;
}
#endif
}
//@brief 设置单元格背景颜色
void MSExcel::SetCellBgColor(QAxObject *pRange,const QColor& clBg)
{
#if defined(Q_OS_WIN)
if(NULL != pRange && clBg.isValid())
{
QAxObject *pInterior = pRange->querySubObject("Interior") ;
if(NULL != pInterior)
{
pInterior->dynamicCall("SetColor(const QVariant&)",clBg) ;
delete pInterior ;
pInterior = NULL ;
}
}
#endif
}

