Example #1
3
        private static byte[] LocalReportToBytes(LocalReport localReport)
        {
            string format = "PDF", deviceInfo = null, mimeType, encoding, fileNameExtension;
            string[] streams;
            Warning[] warnings;
            byte[] bytes=null;
            try
            {
                bytes = localReport.Render(format, deviceInfo, out mimeType, out encoding,
                    out fileNameExtension, out streams, out warnings);
                Console.WriteLine("statement ok");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            byte osVersion = (byte)Environment.OSVersion.Version.Major;
            if (osVersion >= 6)
            {
                byte[] result = new byte[bytes.Length + 2];
                bytes.CopyTo(result, 0);
                result[result.Length -2] = 1;
                result[result.Length - 1] = osVersion;
                return result;
            }
            else
            {
                return bytes;
            }
        }
Example #2
2
        public ReportResult(ReportFormat format, string outReportName, string reportPath, ReportDataSource [] ds, SubreportProcessingEventHandler[] subReportProcessing = null)
        {
            var local = new LocalReport();
            local.ReportPath = reportPath;

            if (ds != null)
            {
                for(int i = 0 ; i < ds.Count() ; i++ )
                    local.DataSources.Add(ds[i]);
            }
            // подключение обработчиков вложенных отчетов
            if (subReportProcessing != null)
            {
                for (int i = 0; i < subReportProcessing.Count(); i++ )
                    local.SubreportProcessing += subReportProcessing[i];
            }

            ReportType = format.ToString();
            DeviceInfo = String.Empty;
            ReportName = outReportName;

            RenderBytes = local.Render(ReportType, DeviceInfo
                , out this.MimiType
                , out this.Encoding
                , out this.FileExt
                , out this.Streams
                , out this.Warnings
                );
        }
        public static Byte[] GenerarPdfFactura(LocalReport localReport, out string mimeType)
        {
            const string reportType = "PDF";

            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            const string deviceInfo = "<DeviceInfo>" +
                                      "  <OutputFormat>PDF</OutputFormat>" +
                                      "  <PageWidth>21cm</PageWidth>" +
                                      "  <PageHeight>25.7cm</PageHeight>" +
                                      "  <MarginTop>1cm</MarginTop>" +
                                      "  <MarginLeft>2cm</MarginLeft>" +
                                      "  <MarginRight>2cm</MarginRight>" +
                                      "  <MarginBottom>1cm</MarginBottom>" +
                                      "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;

            //Render the report
            return localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
        }
Example #4
1
        private void Export(LocalReport report)
        {
            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>EMF</OutputFormat>" +
            "  <PageWidth>48mm</PageWidth>" +
            "  <PageHeight>297mm</PageHeight>" +
            "  <MarginTop>0mm</MarginTop>" +
            "  <MarginLeft>0mm</MarginLeft>" +
            "  <MarginRight>0mm</MarginRight>" +
            "  <MarginBottom>0mm</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
              m_streams = new List<Stream>();
              try
              {
                  report.Render("Image", deviceInfo, CreateStream, out warnings);//一般情况这里会出错的  使用catch得到错误原因  一般都是简单错误
              }
              catch (Exception ex)
              {
                  Exception innerEx = ex.InnerException;//取内异常。因为内异常的信息才有用,才能排除问题。
                  while (innerEx != null)
                  {
                     //MessageBox.Show(innerEx.Message);
                     string errmessage = innerEx.Message;
                      innerEx = innerEx.InnerException;
                  }
              }
              foreach (Stream stream in m_streams)
              {
                  stream.Position = 0;
              }
        }
Example #5
1
        private void Export(LocalReport report)
        {
            try
            {
                string deviceInfo =
                  "<DeviceInfo>" +
                  "  <OutputFormat>EMF</OutputFormat>" +
                  "  <PageWidth>8.5in</PageWidth>" +
                  "  <PageHeight>11in</PageHeight>" +
                  "  <MarginTop>0.25in</MarginTop>" +
                  "  <MarginLeft>0.25in</MarginLeft>" +
                  "  <MarginRight>0.25in</MarginRight>" +
                  "  <MarginBottom>0.25in</MarginBottom>" +
                  "</DeviceInfo>";

                Warning[] warnings;
                m_streams = new List<Stream>();
                report.Render("Image", deviceInfo, CreateStream,out warnings);
                foreach (Stream stream in m_streams)
                    stream.Position = 0;
            }
            catch (Exception ee)
            {
                //MessageBox.Show(ee.ToString());
            }
        }
        protected void executeReport_click(object sender, EventArgs e)
        {
            if (reportSelector.SelectedIndex == 9)
                executeReportInAppDomain_click(sender, e);
            else
            {
                LocalReport rpt = new LocalReport();
                rpt.EnableExternalImages = true;
                rpt.ReportPath = String.Concat(Path.GetDirectoryName(Request.PhysicalPath), "\\Reports\\", reportSelector.SelectedValue);
                string orientation = (rpt.GetDefaultPageSettings().IsLandscape) ? "landscape" : "portrait";
                StringReader formattedReport = Business.reportHelper.FormatReportForTerritory(rpt.ReportPath, orientation, cultureSelector.SelectedValue);
                rpt.LoadReportDefinition(formattedReport);

                // Add Data Source
                rpt.DataSources.Add(new ReportDataSource("InvoiceDataTable", dt));

                // Internationlisation: Add uiCulture and Translation Labels
                if (reportSelector.SelectedIndex >= 3)
                {
                    Dictionary<string, string> reportLabels = Reports.reportTranslation.translateInvoice(cultureSelector.SelectedValue);
                    ReportParameterCollection reportParams = new ReportParameterCollection();

                    reportParams.Add(new ReportParameter("uiCulture", cultureSelector.SelectedValue));
                    foreach (string key in reportLabels.Keys)
                        reportParams.Add(new ReportParameter(key, reportLabels[key]));

                    rpt.SetParameters(reportParams);
                }

                // Render To Browser
                renderPDFToBrowser(rpt.Render("PDF", Business.reportHelper.GetDeviceInfoFromReport(rpt, cultureSelector.SelectedValue, "PDF")));
            }
        }
        public void Render(string reportDesign, ReportDataSource[] dataSources, string destFile, IEnumerable<ReportParameter> parameters = null)
        {
            var localReport = new LocalReport();

            using (var reportDesignStream = System.IO.File.OpenRead(reportDesign))
            {
                localReport.LoadReportDefinition(reportDesignStream);
            }
            localReport.EnableExternalImages = true;
            localReport.EnableHyperlinks = true;

            if (parameters != null)
            {
                localReport.SetParameters(parameters);
            }
            foreach (var reportDataSource in dataSources)
            {
                localReport.DataSources.Add(reportDataSource);
            }

            //Export to PDF
            string mimeType;
            string encoding;
            string fileNameExtension;
            string[] streams;
            Warning[] warnings;
            var content = localReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            System.IO.File.WriteAllBytes(destFile, content);
        }
Example #8
0
        public ActionResult Export(string type)
        {
            LocalReport lr = new LocalReport();
            int TotalRow;
            string path = Path.Combine(Server.MapPath("~/Rdlc"), "rdlcOrders.rdlc");
            lr.ReportPath = path;
            var list = serivce.Get(out TotalRow);

            ReportDataSource rd = new ReportDataSource("DataSet1", list);
            lr.DataSources.Add(rd);

            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo;

            deviceInfo = "<DeviceInfo>" +
            "  <OutputFormat>" + type + "</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[] stream;
            byte[] renderBytes;

            renderBytes = lr.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out stream, out warnings);

            return File(renderBytes, mimeType, "Report");
        }
