首页 新闻 搜索 专区 学院

在 asp.net MVC 4.0中使用rdlc,求详细的代码,试网上的代码试吐了,也没有搞出来,我给高分

0
悬赏园豆:100 [已解决问题] 解决于 2015-05-15 09:48

在 asp.net MVC 4.0中使用rdlc,求详细的代码,试网上的代码试吐了,也没有搞出来,我给高分

小小高的主页 小小高 | 小虾三级 | 园豆:820
提问于:2015-05-12 17:17
< >
分享
最佳答案
0

public ActionResult Index()
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath(@"~/Report/myDataSet.rdlc");

            ReportDataSource reportDataSource = new ReportDataSource("MyDataSet", new FS_NEWEntities().T_Login.ToList());



            localReport.DataSources.Add(reportDataSource);

            string reportType = "PDF";

            string mimeType = "application/pdf ";

            string encoding;

            string fileNameExtension;



            //The DeviceInfo settings should be changed based on the reportType

            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx

            string deviceInfo =

            "<DeviceInfo>" +

            "  <OutputFormat>PDF</OutputFormat>" +

            "  <PageWidth>8.5in</PageWidth>" +

            "  <PageHeight>11in</PageHeight>" +

            "  <MarginTop>0.5in</MarginTop>" +

            "  <MarginLeft>1in</MarginLeft>" +

            "  <MarginRight>1in</MarginRight>" +

            "  <MarginBottom>0.5in</MarginBottom>" +

            "</DeviceInfo>";



            Warning[] warnings;

            string[] streams;

            byte[] renderedBytes;



            //Render the report

            renderedBytes = localReport.Render(

                reportType

            );

          

            return File(renderedBytes,mimeType);
           
        }          

小小高 | 小虾三级 |园豆:820 | 2015-05-12 18:03
其他回答(1)
0

http://www.cnblogs.com/waxdoll/category/49402.html?Show=All 很全

收获园豆:100
气质优雅的猪 | 园豆:283 (菜鸟二级) | 2015-05-12 17:58

我已解决.............

支持(0) 反对(0) 小小高 | 园豆:820 (小虾三级) | 2015-05-12 17:59
public ActionResult Index()
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath(@"~/Report/myDataSet.rdlc");

            ReportDataSource reportDataSource = new ReportDataSource("MyDataSet", new FS_NEWEntities().T_Login.ToList());



            localReport.DataSources.Add(reportDataSource);

            string reportType = "PDF";

            string mimeType = "application/pdf ";

            string encoding;

            string fileNameExtension;



            //The DeviceInfo settings should be changed based on the reportType

            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx

            string deviceInfo =

            "<DeviceInfo>" +

            "  <OutputFormat>PDF</OutputFormat>" +

            "  <PageWidth>8.5in</PageWidth>" +

            "  <PageHeight>11in</PageHeight>" +

            "  <MarginTop>0.5in</MarginTop>" +

            "  <MarginLeft>1in</MarginLeft>" +

            "  <MarginRight>1in</MarginRight>" +

            "  <MarginBottom>0.5in</MarginBottom>" +

            "</DeviceInfo>";



            Warning[] warnings;

            string[] streams;

            byte[] renderedBytes;



            //Render the report

            renderedBytes = localReport.Render(

                reportType

            );

          

            return File(renderedBytes,mimeType);
           
        }           

 

支持(0) 反对(0) 小小高 | 园豆:820 (小虾三级) | 2015-05-12 18:00

rdlc的数据类型与绑的数据类型要一致,。。。。。。。。试了n篇文章。看了一个视频才解决,真是太down了

支持(0) 反对(0) 小小高 | 园豆:820 (小虾三级) | 2015-05-12 18:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册