zoukankan      html  css  js  c++  java
  • C#(99):微软报表编程

    一、加载报表文件

    1、加载本地RDlC文件:

    LocalReport localReport =this.reportViewer1.LocalReport ; //或new LocalReport () 创建我获取LocalReport 对象。
    LocalReport ReportEmbeddResource=”Salary.Report.test.rdlc”;  //报表路经(嵌入式资源到EXE)
    //或 LocalReport.ReportPath=”test.rdlc” ;

    2、加载服务器报表

    reportViewer1.ProcessMode=frerertones.Remote;
    reportViewer1.ServerReport.ReportServerUrl=new Uri(”http://localhost.reportServer”);
    reportViewer1.ServerReport.ReportPath=new Uri(”/Domo/test”);


    二、报表数据源

    string sourerName= localReport .GetDataSourceNames()[0]:
    ReportDataSource reportdataSource =new ReportDataSource (sourerName, ds.Tables[0]);
    localReport .DataSources.Clear();
    localReport .DataSources.Add (reportdataSource );

    sourerName为数据集的名称,eg、DataSet1。也可以为Datatable,其中的列名与报表中的字段需一致。也可以为IEnumeable类型,元素的公共属性的名字应与报表中定义的数据源字段名匹配。

    eg:生成解决方可见。

    List<a> list=new List<a>();
    list.Add(new a(“1",“2”));
    list.Add(new a(“3",“4”));

    三、报表参数

    string paraName =localReport.GetParameters()[0].Name;
    ReportParameter p=new ReportParameter(paraName,”a”);
    localReport.SetParameters (new ReportParameter[]{p});

    四、填充教据,刷新展示数的数据

    da.Fill(ds.Tables[0]);
    localReport.Refresh();
    the.reportViewer1.RefreshReports();

    五、导出到DPF

    sring devInof =”<DeviceInfo><Table>…”;
    string miniType,encoding,filenameExt;
    stirng[] streams;Waring[] warning;
    byte[] bytes=localReport.Render(“PDF”,devinfo,out ..);
    File.WriteAllBytes(“file.pdf”,bytes);

    或下载

    Response.clear();
    Response.ContentType=mimType;
    Response.AddHeader(“Content-Dispoiton”,”attachment;filename=aa.pdf”);
    Response.BinaryWirte(data);

    六、打印

    this.reportViewer1.PrintDialog();
    RsClientRrint控件

  • 相关阅读:
    C# 如何得到局域网中的计算机名?
    设计模式之Factory(转帖)[学习用]
    byte类型特殊的地方
    原码、反码和补码
    由Public key生成Public key token
    .Net位运算符&,|,!,^,<<,>>
    强命名程序集,签名,延迟签名
    把16进制字符转换成byte数组
    SHA1哈希算法
    .NET工具篇(四)—SN.EXE
  • 原文地址:https://www.cnblogs.com/springsnow/p/9433973.html
Copyright © 2011-2022 走看看