十万火急!!!(关于DELPHI5和EXCEL)(35分)

  • 主题发起人 主题发起人 7030
  • 开始时间 开始时间
7

7030

Unregistered / Unconfirmed
GUEST, unregistred user!
1.谁能告诉我怎么样在DELPHI中控制EXCEL97的网格线,使EXCEL启动时不
显示出(整张工作表的)网格线?
2.在DELPHI中控制EXCEL97单元格内容对齐方式(居中居左居右)
3.通过会么方法可合并单元格?
 
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:olevariant;
wbook,wsheet:olevariant;

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;
 
sorry
1.MsExcel.activewindow.diplaygridlines:=false;
 
接受答案了.
 
后退
顶部