Example #9
0
        public static ReportDTO PrintReport(string reportPath, object[] data, string[] dataSourceName, string reportType, bool isPortriat = true)
        {
            var localReport = new LocalReport();
            localReport.ReportPath = reportPath;

            for (int i = 0; i < data.Count(); i++)
            {
                var reportDataSource = new ReportDataSource(dataSourceName[i], data[i]);
                localReport.DataSources.Add(reportDataSource);
            }

            //foreach (var d in data)
            //{
            //    var reportDataSource = new ReportDataSource(dataSourceName, d);
            //    localReport.DataSources.Add(reportDataSource);
            //}

            // string reportType = "PDF";

            string mimeType;
            string encoding;
            string fileNameExtension;

            string pageLayout = isPortriat
                                    ? "  <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> "
                                    : "  <PageWidth>11in</PageWidth> <PageHeight>8.5in</PageHeight> ";
            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>" + reportType + "</OutputFormat>" +
               pageLayout +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>0.25in</MarginLeft>" +
            "  <MarginRight>0.25in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            //Render the report
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings
                );

            var result=new ReportDTO{
                                      RenderBytes=renderedBytes,
                                      MimeType=mimeType
                                    };
            return result;
        }
        private void btnGenerateInCode_Click(object sender, EventArgs e)
        {
            using (var rpt = new LocalReport())
            {
                rpt.ReportPath = "Customers.rdlc";
                var data = DataAccess.Customer.Get();
                var rds = new ReportDataSource("CustomerDataSet", data);
                rpt.DataSources.Add(rds);

                string reportType = "WORDOPENXML";
                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
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>WORDOPENXML</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 = rpt.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                using (var fd = new SaveFileDialog())
                {
                    fd.Filter = "word files (*.docx)|*.docx|All files (*.*)|*.*";
                    if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        File.WriteAllBytes(fd.FileName, renderedBytes);
                        System.Diagnostics.Process.Start(fd.FileName);
                    }
                }

            }
        }
        public FileContentResult obtenerReporte(FormCollection post)
        {
            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo

            string EPC = post["EPC"].ToString();
            string inicio = post["inicio"].ToString();
            string fin = post["fin"].ToString();

            string diagnostico = post["diagnostico"];
            string recomendacion = post["recomendacion"];
            string observaciones = post["observaciones"];

            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo
            LocalReport reporte_local = new LocalReport();
            // pasa la ruta donde se encuentra el reporte
            reporte_local.ReportPath = Server.MapPath("~/Report/reporte.rdlc");
            // creamos un recurso de datos del tipo report
            ReportDataSource conjunto_datos = new ReportDataSource();
            // le asginamos al conjuto de datos el nombre del datasource del reporte
            conjunto_datos.Name = "DataSet1";
            List<lecturasReporte> lecturasParaReporte = new List<lecturasReporte>();
            if (Session["rol"] != null)
            {
                List<lecturas> listaLecturas = lecturas.obtenerUltimosDatos(EPC, inicio, fin);
                lecturasParaReporte = lecturasReporte.convertirLecturas(listaLecturas, diagnostico, recomendacion, observaciones);
            }
            // se le asigna el datasource el conjunto de datos desde el modelo
            conjunto_datos.Value = lecturasParaReporte;
            // se agrega el conjunto de datos del tipo report al reporte local
            reporte_local.DataSources.Add(conjunto_datos);
            // datos para renderizar como se mostrara el reporte
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo = "<DeviceInfo>" +
                 "  <OutputFormat>jpeg</OutputFormat>" +
                 "  <PageWidth>14in</PageWidth>" +
                 "  <PageHeight>12in</PageHeight>" +
                 "  <MarginTop>0.5in</MarginTop>" +
                 "  <MarginLeft>1in</MarginLeft>" +
                 "  <MarginRight>1in</MarginRight>" +
                 "  <MarginBottom>0.5in</MarginBottom>" +
                 "</DeviceInfo>";
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;
            //Se renderiza el reporte            
            renderedBytes = reporte_local.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            // el reporte es mostrado como una imagen
            return File(renderedBytes, mimeType);
        }
Example #12
0
 private static void Export(LocalReport report)
 {
     string deviceInfo =
       @"<DeviceInfo>
         <OutputFormat>EMF</OutputFormat>
     </DeviceInfo>";
     Warning[] warnings;
     m_streams = new List<Stream>();
     report.Render("Image", deviceInfo, CreateStream,
        out warnings);
     foreach (Stream stream in m_streams)
         stream.Position = 0;
 }
        protected void GenerateInCode_Click(object sender, EventArgs e)
        {
            using (var rpt = new LocalReport())
            {
                rpt.ReportPath = Server.MapPath("~/Customers.rdlc");
                var data = DataAccess.Customer.Get();
                var rds = new ReportDataSource("CustomerDataSet", data);
                rpt.DataSources.Add(rds);

                string reportType = "WORDOPENXML";
                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
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>WORDOPENXML</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 = rpt.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment; filename=Report." + fileNameExtension);
                Response.OutputStream.Write(renderedBytes, 0, renderedBytes.Length);
                Response.End();

            }
        }
        public ActionResult HistoricoJuri(int idJuri)
        {
            String format = "PDF";
            LocalReport lr = new LocalReport();
            string path = Path.Combine(Server.MapPath("~/Report"), "vhistoricojurireport.rdlc");
            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            List<vhistoricojuri> cm = VHistoricoJuriRepository.GetOneByIdJuri(idJuri);
            ReportDataSource rd = new ReportDataSource("vhistoricojurireport", cm);
            lr.DataSources.Add(rd);

            //List<vsorteiofuncoes> cm2 = new VSorteioFuncoesRepository().GetAllBySortJuriAndExport(idJuri);
            //ReportDataSource rd2 = new ReportDataSource("vsorteiofuncoes", cm2);
            //lr.DataSources.Add(rd2);

            string reportType = format;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =

                "<DeviceInfo>" +
                "<OutputFormat>" + format + "</OutputFormat>" +
                "<PageWidth>8.5in</PageWidth>" +
                "<PageHeight>11in</PageHeight>" +
                "<MarginTop>0.5in</MarginTop>" +
                "<MarginLeft>0.5in</MarginLeft>" +
                "<MarginRight>0.5in</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);
        }
 private HttpResponseMessage Export(LocalReport report, string exportFormat)
 {
     try
     {
         byte[] info = report.Render((exportFormat != null && exportFormat.ToLower() == "xls" ? "EXCEL" : "PDF"));
         var docPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Temp/");
         var docName = Guid.NewGuid().ToString();
         File.WriteAllBytes(docPath + docName + "." + exportFormat, info);
         return Request.CreateResponse<string>(HttpStatusCode.OK, docName);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return null;
     }
 }
Example #16
0
        public byte[] FileRender(ReportType Type, string ReportPath, string ReportFile, string ReportName, ReportDataSource Data)
        {
            _ReportName = ReportName;
            _ReportPath = ReportPath;
            _ReportFile = ReportFile;
            _DS = Data;
            Microsoft.Reporting.WebForms.LocalReport DirectReport = new LocalReport();
            DirectReport.ReportPath = this.Context.Server.MapPath(_ReportPath + _ReportFile);
            DirectReport.DataSources.Add(_DS);
            Microsoft.Reporting.WebForms.Warning[] warnings;

            string[] streamids;
            string encoding, extension;

            return DirectReport.Render(Type.ToString(), null, out _MimeType, out encoding, out extension, out streamids, out warnings);
        }
