创建一个OLE EXCEL对象,在EXCEL中用宏记录下合并单元格的操作,写到程序中即可。
var
XL,WorkBook, Sheet: Variant;
begin
XL:= CreateOleObject('Excel.Application');
WorkBook := Xl.WorkBooks.Add;
Sheet := WorkBook.WorkSheets[1];
//your code
OleExc.Free;
XL.DisplayAlerts:=false;
XL.QUIT;
XL:=unassigned;
Cell := Sheet .Cells[ 2,3];
Cell.Value :='value';
Sheet.Range("A1:B1").Select
With Sheet.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Sheet.Selection.Merge