Excel操作——单元格的字体和对齐方式

 
       字体的属性包括:名称,大小,颜色,颜色索引,加粗,倾斜,下划线等等。这里只说明前四个,后面的与前四个基本相同。
 
       获得名称,大小,颜色和颜色索引等四个属性。
     oCurCell.AttachDispatchm_oCurrRange.GetItem( COleVariant( (long)(i + 1)), COleVariant( (long)j ) ).pdispVal, TRUE );
 
     Font oFont;
     oFont = oCurCell.GetFont();
     VARIANT varName = oFont.GetName();
     VARIANT varSize = oFont.GetSize();
     VARIANT varColor = oFont.GetColor();
     VARIANT varColorIndex = oFont.GetColorIndex();
 
       获得水平和垂直对齐方式
     VARIANT varHor = oCurCell.GetHorizontalAlignment();
     VARIANT varVer = oCurCell.GetVerticalAlignment();
 
       设置名称,大小,颜色和颜色索引等四个属性
     oCurCell.AttachDispatchm_oCurrRange.GetItem( COleVariant( (long)(i + 1)), COleVariant( (long)j ) ).pdispVal, TRUE );
 
     Font oFont;
     oFont = oCurCell.GetFont();
     oFont.PutName( varName );
     oFont.PutSize( varSize );
     oFont.PutColor( varColor );
     oFont.PutColorIndex( varColorIndex );
 
       设置水平和垂直对齐方式
     oCurCell.PutHorizontalAlignment( varHor );
     oCurCell.PutVerticalAlignment( varVer );

你可能感兴趣的:(Excel)