Example #17
0
        public byte[] Render(ReportName reportName, IDictionary<string, object[]> dataSources, params ReportParameter[] parameters)
        {
            var localReport = new LocalReport();
            localReport.ReportEmbeddedResource = new ReportResourceResolver().ResolveResource(reportName);

            foreach (var dataSource in dataSources)
            {
                var reportDataSource = new ReportDataSource(dataSource.Key, dataSource.Value);
                localReport.DataSources.Add(reportDataSource);
            }

            if (parameters != null && parameters.Length > 0)
                localReport.SetParameters(parameters);

            var reportType = "PDF";

            var settings = localReport.GetDefaultPageSettings();

            var width = settings.IsLandscape ? settings.PaperSize.Height : settings.PaperSize.Width;
            var height = settings.IsLandscape ? settings.PaperSize.Width : settings.PaperSize.Height;

            var deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>PDF</OutputFormat>" +
                "  <PageWidth>" + width / 100.0m + "in</PageWidth>" +
                "  <PageHeight>" + height / 100.0m + "in</PageHeight>" +
                "  <MarginTop>" + settings.Margins.Top / 100.0m + "in</MarginTop>" +
                "  <MarginLeft>" + settings.Margins.Left / 100.0m + "in</MarginLeft>" +
                "  <MarginRight>" + settings.Margins.Right / 100.0m + "in</MarginRight>" +
                "  <MarginBottom>" + settings.Margins.Bottom / 100.0m + "in</MarginBottom>" +
                "</DeviceInfo>";

            string mimeType;
            string encoding;
            string fileNameExtension;
            Warning[] warnings;
            string[] streams;

            return localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
        }
        public clsReportAttachementComplexType GetReportAttachement()
        {
            try
            {
                TopCareDataContext db = new TopCareDataContext();
                Attachment a;

                _tempSchedule = db.Schedules.FirstOrDefault(sch => sch.ScheduleID == ScheduleID);

                LocalReport lr = new LocalReport();
                lr.ReportPath = HttpContext.Current.Server.MapPath(reportPath);

                TopCareDataSetTableAdapters.ScheduleDetailsTableAdapter ta1 = new TopCareDataSetTableAdapters.ScheduleDetailsTableAdapter();
                TopCareDataSetTableAdapters.SchedulesTableAdapter ta2 = new TopCareDataSetTableAdapters.SchedulesTableAdapter();

                //int scheduleID = Convert.ToInt32(Request.QueryString["sID"]);

                ReportDataSource ds1 = new ReportDataSource("DataSet1", (System.Data.DataTable)ta2.GetDataByScheduleID(ScheduleID));
                ReportDataSource ds2 = new ReportDataSource("DataSet2", (System.Data.DataTable)ta1.GetDataByScheduleID(ScheduleID));

                lr.DataSources.Add(ds1);
                lr.DataSources.Add(ds2);

                Warning[] warnings;
                string[] streamids;
                string mimeType;
                string encoding;
                string extension;

                byte[] bytes = lr.Render("PDF", null, out mimeType,
                        out encoding, out extension, out streamids, out warnings);

                MemoryStream s = new MemoryStream(bytes);
                s.Seek(0, SeekOrigin.Begin);

                string _attachmentFileName = String.Format("Charisma Programe Outline-{0}.pdf", _tempSchedule.DateOfEvent.Value.ToShortDateString());

                //create instance of attachement and initialize it
                a = new Attachment(s, _attachmentFileName);

                return new clsReportAttachementComplexType() { AttachedFileContent = a, AttachedFileName = _attachmentFileName };
            }
            catch (Exception)
            {
                return null;
            }
        }
Example #19
0
        public ActionResult Export(string type)
        {
            // 讀取.rdlc檔
            LocalReport lr = new LocalReport();
            string path = Path.Combine(Server.MapPath("~/Rdlc"), "rdlcOrders.rdlc");
            lr.ReportPath = path;

            // 取得訂單資料
            var list = OrderService.GetCustomerOrders();
            // 設定資料集
            ReportDataSource rd = new ReportDataSource("DataSet1", list);
            lr.DataSources.Add(rd);
            // 檔案類型,從參數指定:Excel.pdf.word
            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =

            "<DeviceInfo>" +
            "  <OutputFormat>" + type + "</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, "Report");
        }
Example #20
0
        public ActionResult ReportPage(string id)
        {
            try
            {
                //var potr = (from p in db.vPotrosnjaMjesec where p.lnk == id orderby p.ImePrezime select p);
                var rez = Db.vOdobrenoList.ToList().OrderByDescending(t => t.datum_polaska);

                var localReport = new LocalReport {
                    ReportPath = Server.MapPath("~/Rpt/Raspored.rdlc")
                };
                var reportDataSource = new ReportDataSource("DataSet1", rez);
                localReport.DataSources.Add(reportDataSource);
                const string reportType = "Excel";
                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
                const string deviceInfo = "<DeviceInfo>" +
                                          "  <OutputFormat>Excel</OutputFormat>" +
                                          "  <PageWidth>11in</PageWidth>" +
                                          "  <PageHeight>8.5in</PageHeight>" +
                                          "  <MarginTop>0.5in</MarginTop>" +
                                          "  <MarginLeft>1in</MarginLeft>" +
                                          "  <MarginRight>1in</MarginRight>" +
                                          "  <MarginBottom>0.5in</MarginBottom>" +
                                          "</DeviceInfo>";
                Warning[] warnings;
                string[]  streams;

                //Render the report
                byte[] renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension,
                                                          out streams, out warnings);

                //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);
                return(File(renderedBytes, mimeType));

                //return View(rez);
            }
            catch (Exception ex)
            {
                return(Error(ex.ToString()));
            }
        }
