Const
xlDiagonalDown = 5;
xlDiagonalUp = 6;
xlEdgeLeft = 7;
xlEdgeRight = 10;
xlEdgeTop = 8;
xlEdgeBottom = 9;
xlInsideHorizontal = 12;
xlInsideVertical = 11;
xlNone = -4142 ;
xlContinuous = 1;
XLCENTER=-4108;
var
msexcel
levariant;
wbook,wsheet
levariant;
MsExcel:= CreateOleObject('Excel.Application');
WBook:=MsExcel.Application;
WBook.Visible:= True;
wbook.workbooks.Open(ExtractFileDir(paramstr(0))+'/bao4.xls');
WSheet:=WBook.ActiveSheet;
1.
procedure setgridline(startline, endline: integer;endclomn: string);
begin
wsheet:=wbook.activesheet;
WSHEEt.PageSetup.PrintGridlines:=False;
WSHEEt.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlDiagonalDown].LineStyle:= xlNone;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlDiagonalUp].LineStyle:=xlNone;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeTop].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlEdgeRight].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlInsideVertical].LineStyle:=xlContinuous;
WSHEET.Range['A'+inttostr(startline)+':'+endclomn+inttostr(endline)].Borders[xlInsideHorizontal].LineStyle:=xlContinuous;
end;
2,3.
WSheet.PageSetup.PrintTitleRows:='$1:$4';
wsheet.pagesetup.rightFooter :='第'+'&P'+'页';
WSHEET.RANGE['A3:A4'].MergeCells:=TRUE;
wsheet.RANGE['A3:A4'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['E3:E4'].MergeCells:=TRUE;
wsheet.RANGE['E3:E4'].VerticalAlignment:=XLCENTER;//垂直排列方式
WSHEET.RANGE['S3:S4'].MergeCells:=TRUE;
wsheet.RANGE['S3:S4'].VerticalAlignment:=XLCENTER;