ActiveReports之导出excel

Posted 连先森

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于ActiveReports之导出excel的主要内容,如果未能解决你的问题,请参考以下文章

免费资源 | ActiveReports 报表控件发布多平台 Demo 代码集合

导出Excel之Epplus使用教程4(其他设置)

使用While循环导出Excel

ActiveReports之直接打印报表

Silverlight程序之:简单的Excel报表导出方法

php导出excel问题之解决