Example #1
0
        public ActionResult lista()
        {
            var lis = new List <Libro>();

            lis = Libro.Catologo();
            return(View(lis));
        }
Example #2
0
        public ActionResult printRpt(string id)
        {
            LocalReport lr   = new LocalReport();
            string      path = Path.Combine(Server.MapPath("~/Reportes"), "report.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
                return(Content("No encuentra el reporte"));
            }
            //List<StateArea> cm = new List<StateArea>();
            //using (PopulationEntities dc = new PopulationEntities())
            //{
            //    cm = dc.StateAreas.ToList();
            //}

            List <Libro> cm = new List <Libro>();

            cm = Libro.Catologo();
            ReportDataSource rd = new ReportDataSource("DataSet1", cm);

            lr.DataSources.Add(rd);
            string reportType = id;
            string mimeType;
            string encoding;
            string fileNameExtension;



            string deviceInfo =

                "<DeviceInfo>" +
                "  <OutputFormat>" + id + "</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;

            renderedBytes = lr.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);


            return(File(renderedBytes, mimeType));
        }