private void GeneratePDFReport() { string Grade = string.Empty; ; string Subject = string.Empty; ; string Course = string.Empty; ; string StudentId = string.Empty; ; if (Request.QueryString["Grade"] != null) { Grade = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Grade"].ToString()); } if (Request.QueryString["Subject"] != null) { Subject = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Subject"].ToString()); } if (Request.QueryString["Course"] != null) { Course = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["Course"].ToString()); } if (Request.QueryString["StudentId"] != null) { StudentId = Standpoint.Core.Classes.Encryption.DecryptString(Request.QueryString["StudentId"]); } var DParms = DistrictParms.LoadDistrictParms(); string ClientID = DParms.ClientID; string Year = DParms.Year; Microsoft.Reporting.WebForms.ReportViewer rptViewer = new Microsoft.Reporting.WebForms.ReportViewer(); rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials(reportUsername.Value, reportPassword.Value, reportDomain.Value); rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl.Value); rptViewer.ServerReport.ReportPath = reportPath.Value; rptViewer.ShowParameterPrompts = false; var reportParameterCollection = new ReportParameterCollection(); reportParameterCollection.Add(new ReportParameter("ClientID", ClientID)); reportParameterCollection.Add(new ReportParameter("Year", Year)); reportParameterCollection.Add(new ReportParameter("Grade", Grade)); reportParameterCollection.Add(new ReportParameter("Subject", Subject)); reportParameterCollection.Add(new ReportParameter("Course", Course)); reportParameterCollection.Add(new ReportParameter("StudentTGID", StudentId)); rptViewer.ServerReport.SetParameters(reportParameterCollection); rptViewer.ServerReport.Refresh(); Warning[] warnings; string[] streamids; string mimeType, encoding, extension; byte[] bytes = rptViewer.ServerReport.Render("PDF", string.Empty, out mimeType, out encoding, out extension, out streamids, out warnings); using (MemoryStream memoryStream = new MemoryStream(bytes)) { Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "inline; filename=AssessmentReportCard.pdf"); Response.AddHeader("content-length", bytes.Length.ToString()); Response.BinaryWrite(memoryStream.ToArray()); Response.Flush(); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ServerReport.ReportServerUrl = new Uri(WebConfigurationManager.AppSettings["ReportServer"]); System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter> paramList = new System.Collections.Generic.List<ReportParameter>(); paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter("Param1", "Value1")); paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter("Param2", "Value2")); rview.ServerReport.ReportPath = "/FlamingoSSRSReports/CustomerwiseInquiryReport"; rview.ServerReport.SetParameters(paramList); string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; string format = "Excel"; deviceInfo = "<DeviceInfo>" + "<Head1>True</Head1>" + "</DeviceInfo>"; byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Clear(); Response.ContentType = "application/excel"; Response.AddHeader("Content-disposition", "filename=output.xls"); Response.OutputStream.Write(bytes, 0, bytes.Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.Flush(); Response.Close(); }
//SMC public ActionResult SMC(string FacilityCode, string sdate, string edate) { int x = 0; //Boolean y = false; ReportsModel obj = new ReportsModel(); if (int.TryParse(FacilityCode, out x)) { obj.FacilityCode = System.Convert.ToInt32(FacilityCode); } DateTime?StartDate = DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime?EndDate = DateTime.ParseExact(edate, "dd/MM/yyyy", null); obj.StartDate = StartDate; obj.EndDate = EndDate; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; //reportViewer.Width = Unit.Percentage(900); //reportViewer.Height = Unit.Percentage(900); //List<spView_Admin_Calender_ScheduleAppointmentsGetAll_Result> titles = obj.GetDetailedReport(); reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\Report_WebTemplate_SMC_SLM.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ds_consumption", obj.SMC().ToList())); reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ds_header", obj.SMC_Header().ToList())); ViewBag.ReportViewer = reportViewer; return(View()); }
public void ProcessReportShowing(Microsoft.Reporting.WebForms.ReportViewer myReportViewer) { try { foreach (Microsoft.Reporting.WebForms.RenderingExtension re in myReportViewer.LocalReport.ListRenderingExtensions()) { ////屏蔽掉你需要取消的导出功能 Excel PDF WORD //if (re.Name == "PDF") //{ // FieldInfo fi = re.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic); // fi.SetValue(re, false); //} //else if (re.Name == "WORDOPENXML") { FieldInfo fi = re.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic); fi.SetValue(re, false); } } //谷歌兼容性修复 myReportViewer.SizeToReportContent = true; myReportViewer.ShowPrintButton = false; } catch { } }
public ActionResult GenerateAndDisplayReport() { //ReportViewer reportViewer = new ReportViewer(); //reportViewer.ProcessingMode = ProcessingMode.Remote; //reportViewer.ServerReport.ReportPath = "/AdventureWorks 2012/Sales_by_Region"; //reportViewer.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer/"); //ViewBag.ReportViewer = reportViewer; ReportViewer rpvReports = new Microsoft.Reporting.WebForms.ReportViewer(); LocalReport localReport = new LocalReport(); return(View()); System.Data.DataSet dsLocalReport = new System.Data.DataSet(); ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\YourLocalReport.rdlc"; reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsLocalReport", dsLocalReport.Tables["SampleTable"])); ViewBag.ReportViewer = reportViewer; }
private void OpenReportInPDF(Microsoft.Reporting.WebForms.ReportViewer rpViewerObj) { var path = Server.MapPath("~/CrystalPersonInfo.pdf"); string mimeType, encoding, extension; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; string format = "PDF"; byte[] bytes = rpViewerObj.LocalReport.Render(format, "", out mimeType, out encoding, out extension, out streamids, out warnings); FileStream fs = new FileStream(path, FileMode.Create); byte[] data = new byte[fs.Length]; fs.Write(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "Application/pdf"; //Get the physical path to the file. string FilePath = Server.MapPath("~/CrystalPersonInfo.pdf"); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); Response.End(); }
private void OpenReportInPDF(Microsoft.Reporting.WebForms.ReportViewer rpViewerObj) { string reportType = "PDF"; string mimeType; string encoding; string fileNameExtension; string deviceInfo = "<DeviceInfo>" + "<OutputFormat>PDF</OutputFormat>" + "</DeviceInfo>"; Warning[] warnings; string[] streams; byte[] renderedBytes; //Render the report renderedBytes = rpViewerObj.LocalReport.Render( reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=UniSoftReport." + fileNameExtension); Response.BinaryWrite(renderedBytes); Response.End(); }
public ActionResult RelatorioPedido() { Usuario admin = (Usuario)HttpContext.Session["admin"]; if (admin == null) { return(View("Login")); } var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; viewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"report/RelatorioPedido.rdlc"; ReportDataSource datasource = new ReportDataSource(); datasource.Name = "DataSet1"; datasource.Value = PedidoBO.ListarTodosPedidos(); viewer.LocalReport.DataSources.Add(datasource); viewer.SizeToReportContent = true; viewer.Width = System.Web.UI.WebControls.Unit.Pixel(800); viewer.Height = System.Web.UI.WebControls.Unit.Pixel(1200); ViewBag.ReportViewer = viewer; return(View("Relatorio")); }
public ActionResult All_Products(string sdate, string edate, int?_emmergency) { bool?emergency = null; if (_emmergency == 1) { emergency = false; } else if (_emmergency == 2) { emergency = true; } ProductModel obj = new ProductModel(); DateTime? StartDate = DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime? EndDate = DateTime.ParseExact(edate, "dd/MM/yyyy", null); // obj.GetAll(StartDate, EndDate); //obj.EndDate = EndDate; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Views\Queries\ALLProducts.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("aLLProducts", obj.GetOrders(StartDate, EndDate, emergency).ToList())); ViewBag.ReportViewer = reportViewer; return(View()); }
public void GenerateSLIIReport(string ProspectCode) { Microsoft.Reporting.WebForms.ReportViewer vr = new Microsoft.Reporting.WebForms.ReportViewer(); System.Data.SqlClient.SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); con.Open(); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "USP_GetSLIIEXAMAPPLICATIONPDF"; cmd.Parameters.AddWithValue("@ProspectCode", ProspectCode); List <DataSet> dslst = new List <DataSet>(); DataSet ds = new DataSet(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { dslst.Add(ds); ReportParameter[] parameters = new ReportParameter[1]; parameters[0] = new ReportParameter("ProspectCode", ProspectCode); byte[] bytes = GenerateRDLCReports(dslst, null, @"~/Reports/AgentonBoarding/SLIIExamination.rdlc"); RenderReports(bytes, "AIA SLII Examination Letter"); } }
public static ReportDados ToReport <T>(this IEnumerable <T> dados, string fileRdlc, enumReportFormat format, string dataSetName) { ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); rv.ProcessingMode = ProcessingMode.Local; rv.LocalReport.ReportPath = fileRdlc; ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = dataSetName; reportDataSource.Value = ConvertToDataTable(dados); rv.LocalReport.DataSources.Add(reportDataSource); byte[] streamBytes = null; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streamids = null; Warning[] warnings = null; streamBytes = rv.LocalReport.Render(format.ToString(), null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); return(new ReportDados() { Content = streamBytes, MimeType = mimeType, Encoding = encoding, FileNameExtension = filenameExtension, Warnings = warnings }); }
ConfigReportViewer() { var reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; reportViewer.ViewStateMode = System.Web.UI.ViewStateMode.Inherit; reportViewer.SizeToReportContent = true; reportViewer.Width = System.Web.UI.WebControls.Unit.Percentage(110); reportViewer.Height = System.Web.UI.WebControls.Unit.Percentage(100); reportViewer.AsyncRendering = true; reportViewer.ZoomMode = Microsoft.Reporting.WebForms.ZoomMode.FullPage; reportViewer.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFBF7"); reportViewer.ShowPrintButton = true; reportViewer.ShowRefreshButton = false; reportViewer.ShowZoomControl = true; PermissionSet permissions = new PermissionSet(PermissionState.None); permissions.AddPermission(new FileIOPermission(PermissionState.Unrestricted)); permissions.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); reportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(permissions); Assembly asm = Assembly.Load(Assembly.GetExecutingAssembly().FullName); AssemblyName asm_name = asm.GetName(); reportViewer.LocalReport.AddFullTrustModuleInSandboxAppDomain(new StrongName(new StrongNamePublicKeyBlob(asm_name.GetPublicKeyToken()), asm_name.Name, asm_name.Version)); return(reportViewer); }
public void GeneratePersonalData(string ProspectCode) { Microsoft.Reporting.WebForms.ReportViewer vr = new Microsoft.Reporting.WebForms.ReportViewer(); System.Data.SqlClient.SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); //System.Data.SqlClient.SqlConnection(@"data source = issdbs01; database = AVOJSLife; Uid = sa_policyjs; Pwd = iNube@123;"); con.Open(); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[USP_Getpersonaldatapdf]"; cmd.Parameters.AddWithValue("@ProspectCode", ProspectCode); List <DataSet> dslst = new List <DataSet>(); DataSet ds = new DataSet(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { dslst.Add(ds); ReportParameter[] parameters = new ReportParameter[1]; parameters[0] = new ReportParameter("ProspectCode", ProspectCode); byte[] bytes = GenerateRDLCReports(dslst, null, @"~/Reports/AgentonBoarding/PersonalDataForm.rdlc"); RenderReports(bytes, "AIA Personal Data Letter"); } }
public bool CreateReport(ref Microsoft.Reporting.WebForms.ReportViewer ReportViewer) { ReportViewer.LocalReport.ReportPath = System.Configuration.ConfigurationManager.AppSettings["ReportPath"].ToString() + _reportConfig.ReportName; SqlDataSource sqlDS = new SqlDataSource(); sqlDS.ConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString(); sqlDS.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; sqlDS.SelectCommand = _reportConfig.StoreProcedureName; foreach (var param in _reportConfig.Parameters) { sqlDS.SelectParameters.Add(param.Key, param.Value.ToString()); } ReportDataSource datasource1 = new ReportDataSource(_reportConfig.ReportDataSetName, sqlDS); ReportViewer.LocalReport.DataSources.Clear(); ReportViewer.LocalReport.DataSources.Add(datasource1); List <ReportParameter> rptParams = new List <ReportParameter>(); foreach (var param in _reportConfig.Parameters) { ReportParameter rptParam = new ReportParameter(param.Key, param.Value.ToString()); rptParams.Add(rptParam); } ReportViewer.LocalReport.SetParameters(rptParams); ReportViewer.LocalReport.Refresh(); return(true); }
public ActionResult OrderTracking(string Order_Number) { //int x = 0; //Boolean y = false; ReportsModel obj = new ReportsModel(); //if (int.TryParse(ProductCategory, out x)) // obj.ProductCategoryId = System.Convert.ToInt32(ProductCategory); obj.OrderNumber = Order_Number; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; //reportViewer.Width = Unit.Percentage(900); //reportViewer.Height = Unit.Percentage(900); //List<spView_Admin_Calender_ScheduleAppointmentsGetAll_Result> titles = obj.GetDetailedReport(); reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\OrderStatus.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("OrderStatus", obj.GetCurrentTracking().ToList())); reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("OrderDetails", obj.GetTrackingDetails().ToList())); //reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ds_regional_activity", obj.GetCoARegionalMeetings().ToList())); //reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ds_activity_distribution", obj.GetCoADistributionOfActivities().ToList())); //reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("CoA_AcitivitiesByFundingType", obj.GetCoAActivitiesByFundingType().ToList())); //reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("CoA_AcitivitiesByMeetingType", obj.GetCoAActivitiesByMeetingType().ToList())); ViewBag.ReportViewer = reportViewer; return(View()); }
public ActionResult Fluconazole(string sdate, string edate, int?_emmergency) { bool?emergency = null; if (_emmergency == 1) { emergency = false; } else if (_emmergency == 2) { emergency = true; } ARTModels obj = new ARTModels(); DateTime? StartDate = DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime? EndDate = DateTime.ParseExact(edate, "dd/MM/yyyy", null); // obj.GetAll(StartDate, EndDate); //obj.EndDate = EndDate; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Views\Queries\Fluconazole.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("fluconazole", obj.GetTreatment_Fluconazole(StartDate, EndDate, emergency))); ViewBag.ReportViewer = reportViewer; return(View()); }
public HttpResponseMessage SalesReportView(int id, SalesGetReportEntity obj) { HttpResponseMessage message; try { //dsRptInvoice //DalLayer dal = new DalLayer(); var result = _POMasterService.ReturnSalesList(id, obj); ReportDataSource rds = new ReportDataSource(); rds.Name = "DataSet3"; rds.Value = result.Tables[0]; ReportDataSource rds1 = new ReportDataSource(); rds1.Name = "DataSet4"; rds1.Value = result.Tables[1]; ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); rv.ProcessingMode = ProcessingMode.Local; rv.LocalReport.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/report/SalesReport.rdlc"); // Add the new report datasource to the report. rv.LocalReport.DataSources.Add(rds); rv.LocalReport.DataSources.Add(rds1); rv.LocalReport.Refresh(); //rv.LocalReport. byte[] streamBytes = null; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streamids = null; Warning[] warnings = null; streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); string filename = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8); string locationPath = System.Web.Hosting.HostingEnvironment.MapPath("~/report/"); using (FileStream stream = new FileStream(locationPath + filename + ".pdf", FileMode.Create)) { stream.Write(streamBytes, 0, streamBytes.Length); } ResultSales rs = new ResultSales(); rs.data = result; rs.path = filename + ".pdf"; message = Request.CreateResponse(HttpStatusCode.OK, rs); } catch (Exception ex) { //_invoice.errorLog(ex.Message.ToString()); message = Request.CreateResponse(HttpStatusCode.BadRequest, new { msgText = "Something wrong. Try Again!" }); } return(message); }
public PagingState(ReportNavigation navigationControl) { _reportViewer = (ReportViewer)navigationControl.Parent.FindControl(navigationControl.ReportViewerID); _currentPage = (HiddenField)navigationControl.Parent.FindControl(navigationControl.CurrentPageControlID); _dirtyPage = (HiddenField)navigationControl.Parent.FindControl(navigationControl.DirtyPageID); _dirtyPage.Value = bool.FalseString; InitCurrentPage(); }
private static void GuardaCatalogos(List <Categorias> categorias) { List <FutureVisitsModel> lstcatalogos = new List <FutureVisitsModel>(); FutureVisitsModel cat = new FutureVisitsModel(); foreach (var categoria in categorias) { cat.id = categoria.Id.ToString(); cat.nombre = categoria.Nombre; foreach (var marca in categoria.Submarcas) { //cat.descripcion = marca.Descripcion; //cat.marca = marca.Marca; //cat.subMarca = marca.Submarca; //cat.claveBanorte = marca.ClaveBanorte; //cat.anio = marca.Anio.ToString(); cat.idSM = marca.Id.ToString(); cat.nombreSM = marca.Nombre; //cat.idLoc = local.Id.ToString(); //cat.municipio = local.Municipio; //cat.estado = local.Estado; lstcatalogos.Add(cat); cat = new FutureVisitsModel(); } //lstcatalogos.Add(cat); } //Catalogos catal = new Catalogos(); //foreach (var catalogo in catalogos.Result) //{ // catal.Codigo = catalogo.Codigo; // catal.Descripcion = catalogo.Descripcion; //} Microsoft.Reporting.WebForms.ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; rv.ProcessingMode = ProcessingMode.Remote; rv.LocalReport.ReportPath = @"C:/Users/SaoSistemas/Desktop/atlasws/atlasws/Report9.rdlc"; rv.LocalReport.DataSources.Clear(); rv.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", lstcatalogos)); byte[] bytes = rv.LocalReport.Render("EXCEL", null, out mimeType, out encoding, out extension, out streamids, out warnings); string absoluteFileName = Path.Combine(@"C:/Users/SaoSistemas/Desktop/atlasws", "SubMarca_VehRegularizados.xls"); FileStream file = new FileStream(absoluteFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); file.Write(bytes, 0, bytes.Length); file.Close(); file.Dispose(); }
private void ExportToPdf() { Microsoft.Reporting.WebForms.ReportViewer oViewer = new Microsoft.Reporting.WebForms.ReportViewer(); if (reportName != string.Empty) { oViewer.LocalReport.ReportEmbeddedResource = reportName; } oViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(RptSubreportProcessingEventHandler); oViewer.LocalReport.DataSources.Clear(); ReportDataSource ds = new ReportDataSource(reportDatasourceName, dataSource); oViewer.LocalReport.DataSources.Add(ds); // David [2008-10-27] : In case some reports using extrenal images, the Property 'EnableExternalImages' should be enabled. oViewer.LocalReport.EnableExternalImages = true; int paramCount = this.parameters.GetLength(0); if (paramCount > 0) { ReportParameter[] param = new ReportParameter[paramCount]; for (int i = 0; i < paramCount; i++) { param[i] = new ReportParameter(parameters[i, 0], parameters[i, 1]); } oViewer.LocalReport.SetParameters(param); } oViewer.ProcessingMode = ProcessingMode.Local; oViewer.LocalReport.Refresh(); Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = oViewer.LocalReport.Render( "PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings ); HttpResponse response = VWGContext.Current.HttpContext.Response; response.Clear(); response.ClearHeaders(); response.ContentType = "application/pdf"; response.AddHeader("content-disposition", "attachment; filename=\"Export.pdf\""); response.BinaryWrite(bytes); response.Flush(); response.End(); }
protected void BindDataSource(MsReportViewer reportViewer, IReport report) { if (report.ReportProcessingLocation is ILocalReportProcessingLocation) { reportViewer.ProcessingMode = MsProcessingMode.Local; BindLocalReport(reportViewer.LocalReport, report); } else { reportViewer.ProcessingMode = MsProcessingMode.Remote; BindServerReport(reportViewer.ServerReport, report); } }
private void ConfigureLogoParameter(string logo, Microsoft.Reporting.WebForms.ReportViewer viewer) { if (!string.IsNullOrWhiteSpace(logo)) { _logger.Debug($"Start SetParameters ImagePath: {string.Join("", logo.Take(250))}"); if (logo.Contains("http")) { viewer.LocalReport.SetParameters(new ReportParameter("ImagePath", logo)); } else { viewer.LocalReport.SetParameters(new ReportParameter("ReportLogo", logo)); } _logger.Debug($"End SetParameters ImagePath: {string.Join("", logo.Take(250))}"); } }
public Engine(string baseUrl, string reportPath, string reportName, NameValueCollection querystring) { this.BaseUrl = baseUrl; this.ReportPath = reportPath; this.ReportName = reportName; this.ErrorMessages = new List <ErrorMessage>(); this.CurrentReportViewer = new WebForms.ReportViewer { ProcessingMode = WebForms.ProcessingMode.Local, SizeToReportContent = true }; _reportParameters = new Hashtable(); this.CurrentReportViewer.ReportError += CurrentReportViewer_ReportError; SetParameters(querystring); }
private void SaveReport() { //clsNum2Word csw = new clsNum2Word(); ExamUserComponent ec = new ExamUserComponent(); int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; int StudId = CurrentSession.CurrStudent.StudentId; string FileName = CurrentSession.FileName.ToString(); bool isModExam = CurrentSession.CurrStudent.isModExam; DataSet dsComp = ec.GetCompInfo(); DataSet dsExamRes = ec.GetExamResultPrint(ResDetId, StudId, 1, false); DataSet dsExResSum = ec.GetExamResultPrint(ResDetId, StudId, 2, false); Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ProcessingMode = ProcessingMode.Local; rview.LocalReport.ReportPath = Server.MapPath("~/eReports/Rdlc/rpt_examResult.rdlc"); rview.LocalReport.DataSources.Clear(); rview.LocalReport.DataSources.Add(new ReportDataSource("dsCompInfo", dsComp.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsResPrint", dsExamRes.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsExamSum", dsExResSum.Tables[0])); rview.LocalReport.Refresh(); string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; //Desired format goes here (PDF, Excel, or Image) deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"; byte[] bytes = rview.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Clear(); System.IO.FileStream oFileStream = null; string strFilePath = string.Empty; //strFilePath = ConfigurationManager.AppSettings["AttachFile"].ToString() + FileName + ".pdf";// Server.MapPath("../EmailAttachments/" + filename1 + ".pdf"); //strFilePath = strFilePath.Replace("\\\\", "\\"); strFilePath = Server.MapPath("~/AttachFile/" + FileName + ".pdf"); oFileStream = new System.IO.FileStream(strFilePath, System.IO.FileMode.Create); oFileStream.Write(bytes, 0, bytes.Length); oFileStream.Close(); //string script = string.Format("~/eReports/PdfReport.aspx?FileName={0}", FileName); //ScriptManager.RegisterStartupScript(this, this.GetType(), "openprintwindow", "javascript:window.open('" + ResolveClientUrl(script) + "',null,'width=850px,height=630px,scrollbars=yes,,resizable=yes,toolbar=no,menubar=no,location=no');", true); }
public FileResult File() { ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); rv.ProcessingMode = ProcessingMode.Local; rv.LocalReport.ReportPath = Server.MapPath("~/AuditingLogs2/AuditReport.rdlc"); rv.LocalReport.Refresh(); byte[] streamBytes = null; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streamids = null; Warning[] warnings = null; streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); return File(streamBytes, mimeType, "AuditReport.pdf"); }
public byte[] Generate(string reportPath, string logo, IDictionary <string, string> paramenters, IDictionary <string, object[]> dataSources, string format, out string extension) { try { Warning[] warnings; string[] streamids; string mimeType; string encoding; var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); viewer.ProcessingMode = ProcessingMode.Local; viewer.LocalReport.EnableHyperlinks = true; viewer.LocalReport.ReportPath = reportPath; _logger.Debug($"Report Path: {reportPath}"); viewer.LocalReport.EnableExternalImages = true; foreach (var d in paramenters) { _logger.Debug($"Start SetParameters: {d.Key}"); viewer.LocalReport.SetParameters(new ReportParameter(d.Key, d.Value)); _logger.Debug($"End SetParameters: {d.Key}"); } ConfigureLogoParameter(logo, viewer); foreach (var d in dataSources) { var reportDataSource = new ReportDataSource(d.Key, d.Value); viewer.LocalReport.DataSources.Add(reportDataSource); } _logger.Debug($"Start Render report: {reportPath}"); byte[] bytes = viewer.LocalReport.Render( format, null, out mimeType, out encoding, out extension, out streamids, out warnings); _logger.Debug($"End Render report: {reportPath}"); return(bytes); } catch (Exception ex) { _logger.Error(ex.Message, ex); throw; } }
private void Load(Microsoft.Reporting.WebForms.ReportViewer rptViewer, string reportType, ReportParameter[] reportParma) { if (string.IsNullOrEmpty(reportType)) { throw new Exception("Null ReportParameter Or Null Report Name"); } rptViewer.ProcessingMode = ProcessingMode.Remote; rptViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportURL"]); rptViewer.ServerReport.ReportPath = "/EMS.Report/" + reportType; rptViewer.ServerReport.SetParameters(reportParma); rptViewer.ServerReport.DisplayName = reportType + "_" + DateTime.Now.Ticks.ToString(); rptViewer.ShowCredentialPrompts = false; rptViewer.ShowPrintButton = true; rptViewer.ShowParameterPrompts = false; rptViewer.ShowPromptAreaButton = false; rptViewer.ShowToolBar = true; rptViewer.ShowPrintButton = true; rptViewer.ShowReportBody = true; rptViewer.ServerReport.Refresh(); }
public FileResult File() { ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); rv.ProcessingMode = ProcessingMode.Local; rv.LocalReport.ReportPath = Server.MapPath("~/Reports/RDLC/Report1.rdlc"); rv.LocalReport.Refresh(); byte[] streamBytes = null; string mimeType = ""; string encoding = ""; string filenameExtension = ""; string[] streamids = null; Warning[] warnings = null; streamBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); return(File(streamBytes, mimeType, "Report1.pdf")); }
private void ShowReport() { ExamUserComponent ec = new ExamUserComponent(); int ResDetId = CurrentSession.CurrStudent.ExamResultDetail.ExmResultDetailId; int StudId = CurrentSession.CurrStudent.StudentId; string isDetailed = "0"; //if (chkIsDetailed.Checked) //isDetailed = "2"; bool isModExam = CurrentSession.CurrStudent.isModExam; string FileName = hdnFileName.Value; DataSet dsComp = ec.GetCompInfo(); DataSet dsExamRes = ec.GetExamResultPrint(ResDetId, StudId, 1, false); DataSet dsExResSum = ec.GetExamResultPrint(ResDetId, StudId, 2, false); Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ProcessingMode = ProcessingMode.Local; rview.LocalReport.ReportPath = Server.MapPath("~/eReports/Rdlc/rpt_examResult.rdlc"); rview.LocalReport.DataSources.Clear(); rview.LocalReport.DataSources.Add(new ReportDataSource("dsCompInfo", dsComp.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsResPrint", dsExamRes.Tables[0])); rview.LocalReport.DataSources.Add(new ReportDataSource("dsExamSum", dsExResSum.Tables[0])); rview.LocalReport.Refresh(); string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; //Desired format goes here (PDF, Excel, or Image) deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"; byte[] bytes = rview.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.ContentType = mimeType; System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=Result.PDF"); System.Web.HttpContext.Current.Response.BinaryWrite(bytes); System.Web.HttpContext.Current.Response.End(); }
// GET: RPTContrato public ActionResult ImpressaoContrato() { var ds = Reports.Data.DsImpressaoContrato.ObterRelatorio(); var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); //viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; viewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\Rpt\Rpt_ImpressaoContrato.rdlc"; viewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("dsDetalhe1", (System.Data.DataTable)ds.PR_IMPRESSAO_CONTRATO)); viewer.SizeToReportContent = true; viewer.Width = System.Web.UI.WebControls.Unit.Percentage(100); viewer.Height = System.Web.UI.WebControls.Unit.Percentage(100); ViewBag.ReportViewer = viewer; return(View()); }
public static byte[] GeneratePdf(string report, string server, IList <WebReporting.ReportParameter> parameters) { string mimeType; string encoding; string[] streamids; WebReporting.Warning[] warnings; var extension = "pdf"; WebReporting.ReportViewer rpv = new WebReporting.ReportViewer(); rpv.ProcessingMode = WebReporting.ProcessingMode.Remote; rpv.ServerReport.ReportPath = report; rpv.ServerReport.ReportServerUrl = new Uri(server); rpv.ServerReport.SetParameters((IEnumerable <WebReporting.ReportParameter>)parameters); byte[] bytes = rpv.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); return(bytes); }
public ActionResult ReportingRatesCopy(string productCategory, string sdate, string edate) { ReportsModel obj = new ReportsModel(); if (productCategory == "") { productCategory = null; } obj.productCategory = productCategory; DateTime?StartDate; //= DateTime.ParseExact(sdate, "dd/MM/yyyy", null); DateTime?EndDate; //= DateTime.ParseExact(edate, "dd/MM/yyyy", null); if ((!sdate.Contains("null") && sdate != "") || (!edate.Contains("null") && edate != "")) { StartDate = DateTime.ParseExact(sdate, "dd/MM/yyyy", null); EndDate = DateTime.ParseExact(edate, "dd/MM/yyyy", null); } else { StartDate = null; // Convert.ToDateTime(DBNull.Value); EndDate = null; // Convert.ToDateTime(DBNull.Value); } obj.StartDate = StartDate; obj.EndDate = EndDate; Microsoft.Reporting.WebForms.ReportViewer reportViewer = new Microsoft.Reporting.WebForms.ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; reportViewer.SizeToReportContent = true; reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\LMIS_Reports\Reporting_Rates.rdlc"; reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ReportingRates", obj.GetReportingRatesCopy().ToList())); ViewBag.ReportViewer = reportViewer; return(View()); }
public string DownloadBalanceSheet(DateTime dtStart, DateTime dtEnd) { using (AprosysAccountingEntities db = new AprosysAccountingEntities()) { try { BO_BalanceSheet RetainedEarning = GetRetainedEarning(dtStart, dtEnd, db); List <BO_BalanceSheet> exp = GetBalanceSheetByDate(dtStart, dtEnd); //var exp = db.GetBalanceSheetByDate(dtStart, dtEnd).ToList(); if (RetainedEarning != null) { exp.Add(RetainedEarning); } Microsoft.Reporting.WebForms.ReportViewer rv = new Microsoft.Reporting.WebForms.ReportViewer(); rv.LocalReport.ReportPath = "Reports/Definitions/BalanceSheet.rdlc"; ReportDataSource rd = new ReportDataSource(); string rptName = db.ReportConfigs.First(x => x.active == true && x.repoConfigID == 12).title; ReportParameter[] parameters = new ReportParameter[6]; parameters[0] = new ReportParameter("TitleParam", rptName != "" ? rptName : "MOMAND ENTERPRISES"); parameters[1] = new ReportParameter("StartDate", dtStart.ToString("yyyy-MM-dd")); parameters[2] = new ReportParameter("EndDate", dtEnd.ToString("yyyy-MM-dd")); parameters[3] = new ReportParameter("TotalAssetsAmount", exp.Where(x => x.HeadAccount == 1).Sum(x => (x.DEBIT - x.Credit)).ToString()); parameters[4] = new ReportParameter("TotalLiabilities", exp.Where(x => x.HeadAccount == 2).Sum(x => (x.Credit - x.DEBIT)).ToString()); parameters[5] = new ReportParameter("TotalEquity", exp.Where(x => x.HeadAccount == 3).Sum(x => (x.Credit - x.DEBIT)).ToString()); rd.Value = exp; rd.Name = "DataSet1"; rv.LocalReport.SetParameters(parameters); rv.LocalReport.DataSources.Add(rd); byte[] bt = rv.LocalReport.Render("PDF"); return(WriteBytesToTempFile(bt, ".pdf")); } catch (Exception ex) { //Logger.Write("DownloadAuthReportByDate", ex.Message, ex.StackTrace, Logger.LogType.ErrorLog); throw; } } }
private void LoadReportSourceData(string value) { try { DataSet CompanyList = new DataSet(); Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); switch (value) { case "Voucher": { String orgKey = "1";//(String)Session["OrgKey"]; String voucherNo = (String)Session["VoucherNo"]; if (orgKey.IsNotNullOrEmpty()) { ReportManager manager = new ReportManager(); CompanyList = manager.GetCompany(orgKey); ReportDataSources = manager.GetVoucherDataSources(voucherNo); } rview.LocalReport.ReportPath = Report.ReportPath; ReportDataSource companyDatasource = new ReportDataSource("Company", CompanyList.Tables["spGetCompany"]); ReportDataSource masterDatasource = new ReportDataSource("Voucher", ReportDataSources.Tables["spPreviewVoucher"]); rpViewer.LocalReport.DataSources.Add(companyDatasource); rview.LocalReport.DataSources.Add(companyDatasource); rview.LocalReport.DataSources.Add(masterDatasource); SetReportParameters(value, rview); OpenReportInPDF(rview); //rview.LocalReport.Refresh(); break; }//Transaction case "PO": { String poID = (String)Session["POID"]; ReportManager manager = new ReportManager(); ReportDataSources = manager.GetPODataSources(poID); rview.LocalReport.ReportPath = Report.ReportPath; ReportDataSource masterDatasource = new ReportDataSource("PurchaseOrder", ReportDataSources.Tables["sprptPurchaseOrder"]); rview.LocalReport.DataSources.Add(masterDatasource); SetReportParameters(value, rview); OpenReportInPDF(rview); //rview.LocalReport.Refresh(); break; } case "Transaction": { String StockTransID = (String)Session["StockTransID"]; ReportManager manager = new ReportManager(); ReportDataSources = manager.GetAllTransactionDataSources(StockTransID); rview.LocalReport.ReportPath = Report.ReportPath; ReportDataSource masterDatasource = new ReportDataSource("DataSet1", ReportDataSources.Tables["sprptStorckTransactionAll"]); rview.LocalReport.DataSources.Add(masterDatasource); SetReportParameters(value, rview); OpenReportInPDF(rview); //rview.LocalReport.Refresh(); break; } case "Requisition": { String RequisitionID = (String)Session["RequisitionID"]; ReportManager manager = new ReportManager(); ReportDataSources = manager.GetAllRequisitionDataSources(RequisitionID); rview.LocalReport.ReportPath = Report.ReportPath; ReportDataSource masterDatasource = new ReportDataSource("Requisition", ReportDataSources.Tables["sprptRequisitionAll"]); rview.LocalReport.DataSources.Add(masterDatasource); SetReportParameters(value, rview); OpenReportInPDF(rview); //rview.LocalReport.Refresh(); break; } } } catch (Exception ex) { //Message.ShowErrorMessage("Error: <br>" + ex.Message + "<br>Call Stack: <br>" + ex.StackTrace); } }