//将数据导入 excel 表中 201010
//保存数据到 excel 文件中
…………………
SaveDialog1->FileName =s_ReportName+EDt.FormatString("yyyymmdd");
if(SaveDialog1->Execute())
{
AnsiString filenamex=SaveDialog1->FileName+".xls";
Variant Wb,Sh1;
Wb=CreateOleObject("Excel.Sheet");
int i=0;
AnsiString cc;
Sh1=Wb.OlePropertyGet("ActiveSheet");
//设置 1 行 1 列单元格属性
//设置字号为 18,粗体
Sh1.PG("Cells",1,1).PG("Font").PS("Size",18);
Sh1.PG("Cells",1,1).PG("Font").PS("Bold",true);
Sh1.PG("Cells",1,1).PG("Font").PS("Name","宋体");
//设置行高
Sh1.PG("Rows",1).PS("RowHeight",1.155/0.035); // 1/0.035=1cm
//合并单元格
Sh1.PG("Range", "A1:K1 ").PR("Merge");
//水平对齐 1:顶端对齐,2:居中, 3:底端对齐
Sh1.PG("Cells",1,1).PS("HorizontalAlignment",3);
//垂直对齐 2:左端对齐,3:居中, 4:右端对齐
Sh1.PG("Cells",1,1).PS("VerticalAlignment",2);
//设置 2 行 1 列单元格属性
//设置字号为 18,粗体
Sh1.PG("Cells",2,1).PG("Font").PS("Size",16);
Sh1.PG("Cells",2,1).PG("Font").PS("Bold",true);
Sh1.PG("Cells",2,1).PG("Font").PS("Name","宋体");
Sh1.PG("Rows",2).PS("RowHeight",1.155/0.035); // 1/0.035=1cm
Sh1.PG("Range", "A2:K2 ").PR("Merge");
Sh1.PG("Cells",2,1).PS("HorizontalAlignment",3);
Sh1.PG("Cells",2,1).PS("VerticalAlignment",2);
//设置 3 行 1 列单元格属性
Sh1.PG("Cells",3,1).PG("Font").PS("Size",10);
Sh1.PG("Cells",3,1).PG("Font").PS("Bold",true);
Sh1.PG("Cells",3,1).PG("Font").PS("Name","宋体");
Sh1.PG("Range", "A3:H3").PR("Merge");
//设置 3 行 9 列单元格属性
Sh1.PG("Cells",3,9).PG("Font").PS("Size",10);