zoukankan      html  css  js  c++  java
  • ActiveReports之导出excel

    前提概要参考:http://www.cnblogs.com/liandy0906/p/7936524.html

                DbContextBase db = new DbContextBase();
                var list = db.PurchaseOrderTBs.ToList();
                List<PurchaseOrderView> list2 = new List<PurchaseOrderView>();
                foreach (var item in list)
                {
                    list2.Add(new PurchaseOrderView()
                    {
                        OrderNo = item.OrderNo,
                        PickNum = item.PickNum,
                        ProductPrice = item.ProductPrice,
                        ProductAmount = item.ProductPrice * item.PickNum
                    });
                }
                ReportDataSource ReportDataSource = new ReportDataSource();
                ReportDataSource.Name = "DataSet1";
                ReportDataSource.Value = list2;
    
                ReportViewer rvDoc = new ReportViewer();
                rvDoc.LocalReport.ReportPath = Server.MapPath("~/Reports/Report2.rdlc");
                rvDoc.LocalReport.DataSources.Add(ReportDataSource);
                #region 导入excel
                Warning[] warnings;
                string[] streamids;
                string mimeType;
                string encoding;
                string extension;
    
                byte[] bytes = rvDoc.LocalReport.Render(
                   "Excel", null, out mimeType, out encoding,
                    out extension,
                   out streamids, out warnings);
    
                FileStream fs = new FileStream(@"c:output.xls",
                   FileMode.Create);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();
                #endregion
    View Code
  • 相关阅读:
    包装器
    高级new创建
    野性的呼唤 第三章
    SourceTree的基本使用
    SAP的春天回来么?
    dirname命令和basename命令
    一个简单的ETL脚本的内容
    轮子:读取config.ini文件
    sed基础语法
    hivesql之str_to_map函数
  • 原文地址:https://www.cnblogs.com/liandy0906/p/7965894.html
Copyright © 2011-2022 走看看