SSRS for ASP.NET MVC3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        private FileContentResult DownloadPdfReport(string reportPath, 
                                                    string fileName, 
                                                    IEnumerable reportDataSources)
        {
            var localReport = new LocalReport { ReportPath = reportPath };
            var permissionSet = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
            localReport.SetBasePermissionsForSandboxAppDomain(permissionSet);
            foreach (var dataSource in reportDataSources)
                localReport.DataSources.Add(dataSource);
 
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;
 
            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            var deviceInfo =
                "" +
                "  PDF" +
                "  8.5in" +
                "  11in" +
                "  0.5in" +
                "  0.5in" +
                "  0.5in" +
                "  0.5in" +
                "";
 
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes
                = localReport.Render(reportType,
                                     deviceInfo,
                                     out mimeType,
                                     out encoding,
                                     out fileNameExtension,
                                     out streams,
                                     out warnings);
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + fileNameExtension);
            return File(renderedBytes, mimeType);
        }

Comments are closed.

Our Capabilities Include:


Custom Software Development
Enterprise Architecture
Project Management
Systems Analysis
Performance Testing

AND THE LIST GOES ON...

These methods are vital to our work:


Agile Methodology
PMBOK
Test-Driven Development

LEARN WHY...

About CodeSmart, Inc.


CodeSmart has been locally owned and operated in the Olympia, WA area since 2002. We direct, design, develop and deliver full end-to-end information systems using leading edge Microsoft .Net technologies and recommended best practices.

LEARN MORE...