ReportDocument.PrintToPrinter 方法

將報表中指定的頁面列印到使用 PrintOptions.PrinterName 屬性所選取的印表機。如果沒有選擇印表機,將會使用報表中指定的預設印表機。

[Visual Basic]

Public Overrideable Sub PrintToPrinter( _
   ByVal nCopies As Integer, _
   ByVal collated As Boolean, _
   ByVal startPageN As Integer, _
   ByVal endPageN As Integer _
)

[C#]

public virtual void PrintToPrinter(
   int nCopies, 
   bool collated, 
   int startPageN, 
   int endPageN
);

參數

  • nCopies
    指出列印份數。

  • collated
    指出是否自動分頁。

  • startPageN
    指出要列印的第一頁。

  • endPageN
    指出要列印的最後一頁。

註解

若要列印所有頁數,請將 startPageN 和 endPageN 參數設為零。

範例

教學課程

下列範例設定報表的頁面邊界、選擇印表機和列印報表。

[VJ#]

      private void printReport2( String printerName )
      {
         PageMargins margins;

         margins = Report.get_PrintOptions().get_PageMargins();
         margins.bottomMargin = 350;
         margins.leftMargin = 350;
         margins.rightMargin = 350;
         margins.topMargin = 350;
         Report.get_PrintOptions().ApplyPageMargins( margins );

         Report.get_PrintOptions().set_PrinterName( printerName );

         Report.PrintToPrinter( 1, false, 0, 0 );
      }
[Visual Basic]

      Private Sub PrintReport(ByVal printerName As String)
         Dim margins As PageMargins

         margins = Report.PrintOptions.PageMargins
         margins.bottomMargin = 350
         margins.leftMargin = 350
         margins.rightMargin = 350
         margins.topMargin = 350
         Report.PrintOptions.ApplyPageMargins(margins)

         Report.PrintOptions.PrinterName = printerName

         Report.PrintToPrinter(1, False, 0, 0)
      End Sub 
[C++]

      void PrintReport(String* printerName)
      {
         PageMargins margins;

         margins = Report->PrintOptions->PageMargins;
         margins.bottomMargin = 350;
         margins.leftMargin = 350;
         margins.rightMargin = 350;
         margins.topMargin = 350;
         Report->PrintOptions->ApplyPageMargins(margins);

         Report->PrintOptions->PrinterName = printerName;

         Report->PrintToPrinter(1, false,0,0);
      };
[C#]

      private void PrintReport(string printerName)
      {
         PageMargins margins;

         margins = Report.PrintOptions.PageMargins;
         margins.bottomMargin = 350;
         margins.leftMargin = 350;
         margins.rightMargin = 350;
         margins.topMargin = 350;
         Report.PrintOptions.ApplyPageMargins(margins);

         Report.PrintOptions.PrinterName = printerName;

         Report.PrintToPrinter(1, false,0,0);
      } 

需求

命名空間 CrystalDecisions.CrystalReports.Engine

組件 CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

請參閱

ReportDocument 類別 | ReportDocument 成員 | CrystalDecisions.CrystalReports.Engine 命名空間

**

©2005 Business Objects SA All rights reserved

Business Objects SA
http://www.china.businessobjects.com/
支援的服務
http://www.china.businessobjects.com/BOindex/support/