• 水晶报表导出数据并实现打印



    要在里一个页面上进行操作


    ReportDocument rdocument = new ReportDocument();

        //公用打印方法
        ExportCrystalL ExCrystal = new ExportCrystalL();

        User u = new User();

        #region 加载页面
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //加载报表
                LoadReport();
            }
        }

        /// <summary>
        /// 加载报表
        /// </summary>
        private void LoadReport()
        {
            //设置报表的数据信息
            GetReportDataSource();
            string FilePath = Request.PhysicalApplicationPath + "temp\\";
            string FileName = "水晶报表练习" + DateTime.Now.ToShortDateString();

            //导出数据
            ExCrystal.Export(rdocument, FilePath, FileName, "xls");
        }

        /// <summary>
        /// 设置报表的数据信息
        /// </summary>
        private void GetReportDataSource()
        {
            //取得数据
            DataSet ds = u.GetData("");

            if (ds != null && ds.Tables[0].Rows.Count != 0)
            {
                //加载水晶报表的模板
                rdocument.Load(Server.MapPath("../Report/MyReport.rpt"));

                //设置报表的数据源
                rdocument.SetDataSource(ds.Tables[0]);
            }

            //绑定
            this.CrystalReportViewer1.ReportSource = rdocument;
            this.CrystalReportViewer1.DataBind();
        }
        #endregion

  • 相关阅读:
    改造vant日期选择
    css3元素垂直居中
    npm综合
    (转)网页加水印方法
    Mac下IDEA自带MAVEN插件的全局环境配置
    隐藏注册控件窗口
    High performance optimization and acceleration for randomWalk, deepwalk, node2vec (Python)
    How to add conda env into jupyter notebook installed by pip
    The Power of WordNet and How to Use It in Python
    背单词app测评,2018年
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763519.html
Copyright © 2020-2023  润新知