熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> ASP編程 >> 正文

Asp.net水晶報表之打印和導出格式

2022-06-13   來源: ASP編程 

  在ASPNET中水晶報表沒有象在Windows Form中那樣提供報表的導出和打印功能需要我們自己動手添加代碼來控制下面給個DEMO

  導出

  myReport ReportDoc = new myReport();//表表的名稱

  private void btnExport_Click(object sender SystemEventArgs e)

  {

  CrystalDecisionsSharedDiskFileDestinationOptions DiskOpts = new CrystalDecisionsSharedDiskFileDestinationOptions();

  ReportDocExportOptionsExportDestinationType = CrystalDecisionsSharedExportDestinationTypeDiskFile;

  switch (DropDownListSelectedItemText)

  {

  case Rich Text (RTF):

  ReportDocExportOptionsExportFormatType = CrystalDecisionsSharedExportFormatTypeRichText;

  DiskOptsDiskFileName = d:\\demortf;

  break;

  case Portable Document (PDF):

  ReportDocExportOptionsExportFormatType = CrystalDecisionsSharedExportFormatTypePortableDocFormat;

  DiskOptsDiskFileName = d:\\demopdf;

  break;

  case MS Word (DOC):

  ReportDocExportOptionsExportFormatType = CrystalDecisionsSharedExportFormatTypeWordForWindows;

  DiskOptsDiskFileName = d:\\demodoc;

  break;

  case MS Excel (XLS):

  ReportDocExportOptionsExportFormatType = CrystalDecisionsSharedExportFormatTypeExcel;

  DiskOptsDiskFileName = d:\\demoxls;

  break;

  default:

  break;

  }

  ReportDocExportOptionsDestinationOptions = DiskOpts;

  ReportDocExport();

  }

  打印

  private void btnPrint_Click(object sender SystemEventArgs e)

  {

  string strPrinterName; // 指定打印機名稱

  strPrinterName = @Canon BubbleJet BJCSP;

  PageMargins margins;// 設置打印頁邊距

  margins = ReportDocPrintOptionsPageMargins;

  marginsbottomMargin = ;

  marginsleftMargin = ;

  marginsrightMargin = ;

  marginstopMargin = ;

  ReportDocPrintOptionsApplyPageMargins(margins);

  ReportDocPrintOptionsPrinterName = strPrinterName;//應用打印機名稱

  // 打印報表startPageN 和 endPageN

  // 參數設置為 表示打印所有頁

  ReportDocPrintToPrinter( false);

  }


From:http://tw.wingwit.com/Article/program/ASP/201311/21850.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.