Const
xlDiagonalDown = 5;
xlDiagonalUp = 6;
xlEdgeLeft = 7;
xlEdgeRight = 10;
xlEdgeTop = 8;
xlEdgeBottom = 9;
xlInsideHorizontal = 12;
xlInsideVertical = 11;
xlNone = -4142 ;
xlContinuous = 1;
XLCENTER=-4108;
procedure Treportfrm.formatexcelheader(const kind :integer);
var
year,month,day:word;
begin
WSHEET.RANGE['A1:T1'].MergeCells:=TRUE;
wsheet.RANGE['A1:t1'].horizontalAlignment:=XLCENTER;
WSHEET.RANGE['A3:A5'].MergeCells:=TRUE;
wsheet.RANGE['A3:A5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['B3:B5'].MergeCells:=TRUE;
wsheet.RANGE['B3:B5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['C3:C5'].MergeCells:=TRUE;
wsheet.RANGE['C3:C5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['D4
5'].MergeCells:=TRUE;
wsheet.RANGE['D4
5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['E4:E5'].MergeCells:=TRUE;
wsheet.RANGE['E4:E5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['F4:F5'].MergeCells:=TRUE;
wsheet.RANGE['F4:F5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['M4:M5'].MergeCells:=TRUE;
wsheet.RANGE['M4:M5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['N4:N5'].MergeCells:=TRUE;
wsheet.RANGE['N4:N5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['R4:R5'].MergeCells:=TRUE;
wsheet.RANGE['R4:R5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['S4:S5'].MergeCells:=TRUE;
wsheet.RANGE['S4:S5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['T3:T5'].MergeCells:=TRUE;
wsheet.RANGE['T3:T5'].VerticalAlignment:=XLCENTER;
WSHEET.RANGE['A2:T2'].MergeCells:=TRUE;
WSHEET.CELLS[2,1]:='制表日期:'+datetostr(now);
decodedate(now,year,month,day);
if kind=0 then
WSHEET.CELLS[1,1]:=inttostr(month)+'月份库存材料分大类余额核算(月表)'
else
WSHEET.CELLS[1,1]:=inttostr(month)+'月份库存材料分大类余额核算(累表)';
WSheet.PageSetup.PrintTitleRows:='$1:$5';
wsheet.pagesetup.leftFooter :='填报单位:测井公司供应站';
wsheet.pagesetup.rightFooter :='第'+'&P'+'页';
WSHEET.PageSetup.PrintGridlines:=False;
WSHEEt.Range['A3:t69'].Borders[xlDiagonalDown].LineStyle:= xlNone;
WSHEET.Range['A3:t69'].Borders[xlDiagonalUp].LineStyle:=xlNone;
WSHEET.Range['A3:t69'].Borders[xlEdgeLeft].LineStyle:=xlContinuous;
WSHEET.Range['A3:t69'].Borders[xlEdgeTop].LineStyle:=xlContinuous;
WSHEET.Range['A3:t69'].Borders[xlEdgeBottom].LineStyle:=xlContinuous;
WSHEET.Range['A3:t69'].Borders[xlEdgeRight].LineStyle:=xlContinuous;
WSHEET.Range['A3:t69'].Borders[xlInsideVertical].LineStyle:=xlContinuous;
WSHEET.Range['A3:t69'].Borders[xlInsideHorizontal].LineStyle:=xlContinuous;
WSHEET.Rows['37:69'].RowHeight:=17;
end;
procedure Treportfrm.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;
procedure report;
begin
MsExcel:= CreateOleObject('Excel.Application');
WBook:=MsExcel.Application;
WBook.Visible:= True;
wbook.workbooks.Open(ExtractFileDir(paramstr(0))+'/bao2.xls');
WSheet:=WBook.ActiveSheet;
for i:=1 to 59do
for j:=1 to fieldcountdo
if fields[j-1].asstring<>'0' then
WSHEET.CELLS[i+5,j].VALUE:=fields[j-1].asstring
formatexcelheader(1);
end;