码迷,mamicode.com
首页 > 其他好文 > 详细

ActiveReports之导出excel

时间:2017-12-03 13:51:33      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:技术分享   sed   导入   warnings   create   mode   lap   length   data   

前提概要参考: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

 

ActiveReports之导出excel

标签:技术分享   sed   导入   warnings   create   mode   lap   length   data   

原文地址:http://www.cnblogs.com/liandy0906/p/7965894.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!