delphi5中如何控制excel97表格的每列列宽和网格线?(100分)

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

7030

Unregistered / Unconfirmed
GUEST, unregistred user!
打印报表时我想使用delphi5的server组件扳中的OFFICE控件,但不知道如何
控制每一列的列宽(每列列宽各不相等),以及如何设置网格线,请各位高手帮忙!
 
Excelobj.range('A:A').width:=...
大概如此。
总之你可先在excel中试一下设宽度等,并记录宏,然后好好看一下记录下的语句。
在Delphi中套用就行,大致是一样的,只不过注意一下语法的区别。
 
Const
xlDiagonalDown = 5;
xlDiagonalUp = 6;
xlEdgeLeft = 7;
xlEdgeRight = 10;
xlEdgeTop = 8;
xlEdgeBottom = 9;
xlInsideHorizontal = 12;
xlInsideVertical = 11;
xlNone = -4142 ;
xlContinuous = 1;
XLCENTER=-4108;
var
reportfrm: Treportfrm;
typef:smallint;
msexcel:olevariant;
wbook,wsheet:olevariant;
procedure createexcel
begin
MsExcel:= CreateOleObject('Excel.Application');
WBook:=MsExcel.Application;
WBook.Visible:= True;
wbook.workbooks.Open(ExtractFileDir(paramstr(0))+'/bao11.xls');
WSheet:=WBook.ActiveSheet;
WSheet.PageSetup.PrintTitleRows:='$1:$3';
wsheet.pagesetup.leftFooter :='填报单位:测井公司供应站';
wsheet.pagesetup.rightFooter :='第'+'&P'+'页';
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;
 
接受答案了.
 
后退
顶部