1. 程式人生 > >vs2013下, asp.net mvc5 使用和釋出rdlc報表的步驟 ,使用ef來獲取資料

vs2013下, asp.net mvc5 使用和釋出rdlc報表的步驟 ,使用ef來獲取資料

1.右鍵專案,新增 新建項-》資料-》資料集

2.使用sql語句建立資料集,儘量包含所有的欄位

3.右鍵專案 ,新增報表,設計報表,然後新增資料集

4.在controll中,

            LogisticsDbContext db = new LogisticsDbContext();


            var e = from p in db.instocks
。。。。。。
                    select new
                    {
。。。。。。


                    };
            
            byte[] renderedBytes;
            string mimeType;
            string path = Server.MapPath("~/Report/Report1.rdlc");
            renderedBytes = PublicHelper.PrintReport(path, e, out mimeType); //很多地方可以搜到類似的程式碼
            return File(renderedBytes, mimeType);

就可以了