国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:11:06
字體:
來源:轉載
供稿:網友
  在asp.net中水晶報表沒有象在windows form中那樣提供報表的導出和打印功能,需要我們自己動手添加代碼來控制,下面給個demo:

  導出:
myreport  reportdoc = new myreport();//表表的名稱
private void btnexport_click(object sender, system.eventargs e)
  {
   crystaldecisions.shared.diskfiledestinationoptions diskopts = new  crystaldecisions.shared.diskfiledestinationoptions();
   reportdoc.exportoptions.exportdestinationtype = crystaldecisions.shared.exportdestinationtype.diskfile;
   switch (dropdownlist1.selecteditem.text)
   {
    case "rich text (rtf)":
       reportdoc.exportoptions.exportformattype =   crystaldecisions.shared.exportformattype.richtext;
       diskopts.diskfilename = "d://demo.rtf";
     break;
    case "portable document (pdf)":
       reportdoc.exportoptions.exportformattype =   crystaldecisions.shared.exportformattype.portabledocformat;
       diskopts.diskfilename = "d://demo.pdf";
     break;
    case "ms word (doc)":
       reportdoc.exportoptions.exportformattype =   crystaldecisions.shared.exportformattype.wordforwindows;
       diskopts.diskfilename = "d://demo.doc";
     break;
    case "ms excel (xls)":
       reportdoc.exportoptions.exportformattype =   crystaldecisions.shared.exportformattype.excel;
       diskopts.diskfilename = "d://demo.xls";
     break;
    default:
     break;
   }
   reportdoc.exportoptions.destinationoptions = diskopts;
    reportdoc.export();
  }

  打印:
private void btnprint_click(object sender, system.eventargs e)
  {
     string strprintername; // 指定打印機名稱     
   strprintername = @"canon bubble-jet bjc-210sp"; 
   pagemargins margins;  // 設置打印頁邊距
   margins = reportdoc.printoptions.pagemargins;
   margins.bottommargin = 250;
   margins.leftmargin = 350;
   margins.rightmargin = 350;
   margins.topmargin = 450;    
   reportdoc.printoptions.applypagemargins(margins);     
   reportdoc.printoptions.printername = strprintername;  //應用打印機名稱    
     // 打印報表.startpagen 和 endpagen
   // 參數設置為 0 表示打印所有頁。
   reportdoc.printtoprinter(1, false,0,0);     
   }
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 大化| 肃北| 淮阳县| 南岸区| 七台河市| 兴国县| 乳山市| 青阳县| 青田县| 镇赉县| 唐海县| 葵青区| 汝阳县| 霍林郭勒市| 金寨县| 怀安县| 阿瓦提县| 陆丰市| 东港市| 偃师市| 龙里县| 临武县| 板桥市| 太仓市| 东平县| 梁山县| 兖州市| 恩施市| 米易县| 三亚市| 莱芜市| 广宗县| 岳普湖县| 惠东县| 平度市| 高雄市| 延庆县| 嘉兴市| 昌江| 澳门| 紫云|