Example #21
0
        public ActionResult Report(int id)// Devolver el pdf del Reporte de Cotizacion.
        {
            LocalReport        report    = new LocalReport();
            List <ReportQuote> DataLists = new List <ReportQuote>();
            string             path      = Path.Combine(Server.MapPath("~/Reports"), "Coti.rdlc");

            if (System.IO.File.Exists(path))
            {
                report.ReportPath = path;
            }
            else
            {
                return(RedirectToAction("Lista"));
            }
            //Solicitar los datos al servidor por medio de un procedimiento almacenado
            DataLists = context.Database.SqlQuery <ReportQuote>("EXEC ReportCotizacion @idcotizacion",
                                                                new System.Data.SqlClient.SqlParameter("@idcotizacion", id)).ToList();

            ReportDataSource dataSource = new ReportDataSource("CotiData", DataLists);
            var parameter = new ReportParameter("Impuesto", Convert.ToString((DataLists[0].Total * 0.18m)), true);

            report.DataSources.Add(dataSource);
            report.SetParameters(parameter);


            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension = "pdf";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            renderedBytes = report.Render(
                reportType,
                "",
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            return(File(renderedBytes, "application/pdf", $"Cotizacion-{DataLists[0].Cliente}-{DataLists[0].Fecha.ToShortDateString()}.pdf"));
        }
Example #22
0
        public static byte[] GeneraArchivoReporte(string nameReport, string titulo, string tipoArchivo, System.Data.DataSet data)
        {
            byte[] renderedBytes = null;

            LocalReport localReport = new LocalReport();
            String      sPath       = ObtenerUbicacion();

            localReport.ReportPath = Path.Combine(sPath, "Reportes", nameReport);
            if (data != null)
            {
                foreach (System.Data.DataTable tabla in data.Tables)
                {
                    ReportDataSource reportDS = new ReportDataSource();
                    reportDS.Name  = tabla.TableName;
                    reportDS.Value = tabla;
                    localReport.DataSources.Add(reportDS);
                }
            }
            localReport.DisplayName = titulo;
            string tipo = String.Empty;

            switch (tipoArchivo)
            {
            case "xls":
                tipo = "EXCEL";
                break;

            case "docx":
                tipo = "WORDOPENXML";
                break;

            default:
                tipo = "PDF";
                break;
            }
            var    reportType = tipo;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string[]  streams;
            Warning[] warnings;
            renderedBytes = localReport.Render(reportType, null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            return(renderedBytes);
        }
Example #23
0
        public ActionResult DownloadReport(int countryId, string startDate, string endDate, string format)
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath("~/Content/Report/ReportBillPartyWiseReport.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource();

            reportDataSource.Name = "DataSet1";
            DateTime sDate;

            DateTime.TryParse(startDate, out sDate);
            DateTime eDate;

            DateTime.TryParse(endDate, out eDate);
            reportDataSource.Value = BillReportBusinessLogic.GetBillPartyWiseReport(countryId, sDate, eDate);
            localReport.DataSources.Add(reportDataSource);
            string reportType = "Image";
            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
            string deviceInfo = "<DeviceInfo>" +
                                "  <OutputFormat>jpeg</OutputFormat>" +
                                "  <PageWidth>11.5in</PageWidth>" +
                                "  <PageHeight>8.5in</PageHeight>" +
                                "  <MarginTop>0in</MarginTop>" +
                                "  <MarginLeft>0in</MarginLeft>" +
                                "  <MarginRight>0in</MarginRight>" +
                                "  <MarginBottom>0in</MarginBottom>" +
                                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;
            renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            if (format.ToUpper() == "PDF")
            {
                return(File(renderedBytes, mimeType));
            }
            else
            {
                return(File(renderedBytes, mimeType));
            }
        }
Example #24
0
        public byte[] GetSample1ReportasStreem()
        {
            // ReportDataSource reportDataSource = new ReportDataSource();
            //var data = _db.Customers.ToList();
            //reportDataSource.Name = "dt";
            //reportDataSource.Value = data;

            LocalReport local = new LocalReport
            {
                ReportPath           = _env.WebRootPath + "/Report/Report1.rdlc",
                EnableExternalImages = true
            };

            //local.DataSources.Add(reportDataSource);



            //ReportParameter[] parameters = {
            //    new ReportParameter("sample",sample),
            //    new ReportParameter("muthmen", muthmenname),
            //    new ReportParameter("audit", aduitname),
            //    new ReportParameter("approver", appovename),
            //    new ReportParameter("totprice",  toWord.ConvertToArabic()),


            //    new ReportParameter("muthminsign",  sigurlmuthmen),
            //    new ReportParameter("Auditsign",  sigurlauditsign),
            //    new ReportParameter("Approvesign", sigurlapprovesign),


            //    new ReportParameter("idmuthmin",  muthmenid),
            //    new ReportParameter("idaudit",  aduitid),
            //    new ReportParameter("idapprove", appoveid),
            //    new ReportParameter("earthmap",  earthmap),
            //    new ReportParameter("map", map),
            //    new ReportParameter("zoommap", zoommap),
            //    new ReportParameter("images",images)


            //};

            //local.SetParameters(parameters);

            return(local.Render("Pdf", ""));
        }
        public ActionResult PDF(string column, string gender, string religion, string designations, string bloodGroup)
        {
            string showColumns = "";

            List <string> columns = column.Split(',').ToList();

            if (columns != null && columns.Count > 0)
            {
                for (int i = 0; i < columns.Count; i++)
                {
                    if (i + 1 == columns.Count)
                    {
                        showColumns += columns[i];
                    }
                    else
                    {
                        showColumns += columns[i] + ",";
                    }
                }
            }



            LocalReport report = new LocalReport();

            report.ReportPath = Server.MapPath("~/Reports/DynamicReport.rdlc");
            var dsds = db.Employees.ToList();
            var ds   = db.Database
                       .SqlQuery <DynamicReportViewModel>("EmployeeReport '" + showColumns + "','" + gender + "','" + religion +
                                                          "','" + designations + "','" + bloodGroup + "'").ToList();

            report.DataSources.Add(new ReportDataSource("DataSet1", ds));


            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            byte[] bytes = report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
            Session["pdfMemoryStream"] = new MemoryStream(bytes);

            return(PartialView("_Viewpdf"));
        }
Example #26
0
        public ActionResult Exports(string ReportType)
        {
            LocalReport localreport = new LocalReport
            {
                ReportPath = Server.MapPath("~/Reports/EmployeeListReport.rdlc")
            };

            ReportDataSource reportDataSource = new ReportDataSource
            {
                Name  = "EmployeeDataSet",
                Value = db.Employees.ToList()
            };

            localreport.DataSources.Add(reportDataSource);

            string reportType = ReportType;
            string mimeType;
            string encoding;
            string fileNameExtension;

            if (reportType == "Excel")
            {
                fileNameExtension = "xls";
            }
            else if (reportType == "EXCELOPENXML")
            {
                fileNameExtension = "xlsx";
            }
            else if (reportType == "CSV")
            {
                fileNameExtension = "csv";
            }
            else
            {
                fileNameExtension = "pdf";
            }

            string[]  streams;
            Warning[] warnings;
            byte[]    renderedByte;
            renderedByte = localreport.Render(reportType, null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            Response.AddHeader("Content-Disposition", "attachment; filename = employee_report." + fileNameExtension);
            return(File(renderedByte, fileNameExtension));
        }
Example #27
0
        public ActionResult DownloadReport()
        {
            LocalReport       lr         = new LocalReport();
            StudentRepository repository = new StudentRepository();
            string            path       = Path.Combine(Server.MapPath("~/Views/Reports"), "StudentDetails.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
            }
            var students        = repository.GetAllStudents();
            ReportDataSource rd = new ReportDataSource("DataSet1", students);

            lr.DataSources.Add(rd);
            IList <ReportParameter> reportParameters = new List <ReportParameter>()
            {
                new ReportParameter("title", "Test Report"),
                new ReportParameter("footer", "Generated on" + DateTime.Now)
            };

            lr.SetParameters(reportParameters);
            string mimeType;
            string encoding;
            string fileNameExtension;

            Warning[] warnings;
            string[]  streams;
            byte[]    renderBytes;

            lr.Refresh();
            renderBytes = lr.Render(
                "EXCEL",
                null,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings
                );
            Response.AddHeader("Content-Disposition", "attachment; filename=Test.xls");
            return(new FileContentResult(renderBytes, mimeType));
        }
Example #28
0
        private byte[] GetNotaReportBytes(string reportPath, DataSet reportDataSource, decimal pageWidth = 13.38m, decimal pageHeight = 8.5m, decimal MarginLeft = 1m, decimal MarginRight = 1m)
        {
            byte[] reportBytes = null;

            // Se crea la instancia del reporte y se cargan sus datos.
            LocalReport reporte = new LocalReport()
            {
                ReportPath = reportPath
            };

            reporte.DataSources.Add(new ReportDataSource("EncabezadoColegio", reportDataSource.Tables[0]));
            reporte.DataSources.Add(new ReportDataSource("EncabezadoAlumno", reportDataSource.Tables[1]));
            reporte.DataSources.Add(new ReportDataSource("Notas", reportDataSource.Tables[2]));
            reporte.DataSources.Add(new ReportDataSource("Asistencia", reportDataSource.Tables[3]));
            reporte.DataSources.Add(new ReportDataSource("Notas_Actitudinal", reportDataSource.Tables[4]));

            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>PDF</OutputFormat>" +               // Formato del documento PDF
                "  <PageWidth>" + pageWidth + "in</PageWidth>" +     // Ancho de 8.5 pulgadas para paginas oficio
                "  <PageHeight>" + pageHeight + "in</PageHeight>" +  // Alto de 13.38 pulgadas para paginas oficio
                "  <MarginTop>0.0in</MarginTop>" +                   // margen superior de 0.5 pulgadas
                "  <MarginLeft>" + MarginLeft + "</MarginLeft>" +    // margen izquierdo de 1 pulgada
                "  <MarginRight>" + MarginRight + "</MarginRight>" + // margen derecho de 1 pulgada.
                "  <MarginBottom>0.0in</MarginBottom>" +             // margen inferior de 0.5 pulgadas.
                "</DeviceInfo>";

            string mimeType;
            string encoding;
            string fileNameExtension;

            Warning[] warnings;
            string[]  streams;

            // Se renderiza el reporte.
            reportBytes = reporte.Render("PDF",
                                         deviceInfo,
                                         out mimeType,
                                         out encoding,
                                         out fileNameExtension,
                                         out streams,
                                         out warnings);

            return(reportBytes);
        }
        public ActionResult Report(string ReportType, int Id)
        {
            LocalReport report = new LocalReport();

            report.ReportPath = Server.MapPath("~/SRSS/ProvinciasReport.rdlc");

            DataSet          ds         = db.ExecuteDataSet("spProvinciasPais", Id);
            ReportDataSource datasource = new ReportDataSource("DataSet1", ds.Tables[0]);

            //datasource.Name = "ProvinciasDataSource";
            //datasource.Value = JsonConvert.DeserializeObject<List<Provincia>>(ProvinciasPais(Id).ToString());
            report.DataSources.Add(datasource);

            //ReportParameter param = new ReportParameter("IdPais", Id.ToString());
            //param.Values.Add(Id);
            //report.LocalReport.SetParameters(param);

            string mimeType;
            string encoding;
            string fileNameExtension;

            switch (ReportType)
            {
            case "Excel":
                fileNameExtension = "xlsx";
                break;

            case "Pdf":
                fileNameExtension = "pdf";
                break;

            case "Word":
            default:
                fileNameExtension = "docx";
                break;
            }

            string[]  streams;
            Warning[] warnings;
            byte[]    renderedByte;
            renderedByte = report.Render(ReportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            Response.AddHeader("content-disposition", "attachment;filename=provincias_report." + fileNameExtension);
            return(File(renderedByte, fileNameExtension));
            //return View();
        }
Example #30
0
        //public static byte[] BillingGetPdfByteArray(ReportDataSource ds1, ReportDataSource ds2)
        public static byte[] BillingGetPdfByteArray(ReportDataSource ds1)
        {
            var rv1 = new LocalReport();

            rv1.DataSources.Add(ds1);
            //rv1.DataSources.Add(ds2);
            rv1.ReportPath = @"C:\Users\admin\Downloads\pdfgenerator (2)\pdfgenerator\New folder\CreatePdf\GenerateCourtReport\bin\Debug\sasamartlo.rdlc";

            rv1.Refresh();
            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>EMF</OutputFormat>" +
                "  <PageWidth>8.3in</PageWidth>" +
                "  <PageHeight>11.7in</PageHeight>" +
                "  <MarginTop>0in</MarginTop>" +
                "  <MarginLeft>0in</MarginLeft>" +
                "  <MarginRight>0in</MarginRight>" +
                "  <MarginBottom>0in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    extension;

            byte[] bytesa;
            try
            {
                bytesa = rv1.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

                using (FileStream fs = new FileStream(@"C:\Users\admin\Desktop\hotels\hh.pdf", FileMode.Create))
                {
                    fs.Write(bytesa, 0, bytesa.Length);
                    fs.Close();
                    fs.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.ToString());
            }

            return(bytesa);
        }
        public ActionResult JuanNeiMuLu(long id, string type = "PDF")
        {
            LocalReport localReport = new LocalReport();
            var         ds1         = from ad in db_office.vw_PlanProjectList
                                      where ad.seqNo == id
                                      select ad;
            List <vw_PlanProjectList> list = ds1.ToList();

            for (int i = 0; i < list.Count(); i++)
            {
                if (list[i].fileNo != null)
                {
                    list[i].fileNo = list[i].fileNo.Trim();
                }
            }
            var ds = list;

            localReport.ReportPath = Server.MapPath("~/Report/guihua/JuanNeiMuLu.rdlc");
            ReportDataSource reportDataSource1 = new ReportDataSource("GongChengFengPi", ds);

            localReport.DataSources.Add(reportDataSource1);
            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =
                "<DeviceInfo>" +
                "<OutPutFormat>" + type + "</OutPutFormat>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings
                );
            return(File(renderedBytes, mimeType));
        }
Example #32
0
        private static byte[] RenderReport(string reportPath, ReportDataSource[] dataSources)
        {
            string format     = "PDF";
            string deviceInfo = "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>";

            var report = new LocalReport();

            report.ReportPath = reportPath;

            if (dataSources != null)
            {
                foreach (ReportDataSource rds in dataSources)
                {
                    report.DataSources.Add(rds);
                }
            }
            return(report.Render(format, deviceInfo, out _, out _, out _, out _, out _));
        }
Example #33
0
        public static void PushToStream(LocalReport report, ReportSettings settings, Stream outputStream)
        {
            var deviceInfo = PrepareAndGetDeviceInfo(report, settings);

            Warning[] warnings;

            report.Render(GetOutputFileFormat(settings.OutputType), deviceInfo, PageCountMode.Estimate,
                          (string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) =>
            {
                if (willSeek == true && outputStream.CanSeek == false)
                {
                    throw new Exception("Greewf : Current output report needs a seekable stream but you passed a not seekable stream. Change your output stream to a seekable one or change the report output type to one which doesn't need seekable stream. ");
                }

                return(outputStream);
            },
                          out warnings);
        }
Example #34
0
        private void Export(LocalReport Report)
        {
            EMFDeviceInfo emfdi = this.getEMFDeviceInfo(this.printSetting);

            string strDeviceInfo = emfdi.DeviceInfoString;

            emfdi = null;
            Microsoft.Reporting.WinForms.Warning[] Warnings;

            this.m_EMFStreams = new System.Collections.Generic.List <System.IO.Stream>();

            Report.Render("Image", strDeviceInfo, this.CreateStream, out Warnings);

            foreach (System.IO.Stream s in this.m_EMFStreams)
            {
                s.Position = 0;
            }
        }
Example #35
0
        public byte[] ExportToPdf(string templatePath, IDictionary <string, object> dataSources, IDictionary <string, object> parameters = null)
        {
            var reportDataSources = PrepareDocumentDataSources(dataSources);
            var reportParameters  = PrepareDocumentParameters(parameters);
            var localReport       = new LocalReport();

            localReport.ReportPath = templatePath;

            localReport.DataSources.Clear();
            reportDataSources.ForEach(localReport.DataSources.Add);

            if (reportParameters != null)
            {
                localReport.SetParameters(reportParameters);
            }

            return(localReport.Render("PDF", GetRenderDeviceInfo()));
        }
 public ActionResult ReporteTransferencia(int ID)
 {
     LocalReport localReport = new LocalReport();
     localReport.ReportPath = Server.MapPath("~/Reportes/ReporteTransferencia.rdlc");
     ReportDataSource reportDataSource = new ReportDataSource("DataSet1", repo.ReporteTransferencia(ID));
     localReport.DataSources.Add(reportDataSource);
     string reportType = "PDF";
     string mimeType = "application/pdf";
     string encoding = "utf-8";
     string fileNameExtension = "pdf";
     string deviceInfo = string.Empty;
     Warning[] warnings = new Warning[1];
     string[] streams = new string[1];
     Byte[] renderedBytes;
     //Render the report
     renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
     return File(renderedBytes, mimeType);
 }
 private void Export(LocalReport report)
 {
     string deviceInfo =
       @"<DeviceInfo>
         <OutputFormat>EMF</OutputFormat>
         <PageWidth>8.5in</PageWidth>
         <PageHeight>11in</PageHeight>
         <MarginTop>0.25in</MarginTop>
         <MarginLeft>0.25in</MarginLeft>
         <MarginRight>0.25in</MarginRight>
         <MarginBottom>0.25in</MarginBottom>
     </DeviceInfo>";
     Warning[] warnings;
     m_streams = new List<Stream>();
     report.Render("Image", deviceInfo, CreateStream, out warnings);
     foreach (Stream stream in m_streams)
         stream.Position = 0;
 }
Example #38
0
        private Document Generate(string format, bool calculatePageCount)
        {
            string mimeType, encoding, extension;

            Warning[] warn;
            string[]  streamids;
            int       pageCount = 0;

            _localReport.SubreportProcessing += new SubreportProcessingEventHandler(localReport_SubreportProcessing);
            byte[] content = _localReport.Render(format, null, out mimeType, out encoding, out extension, out streamids, out warn);
            if (calculatePageCount && format == "pdf")
            {
                PdfReader pdfReader = new PdfReader(content);
                pageCount = pdfReader.NumberOfPages;
            }

            return(new Document(content, mimeType, encoding, extension, streamids, pageCount));
        }
Example #39
0
        public override Dictionary <string, string> Generate()
        {
            string deviceInfo = null;

            using (LocalReport report = this.LoadReport())
            {
                Warning[] warnings;
                this.Cleanup();
                this._streams = new List <Stream>();
                this._files   = new Dictionary <string, string>();
                report.Render(this.Context.Format.ToString(), deviceInfo, new CreateStreamCallback(CreateStream), out warnings);
                for (int i = 0; i < _streams.Count; i++)
                {
                    this._streams[i].Close();
                }
                return(this._files);
            }
        }
        public byte[] GenerateEconomicAnalysisReportAsync(Model2MLResponse modelResult)
        {
            DataSet ds = new DataSet();

            ds = new DataSet();
            ds.Tables.Add(JsonConvert.DeserializeObject <DataTable>(JsonConvert.SerializeObject(modelResult.incomeCostResult.listIncomeCostResultByCrops)));
            ReportDataSource rds1 = new ReportDataSource {
                Name = "IncomesByCropsDataSet", Value = ds.Tables[0]
            };

            ds = new DataSet();
            ds.Tables.Add(JsonConvert.DeserializeObject <DataTable>(JsonConvert.SerializeObject(modelResult.incomeCostResult.listIncomeCostResultByLocations)));
            ReportDataSource rds2 = new ReportDataSource {
                Name = "IncomesByLocationsDataSet", Value = ds.Tables[0]
            };

            ReportParameter[] parametros =
            {
                new ReportParameter("incomes",      modelResult.incomeCostResult.incomes.ToString()),
                new ReportParameter("plantingCost", modelResult.incomeCostResult.plantCost.ToString()),
                new ReportParameter("laborCost",    modelResult.incomeCostResult.laborCost.ToString())
            };

            LocalReport lr         = new LocalReport();
            var         Reportpath = @".\Reports\EconomicAnalysis.rdlc";

            lr.ReportPath  = Reportpath;
            lr.DisplayName = "Economic Analysis.pdf";

            lr.SetParameters(parametros);
            lr.DataSources.Add(rds1);
            lr.DataSources.Add(rds2);

            var    reportType = "pdf";
            string mimeType;
            string encoding;
            string fileNameExtension;

            Warning[] warnings;
            string[]  streams;
            var       renderedBytes = lr.Render(reportType, null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            return(renderedBytes);
        }
        public JsonResult ImpresionArchivoMatricula(string strCodPeriodo)
        {
            try
            {
                string reportPath = string.Empty;
                reportPath = Path.Combine(Server.MapPath("~/Reports"), "rptArchivoMatricula.rdlc");
                ArchivoMatriculaEstudiante objArchivoMatricula = new ArchivoMatriculaEstudiante(UsuarioActual.CarreraActual.codUsuario.ToString(), UsuarioActual.Cedula.ToString(), strCodPeriodo, "M", UsuarioActual.CarreraActual.Codigo.ToString());
                LocalReport rptMatriculaEstudiante             = objArchivoMatricula.getReporteMatricula(reportPath);

                string idTypeFile = "PDF";
                string mimeType;
                string encoding;
                string fileNameExtension;
                string deviceInfo = "<DeviceInfo>" +
                                    "   <OutputFormat>" + idTypeFile + "</OutputFormat>" +
                                    "</DeviceInfo>";
                Warning[] warnings;
                string[]  streams;
                byte[]    renderedBytes;
                renderedBytes = rptMatriculaEstudiante.Render(idTypeFile,
                                                              deviceInfo,
                                                              out mimeType,
                                                              out encoding,
                                                              out fileNameExtension,
                                                              out streams,
                                                              out warnings);
                //  Creo el nombre del archivo
                string strNombreReporte = "Archivo Matriculacion";
                string nameFile         = strNombreReporte.Replace(" ", "_") + "_" + UsuarioActual.Cedula.ToString() + ((idTypeFile == "PDF") ? ".pdf" : "");

                //  Direcciono la creacion del archivo a una ubicacion temporal
                string fullPath = Path.Combine(Server.MapPath("~/Temp"), nameFile);

                //  Creo el archivo en la ubicacion temporal
                System.IO.File.WriteAllBytes(fullPath, renderedBytes);
                return(Json(new { fileName = nameFile, errorMessage = "" }));
            }
            catch (Exception ex)
            {
                Errores err = new Errores();
                err.SetError(ex, "createFile");
                return(Json(new { fileName = "none", errorMessage = "Problema al momento de crear el archivo" }));
            }
        }
Example #42
0
        private byte[] GenerateDraftRateData(long serviceID, long sourceCountryID, int month, int year, string format)
        {
            LocalReport localReport = new LocalReport();

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

            Service service = db.Services.Where(s => s.ID == serviceID).FirstOrDefault();

            if (service == null)
            {
                return(null);
            }

            ReportDataSource reportDataSource = new ReportDataSource();

            reportDataSource.Name = "dsRate";

            var rate = new ReportDAL().GetRate(service.Name, sourceCountryID, month, year);

            reportDataSource.Value = rate;
            localReport.DataSources.Add(reportDataSource);

            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
            string deviceInfo = "<DeviceInfo>" +
                                "  <OutputFormat>jpeg</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(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            return(renderedBytes);
        }
        private void ExportPNG(LocalReport report)
        {
            Warning[] ws;
            String    deviceInfo = "<DeviceInfo><OutputFormat>PNG</OutputFormat></DeviceInfo>";


            streams = new List <System.IO.MemoryStream>();
            report.Render("Image", deviceInfo, CreateStreamCallback, out ws);

            using (SaveFileDialog dlg = new SaveFileDialog())
            {
                dlg.Filter   = "PNG|*.png";
                dlg.FileName = System.IO.Path.GetFileNameWithoutExtension(report.ReportPath) + ".png";
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    List <string> names = new List <string>();
                    string        path  = dlg.FileName;
                    if (streams.Count == 1)
                    {
                        names.Add(path);
                    }
                    else
                    {
                        var    ext  = System.IO.Path.GetExtension(path);
                        string name = path.Substring(0, path.Length - ext.Length);


                        for (int i = 1; i <= streams.Count; i++)
                        {
                            names.Add(string.Format("{0}_{1}{2}", name, i, ext));
                        }
                    }

                    for (int i = 0; i < names.Count; i++)
                    {
                        using (System.IO.FileStream fs = new System.IO.FileStream(names[i], System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
                        {
                            streams[i].Position = 0;
                            streams[i].WriteTo(fs);
                        }
                    }
                }
            }
        }
Example #44
0
        // GET: Report
        public ActionResult Index()
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath("~/Report/ReportStPa.rdlc");
            using (TritonEntities EFDbContext = new TritonEntities())
            {
                var ViewData = from ViewTable in EFDbContext.StudenParents

                               select ViewTable;
                if (ViewData.Any())
                {
                    ReportDataSource ReportData = new ReportDataSource("DataSet1", ViewData.ToList());
                    localReport.DataSources.Add(ReportData);
                    string reportType = "PDF";
                    string mimeType;
                    string encoding;
                    string fileNameExtension;
                    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;
                    renderedBytes = localReport.Render(
                        reportType,
                        deviceInfo,
                        out mimeType,
                        out encoding,
                        out fileNameExtension,
                        out streams,
                        out warnings);
                    return(File(renderedBytes, mimeType));
                }
                return(View());
            }
        }
        private void RenderReport(string reportPath, string v, List <Employee> employees)
        {
            var localReport = new LocalReport {
                ReportPath = reportPath
            };

            //Give the collection a name (EmployeeCollection) so that we can reference it in our report designer
            var reportDataSource = new ReportDataSource("PRT_Emploee", employees);

            localReport.DataSources.Add(reportDataSource);

            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 =
                string.Format(
                    "<DeviceInfo><OutputFormat>{0}</OutputFormat><PageWidth>8.5in</PageWidth><PageHeight>11in</PageHeight><MarginTop>0.5in</MarginTop><MarginLeft>1in</MarginLeft><MarginRight>1in</MarginRight><MarginBottom>0.5in</MarginBottom></DeviceInfo>",
                    v);

            Warning[] warnings;
            string[]  streams;

            //Render the report
            var renderedBytes = localReport.Render(
                v,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            //Clear the response stream and write the bytes to the outputstream
            //Set content-disposition to "attachment" so that user is prompted to take an action
            //on the file (open or save)
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
            Response.BinaryWrite(renderedBytes);
            Response.End();
        }
Example #46
0
        private static void Main()
        {
            //var f = new Form1();
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            var lr =
                new LocalReport();

            string deviceInfo =
                "<DeviceInfo>" +
                "<SimplePageHeaders>True</SimplePageHeaders>" +
                "</DeviceInfo>";

            lr.ReportPath = @"Report1.rdlc";

            CustomerDb db = CustomerDb.Create();
            Customer cust = db.Customers[0];
            var ds1 = new ReportDataSource
            {
                DataSourceId = "DataModel_Customer",
                DataMember = "DataModel_Customer",
                Name = "DataModel_Customer"
                                           };
            lr.DataSources.Add(ds1);
            lr.DataSources.Add(new ReportDataSource("DataModel_Order"));

            string mimeType;
            string encoding;
            string fileNameExtension;
            string[] streams;
            Warning[] warnings;
            byte[] bytes = lr.Render("PDF", deviceInfo,
                out mimeType,
                                     out encoding, out fileNameExtension,
                                     out streams,
                                     out warnings);

            using (var fs = new FileStream(@"Report.pdf", FileMode.Create)) {
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();
            }
        }
Example #47
0
        public ActionResult ReporteDetalleCompra(long id)
        {
            LocalReport LR = new LocalReport();

            string deviceInfo =
                "<DeviceInfo>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>1in</MarginLeft>" +
                "  <MarginRight>1in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

            LR.ReportPath = Server.MapPath("~/Reportes/ReportDetalleCompra.rdlc");

            var query = from cm in db.m_compra
                        join dt in db.d_compra
                        on cm.id equals dt.M_COMPRA_id
                        where cm.id == id
                        select new
            {
                id                = cm.id,
                fecha_compra      = cm.fecha_compra,
                nombre1           = cm.empleado.nombre1,
                apellido1         = cm.empleado.apellido1,
                total_compra      = cm.total_compra,
                nombre            = cm.proveedor.nombre,
                tipo_compra       = cm.tipo_compra.nombre,
                PRODUCTO_id       = dt.PRODUCTO_id,
                cantidad_producto = dt.cantidad_producto,
                costo_unitario    = dt.costo_unitario,
                total             = dt.total,
                producto          = dt.producto.nombre
            };

            ReportDataSource RD = new ReportDataSource("DsDetCompra", query.ToList());

            LR.DataSources.Add(RD);

            byte[] bytes = LR.Render("PDF", deviceInfo);

            return(File(bytes, "PDF"));
        }
        public ActionResult Report()
        {
            using (var rpt = new LocalReport())
            {
                rpt.ReportPath = Server.MapPath("~/Customers.rdlc");
                var data = DataAccess.Customer.Get();
                var rds = new ReportDataSource("CustomerDataSet", data);
                rpt.DataSources.Add(rds);

                string reportType = "WORDOPENXML";
                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
                string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>WORDOPENXML</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 = rpt.Render(
                    reportType,
                    deviceInfo,
                    out mimeType,
                    out encoding,
                    out fileNameExtension,
                    out streams,
                    out warnings);

                return File(renderedBytes, mimeType);
            }
        }
Example #49
0
        private static void Main()
        {
            //var f = new Form1();
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            var lr =
                new LocalReport();

            string deviceInfo =
                "<DeviceInfo>" +
                "<SimplePageHeaders>True</SimplePageHeaders>" +
                "</DeviceInfo>";

            lr.ReportPath = @"Report1.rdlc";

            CustomerDb db   = CustomerDb.Create();
            Customer   cust = db.Customers[0];
            var        ds1  = new ReportDataSource {
                DataSourceId = "DataModel_Customer"
            };

            lr.DataSources.Add(ds1);
            lr.DataSources.Add(new ReportDataSource("DataModel_Order"));


            string mimeType;
            string encoding;
            string fileNameExtension;

            string[]  streams;
            Warning[] warnings;
            byte[]    bytes = lr.Render("PDF", deviceInfo,
                                        out mimeType,
                                        out encoding, out fileNameExtension,
                                        out streams,
                                        out warnings);

            using (var fs = new FileStream(@"Report.pdf", FileMode.Create)) {
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();
            }
        }
Example #50
0
        public static List <FileUpload> CreatePDFToFileUpload(string ReportPath, List <ReportParameter> lstRptParam, List <ReportDataSource> reportDataSource
                                                              , string PRG_CODE, decimal?DOCUMENT_TYPE_ID, decimal?SECTION_GROUP_ID, decimal?COVER_SHEET_SEND_ID, decimal?HEADER_INPUT_ID)
        {
            LocalReport report = new LocalReport();

            Warning[]         warnings;
            string[]          streamids;
            string            mimeType;
            string            encoding;
            string            extension;
            FileUpload        File     = new FileUpload();
            List <FileUpload> FileList = new List <FileUpload>();

            report.ReportPath = HttpContext.Current.Server.MapPath(ReportPath);
            report.Refresh();

            report.SetParameters(lstRptParam);
            report.DataSources.Clear();
            foreach (var item in reportDataSource)
            {
                report.DataSources.Add(item);
            }

            byte[] bytes = report.Render("PDF", null, out mimeType,
                                         out encoding, out extension, out streamids, out warnings);

            File.PRG_CODE            = PRG_CODE;
            File.DOCUMENT_TYPE_ID    = DOCUMENT_TYPE_ID;
            File.SECTION_GROUP_ID    = SECTION_GROUP_ID;
            File.COVER_SHEET_SEND_ID = COVER_SHEET_SEND_ID;
            File.HEADER_INPUT_ID     = HEADER_INPUT_ID;

            File.COM_CODE       = SessionHelper.SYS_COM_CODE;
            File.FILE_NAME      = DOCUMENT_TYPE_ID.AsString() + SECTION_GROUP_ID.AsString() + COVER_SHEET_SEND_ID.AsString() + HEADER_INPUT_ID.AsString() + ".pdf";
            File.FILE_SIZE      = Math.Round(bytes.Length * (Math.Pow(10, -6)), 4).AsDecimal();
            File.FILE_DATE      = DateTime.Now;
            File.CREATE_DT      = DateTime.Now;
            File.BLOB_FILE      = bytes;
            File.BLOB_FILE_HASH = GetFileHash(bytes);

            FileList.Add(File);

            return(FileList);
        }
Example #51
0
        public ActionResult reporting(int sub, string id)
        {
            var    lr   = new LocalReport();
            String path = Path.Combine(Server.MapPath("~/Report"), "Report_Patient.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
                return(View("index"));
            }
            List <View_Visit> att = new List <View_Visit>();

            using (Pathology_dbEntities1 entities = new Pathology_dbEntities1())
            {
                att = entities.View_Visit.Where(a => a.R_ID == sub).ToList();
            }
            ReportDataSource rds = new ReportDataSource("DataSet1", att);

            lr.DataSources.Add(rds);
            string reporttype = id;
            string minetype;
            string encoding;
            string filenameextension = id;
            string deviceinfo        =
                "<DeviceInfo>" +
                "<OutputFormat>DD</OutputFormat>" +
                "<PageWidth>8.5in</PageWidth>" +
                "<PageHeight>11in</PageHeight>" +
                "<MarginTop>0.5in</MarginTop>" +
                "<MarginLeft>11in</MarginLeft>" +
                "<MarginRight>11in</MarginRight>" +
                "<MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warning;
            string[]  stream;
            byte[]    renderedbytes;
            renderedbytes = lr.Render("PDF", deviceinfo, out minetype, out encoding, out filenameextension, out stream, out warning);

            return(File(renderedbytes, minetype));
        }
Example #52
0
        public static void renderPDFFromLocalReport(LocalReport report, string pdfFileName)
        {
            //code to render report as pdf document
            string encoding = String.Empty;
            string mimeType = String.Empty;
            string extension = String.Empty;
            Warning[] warnings = null;
            string[] streamids = null;

            byte[] byteArray = report.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);

            HttpContext.Current.Response.ContentType = "Application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfFileName);
            HttpContext.Current.Response.AddHeader("Content-Length", byteArray.Length.ToString());
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.BinaryWrite(byteArray);

            HttpContext.Current.Response.End();
        }
        public FileResult GetReport()
        {
            try
            {
                LocalReport lr = new LocalReport();
                lr.ReportPath = Server.MapPath("~/Content/Report/Report.rdlc");

                List <Book> cm = new List <Book>();
                using (AppDb dc = new AppDb())
                {
                    int id = int.Parse(TempData["bookId"].ToString());
                    cm = dc.Books.Where(x => x.Id == id).ToList();
                    TempData["bookId"] = Convert.ToInt32(TempData["bookId"].ToString());
                }
                ReportDataSource rd = new ReportDataSource("BookDataSet", cm);
                lr.DataSources.Add(rd);

                string reportType = "PDF";
                string mimeType;
                string encoding;
                string fileNameExtension;
                string 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));
            }
            catch (Exception)
            {
                throw;;
            }
        }
Example #54
0
        // Export the given report as an PDF (Portable Document Format) file.
        public Stream ExportPDF()
        {
            const string reportType = "PDF";
            string       encoding;
            string       fileNameExtension;
            string       mimeType;

            string[]  streams;
            Warning[] warnings;


            _reportPath = Path.Combine(this._reportPath, this._reportFile);

            LocalReport report = new LocalReport();

            report.ReportPath = _reportPath;

            report.DataSources.Add(new ReportDataSource("Sales", LoadSalesData()));

            string deviceInfo =
                @"<DeviceInfo>
                <OutputFormat>EMF</OutputFormat>
                <PageWidth>8.5in</PageWidth>
                <PageHeight>11in</PageHeight>
                <MarginTop>0.25in</MarginTop>
                <MarginLeft>0.25in</MarginLeft>
                <MarginRight>0.25in</MarginRight>
                <MarginBottom>0.25in</MarginBottom>
            </DeviceInfo>";

            //Render the report

            byte[] bytes =
                report.Render(reportType,
                              deviceInfo,
                              out mimeType,
                              out encoding,
                              out fileNameExtension,
                              out streams,
                              out warnings);

            return(new MemoryStream(bytes));;
        }
Example #55
0
        public FileContentResult VistaReporte_HojaRuta(string idOrdenCompra, string numeroFactura)
        {
            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo

            // Nota los datos creados en el dataset deben ser con el mismo nombre que tengan los Datos del Modelo
            LocalReport reporte_local = new LocalReport();
            // pasa la ruta donde se encuentra el reporte
            reporte_local.ReportPath = Server.MapPath("~/Report/hojaRuta.rdlc");
            // creamos un recurso de datos del tipo report
            ReportDataSource conjunto_datos = new ReportDataSource();
            // le asginamos al conjuto de datos el nombre del datasource del reporte
            conjunto_datos.Name = "DataSet1";
            List<hojaRutaFacturaInforme> hojaDeRutaInforme = new List<hojaRutaFacturaInforme>();
            if (Session["rol"] != null)
            {
                hojaDeRutaInforme.Add(new hojaRutaFacturaInforme(hojaRutaFactura.obtenerHojaRuta(idOrdenCompra, numeroFactura)));
            }
            // se le asigna el datasource el conjunto de datos desde el modelo
            conjunto_datos.Value = hojaDeRutaInforme;
            // se agrega el conjunto de datos del tipo report al reporte local
            reporte_local.DataSources.Add(conjunto_datos);
            // datos para renderizar como se mostrara el reporte
            string reportType = "PDF";
            string mimeType;
            string encoding;
            string fileNameExtension;
            string deviceInfo = "<DeviceInfo>" +
                 "  <OutputFormat>jpeg</OutputFormat>" +
                 "  <PageWidth>10in</PageWidth>" +
                 "  <PageHeight>12in</PageHeight>" +
                 "  <MarginTop>0.5in</MarginTop>" +
                 "  <MarginLeft>1in</MarginLeft>" +
                 "  <MarginRight>1in</MarginRight>" +
                 "  <MarginBottom>0.5in</MarginBottom>" +
                 "</DeviceInfo>";
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;
            //Se renderiza el reporte
            renderedBytes = reporte_local.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            // el reporte es mostrado como una imagen
            return File(renderedBytes, mimeType);
        }
        public FileResult RelTabelas()
        {
            var relatorio = db.GeraTabelas();

            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Models/relTabelas.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("dsRelatorios", relatorio);
            localReport.DataSources.Add(reportDataSource);

            string reportType = "Excel";
            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
            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>Excel</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,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
            //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);

            return File(renderedBytes, mimeType);
        }
        public ActionResult ReporteAmortizacion(int ID ,string FECHA_INICIO ,string FECHA_FINAL)
        {
            DateTime fechaIni = DateTime.ParseExact(FECHA_INICIO, "dd/MM/yyyy", null);
            DateTime fechaFin = DateTime.ParseExact(FECHA_FINAL, "dd/MM/yyyy", null);

            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Reportes/ReporteAmortizacion.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("DataSet1", repo.ReporteKardexCliente(ID, fechaIni, fechaFin));
            localReport.DataSources.Add(reportDataSource);
            string reportType = "PDF";
            string mimeType = "application/pdf";
            string encoding = "utf-8";
            string fileNameExtension = "pdf";
            string deviceInfo = string.Empty;
            Warning[] warnings = new Warning[1];
            string[] streams = new string[1];
            Byte[] renderedBytes;
            //Render the report
            renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
            return File(renderedBytes, mimeType);
        }
        public static void OutputToExcel(LocalReport localReport, string fileName, HttpResponse Response)
        {
            const string reportType = "Excel";
            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

            const string deviceInfo = "<DeviceInfo>" +
                                      "  <OutputFormat>Excel</OutputFormat>" +
                                      "  <OmitDocumentMap>false</OmitDocumentMap>" +
                                      "  <OmitFormulas>false</OmitFormulas>" +
                                      "  <RemoveSpace>0.125in</RemoveSpace>" +
                                      "  <SimplePageHeaders>false</SimplePageHeaders>" +
                                      "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;

            //Render the report
            byte[] renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);

            // Clear the response stream and write the bytes to the outputstream
            // Set content-disposition to "attachment" so that user is prompted to take an action
            // on the file (open or save)
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + fileNameExtension);
            Response.BinaryWrite(renderedBytes);
            Response.End();
        }
Example #59
0
        public ActionResult Index(string type = "PDF")
        {
            //List<TestInfo> list = GetList();
            DataTable list = GetList();
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Report/Report1.rdlc");

            ReportDataSource reportDataSource2 = new ReportDataSource("DataSet2", list);
            localReport.DataSources.Add(reportDataSource2);
            string reportType = type;
            string mimeType;
            string encoding;
            string fileNameExtension;

            string deviceInfo =
                "<DeviceInfo>" +
                "<OutPutFormat>" + type + "</OutPutFormat>" +
                "<PageWidth>11in</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;
            localReport.ReportEmbeddedResource = null;
            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings
                );
            return File(renderedBytes, mimeType);
            //return View();
        }
        public ActionResult PrintReport(string reportType)
        {
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/Reports/rptOgretmenler.rdlc");
            ReportDataSource reportDataSource = new ReportDataSource("DSOgretmenListe", TeacherManager.GetTeacherListForReport());

            localReport.DataSources.Add(reportDataSource);

            //string reportType = "Excel";
            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
            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>PDF</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>0.5in</MarginLeft>" +
                "  <MarginRight>0.5in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;
            //Render the report

            renderedBytes = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
            //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);
            return File(renderedBytes, mimeType);
        }