604
社区成员
发帖
与我相关
我的任务
分享
// 先将列名写入Excel表格
for(int j=0; j<dbg->Columns->Count; j++)
{
// 标题行的行高
vExcelApp.OlePropertyGet("Rows", 1).OlePropertySet("RowHeight", 20);
//
vSheet.OlePropertyGet("Cells", 1, j + 1)
.OlePropertySet("Value",
dbg->Columns->Items[j]->FieldName.c_str());
// 设置列名单元格的背景色
Variant vInter = vSheet.OlePropertyGet(
"Cells", 1, j + 1).OlePropertyGet("Interior");
vInter.OlePropertySet("ColorIndex", 15); // 灰色
vInter.OlePropertySet("Pattern", 1); // xlSolid
vInter.OlePropertySet("PatternColorIndex", -4105); // xlAutomatic
}
把这个dbg->Columns->Items[j]->FieldName.c_str()修改成你要的字段不就可以了