v: Variant;
Sheet: Variant; v:=CreateOleObject('Excel.Application');
v.Visible:=false;
v.WorkBooks.Open('G:\'+Query2.Fields[1].AsString);
sheet:=v.WorkBooks[1].WorkSheets[1];
sheet.PageSetup.PrintTitleColumns:='';
sheet.PageSetup.PrintArea:='';
sheet.PageSetup.LeftHeader:='';
sheet.PageSetup.CenterHeader:='';
sheet.PageSetup.RightHeader:='';
sheet.PageSetup.LeftFooter:='';
sheet.PageSetup.CenterFooter:='';
sheet.PageSetup.RightFooter:='';
sheet.PageSetup.PrintHeadings:=False;
sheet.PageSetup.PrintGridlines:=False;
sheet.PageSetup.PrintComments:=xlPrintNoComments;
sheet.PageSetup.CenterHorizontally:=False;
sheet.PageSetup.CenterVertically:=False;
sheet.PageSetup.Orientation:=xlPortrait;
sheet.PageSetup.Draft:=False;
sheet.PageSetup.PaperSize:=xlPaperA5;
sheet.PageSetup.FirstPageNumber:=xlAutomatic;
sheet.PageSetup.Order:=xlDownThenOver;
sheet.PageSetup.BlackAndWhite:=False;
sheet.PageSetup.Zoom:=100;
sheet.PageSetup.PrintErrors:=xlPrintErrorsDisplayed;
sheet.PageSetup.PrintArea:='$A$1:$E$90';
sheet.Range['A1:E90'].Select;//一直到这里都没问题
sheet.PrintPreview;//到这里就没响应了,我没写错吧?
大家帮我看看吧。
Sheet: Variant; v:=CreateOleObject('Excel.Application');
v.Visible:=false;
v.WorkBooks.Open('G:\'+Query2.Fields[1].AsString);
sheet:=v.WorkBooks[1].WorkSheets[1];
sheet.PageSetup.PrintTitleColumns:='';
sheet.PageSetup.PrintArea:='';
sheet.PageSetup.LeftHeader:='';
sheet.PageSetup.CenterHeader:='';
sheet.PageSetup.RightHeader:='';
sheet.PageSetup.LeftFooter:='';
sheet.PageSetup.CenterFooter:='';
sheet.PageSetup.RightFooter:='';
sheet.PageSetup.PrintHeadings:=False;
sheet.PageSetup.PrintGridlines:=False;
sheet.PageSetup.PrintComments:=xlPrintNoComments;
sheet.PageSetup.CenterHorizontally:=False;
sheet.PageSetup.CenterVertically:=False;
sheet.PageSetup.Orientation:=xlPortrait;
sheet.PageSetup.Draft:=False;
sheet.PageSetup.PaperSize:=xlPaperA5;
sheet.PageSetup.FirstPageNumber:=xlAutomatic;
sheet.PageSetup.Order:=xlDownThenOver;
sheet.PageSetup.BlackAndWhite:=False;
sheet.PageSetup.Zoom:=100;
sheet.PageSetup.PrintErrors:=xlPrintErrorsDisplayed;
sheet.PageSetup.PrintArea:='$A$1:$E$90';
sheet.Range['A1:E90'].Select;//一直到这里都没问题
sheet.PrintPreview;//到这里就没响应了,我没写错吧?
大家帮我看看吧。
我看不明白
//EXCEL打印页面设置
procedure ExcelPrintSet(const vLeftMargin, vRightMargin, vTopMargin, vBottomMargin: Double; vOrientation, vZoom: Integer;
vCenterVertically, vCenterHorizontally, vDraft, vBlackAndWhite, PrintPreView: Boolean; var ExcelSheet: Variant);
begin
try
ExcelSheet.PageSetup.PrintTitleRows :='$1:$3'; //页眉
ExcelSheet.PageSetup.PrintTitleColumns := '';
ExcelSheet.PageSetup.LeftFooter := ' 注:页脚'+' 总共&N页'+'--第&P页'; //页脚
ExcelSheet.PageSetup.LeftMargin := vLeftMargin; //设置边距
ExcelSheet.PageSetup.RightMargin := vRightMargin;
ExcelSheet.PageSetup.TopMargin := vTopMargin;
ExcelSheet.PageSetup.BottomMargin := vBottomMargin;
// ExcelSheet.PageSetup.PrintQuality := 400; //分辨率(根据打印机确定)
ExcelSheet.PageSetup.CenterHorizontally := vCenterVertically;//是否水平居中
ExcelSheet.PageSetup.CenterVertically := vCenterHorizontally; //是否垂直居中
ExcelSheet.PageSetup.Orientation := vOrientation; //横向打印
ExcelSheet.PageSetup.Draft := vDraft; //非草稿模式
// ExcelSheet.PageSetup.FirstPageNumber := xlAutomatic;
ExcelSheet.PageSetup.BlackAndWhite := vBlackAndWhite; //黑白稿
ExcelSheet.PageSetup.Zoom := vZoom; //缩放
if PrintPreView then
ExcelSheet.PrintPreView; //打印预览
except
end;
end;
我调用的
ExcelPrintSet(1.0 / 0.035, 1.0 / 0.035, 1.5 / 0.035, 2 / 0.035, 2, 100, False, False, False, true, false, ExcelSheet);
我试过了,但遇到ExcelSheet.PrintPreView; 这句就没响应了。
郁闷中......
WorkBook:=CreateOleObject('Excel.Sheet');WorkBook:=eclApp.WorkBooks.add;
eclApp.WorkBooks[1].WorkSheets[1].Range['C15'].NumberFormatLocal:='@';sheet:=eclApp.WorkBooks[1].WorkSheets[1];
sheet.Range['C:C'].Select;
sheet.Range['C:C'].HorizontalAlignment:=xlCenter;
sheet.Columns['C:C'].ColumnWidth:=31.25;
sheet.Columns['D:D'].ColumnWidth:=0;sheet.Range['C50:C59'].Select;
sheet.Range['C50:C59'].Font.Size:=22;sheet.Range['C58'].NumberFormatLocal:='0_ ';
sheet.Range['A68:C180'].NumberFormatLocal:='@';sheet.Rows['50:50'].RowHeight:=28.5;sheet.PageSetup.PrintArea:='$A$1:$E$90';
sheet.Range['A1:E90'].Select; sheet.PageSetup.PrintTitleColumns:='';
sheet.PageSetup.PrintArea:='';
sheet.PageSetup.LeftHeader:='';
sheet.PageSetup.CenterHeader:='';
sheet.PageSetup.RightHeader:='';
sheet.PageSetup.LeftFooter:='';
sheet.PageSetup.CenterFooter:='';
sheet.PageSetup.RightFooter:='';
sheet.PageSetup.LeftMargin:=sheet.Application.InchesToPoints(0.75);
sheet.PageSetup.RightMargin:=sheet.Application.InchesToPoints(0.75);
sheet.PageSetup.TopMargin:=sheet.Application.InchesToPoints(1);
sheet.PageSetup.BottomMargin:=sheet.Application.InchesToPoints(0);
sheet.PageSetup.HeaderMargin:=sheet.Application.InchesToPoints(0.5);
sheet.PageSetup.FooterMargin:=sheet.Application.InchesToPoints(0.5);
sheet.PageSetup.PrintHeadings:=False;
sheet.PageSetup.PrintGridlines:=False;
sheet.PageSetup.PrintComments:=xlPrintNoComments;
//sheet.PageSetup.PrintQuality:=400;
sheet.PageSetup.CenterHorizontally:=False;
sheet.PageSetup.CenterVertically:=False;
sheet.PageSetup.Orientation:=xlPortrait;
sheet.PageSetup.Draft:=False;
sheet.PageSetup.PaperSize:=xlPaperA5;
sheet.PageSetup.FirstPageNumber:=xlAutomatic;
sheet.PageSetup.Order:=xlDownThenOver;
sheet.PageSetup.BlackAndWhite:=False;
sheet.PageSetup.Zoom:=100;
sheet.PageSetup.PrintErrors:=xlPrintErrorsDisplayed; //sheet.PrintPreview;
Sheet.PrintOut;