コード例 #1
0
        //Exportar Excel
        private void m_exp_xlsx_Click(object sender, EventArgs e)
        {
            RenderingExtension[] list_exp = rep_view.LocalReport.ListRenderingExtensions();
            RenderingExtension   ext_exp  = list_exp[1];

            rep_view.ExportDialog(ext_exp);
        }
コード例 #2
0
        private void ExportToFile()
        {
            try
            {
                var x = reportViewer1.LocalReport.ListRenderingExtensions();
                RenderingExtension render_ = null;


                render_ = x[5];


                if (render_ != null)
                {
                    var DialogResult = reportViewer1.ExportDialog(render_);
                    if (DialogResult == DialogResult.OK)
                    {
                        MessageBox.Show("Done!");
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #3
0
ファイル: Utility.cs プロジェクト: pangxb/SchoolHealth
        /// <summary>
        /// Exports the report.
        /// </summary>
        /// <param name="viewer">The viewer.</param>
        /// <param name="index">
        /// The index.
        /// 0 ---> doc
        /// 1 ---> xls
        /// 2 ---> pdf
        /// </param>
        /// <returns></returns>
        ///

        internal static bool ExportReport(ReportViewer viewer, ExportType index)
        {
            if (viewer.LocalReport.DataSources.Count == 0)
            {
                return(false);
            }
            Type t = viewer.GetType();
            RenderingExtension re = null;

            RenderingExtension[] extensionArray = viewer.LocalReport.ListRenderingExtensions();

            try
            {
                re = extensionArray[(int)index];

                if (re != null)
                {
                    ReportExportEventArgs e = new ReportExportEventArgs(re);
                    string methodName       = "OnExport";
                    t.InvokeMember(methodName, flags | BindingFlags.InvokeMethod, null, viewer, new object[] { null, e });
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// The ABCAnnadhanamReorts_Load.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/>.</param>
        /// <param name="e">The e<see cref="EventArgs"/>.</param>
        private void ABCAnnadhanamReorts_Load(object sender, EventArgs e)
        {
            DateTime periodFrom = new DateTime(dtPeriodFrom.Value.Year, dtPeriodFrom.Value.Month, dtPeriodFrom.Value.Day, 12, 0, 0);
            DateTime periodTo   = new DateTime(dtPeriodTo.Value.Year, dtPeriodTo.Value.Month, dtPeriodTo.Value.Day, 12, 0, 0);

            string             exportOption = "Excel";
            RenderingExtension extension    = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension, false);
            }

            string             exportOption1 = "Word";
            RenderingExtension extension1    = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption1, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension1, false);
            }
            tblAnnadhanamDetailsTableAdapter.FillByAnnadhanamDate(ABCAnnadhanamReportsDataset.tblAnnadhanamDetails, periodFrom, periodTo);
            reportViewer1.RefreshReport();
        }
コード例 #5
0
        /// <summary>
        /// Metodo auxiliar que esconde la extensión que se desea deshabilitar
        /// </summary>
        /// <param name="extension">Nombre de la extensión a ocultar.</param>
        /// <remarks>
        /// Autor: William Vásquez R. - INTRGRUPO\wvasquez
        /// FechaDeCreacion: 28/02/2013
        /// UltimaModificacionPor: William Vásquez R. - INTRGRUPO\wvasquez
        /// FechaDeUltimaModificacion: 28/02/2013
        /// EncargadoSoporte: William Vásquez R. - INTRGRUPO\wvasquez
        /// Descripción:
        /// </remarks>
        private static void ReflectivelySetVisibilityFalse(RenderingExtension extension)
        {
            FieldInfo info = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);

            if (info != null)
            {
                info.SetValue(extension, false);
            }
        }
コード例 #6
0
        private void ReflectivelySetVisibilityFalse(RenderingExtension extension)
        {
            FieldInfo info = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);

            if (info != null)
            {
                info.SetValue(extension, false);
            }
        }
コード例 #7
0
        /// <summary>
        /// Dissable specific or single report rendering extension
        /// </summary>
        /// <param name="rptViewerId">Report control Id</param>
        /// <param name="option">The internal or displayed extension name e.g CSV, Word, Power Point</param>
        public void DissableReportExportOptions(ReportViewer rptViewerId, string option)
        {
            RenderingExtension renderingExtendion = rptViewerId.ServerReport.ListRenderingExtensions().ToList <RenderingExtension>().Find(x => x.Name.Equals(option, StringComparison.OrdinalIgnoreCase));

            if (renderingExtendion != null)
            {
                FieldInfo info = renderingExtendion.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                info.SetValue(renderingExtendion, false);
            }
        }
コード例 #8
0
        protected void CustomizeWordNotVisible()
        {
            string             exportOption = "WordOpenXml";
            RenderingExtension extension    = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension, false);
            }
        }
コード例 #9
0
        private void OcultarOpcaoExportar(string tipo)
        {
            string             exportOption = tipo;
            RenderingExtension extension    = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.LocalizedName.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension, false);
            }
        }
コード例 #10
0
        private void ReflectivelySetVisibilityFalse(RenderingExtension extension)
        {
            var info = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);
            if (info != null)
            {
                var actualExtension = info.GetValue(extension);
                if (actualExtension != null)
                    info.SetValue(extension, false);
            }

            this.SetMarginsAndOrientation();
        }
コード例 #11
0
        protected void ReportViewer_OnLoad(object sender, EventArgs e)
        {
            //string exportOption = "Excel";
            // string exportOption1 = "Word";
            string             exportOption = "PDF";
            RenderingExtension extension    = ReportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension, false);
            }
        }
コード例 #12
0
        private void ReflectivelySetVisibilityFalse(RenderingExtension extension)
        {
            var info = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);

            if (info != null)
            {
                var actualExtension = info.GetValue(extension);
                if (actualExtension != null)
                {
                    info.SetValue(extension, false);
                }
            }

            this.SetMarginsAndOrientation();
        }
コード例 #13
0
        /// <summary>
        /// 隐藏导出Excel
        /// </summary>
        /// <param name="re"></param>
        private static void HideRender(RenderingExtension re)
        {
            FieldInfo fi = re.GetType().GetField("m_serverExtension", BindingFlags.Instance | BindingFlags.NonPublic);

            if (fi != null)
            {
                object actualExtension = fi.GetValue(re);
                if (actualExtension != null)
                {
                    PropertyInfo propInfo = actualExtension.GetType().GetProperty("Visible");
                    if (propInfo != null && propInfo.CanWrite)
                    {
                        propInfo.SetValue(actualExtension, false, null);
                    }
                }
            }
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }
            if (Request.QueryString["Stage"] != null)
            {
                TransactionStageControlId.ActiveStage = Request.QueryString["Stage"].ToString();
            }

            RenderingExtension extension = BillTrackingViewer.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals("PDF", StringComparison.CurrentCultureIgnoreCase));

            System.Reflection.FieldInfo info = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            info.SetValue(extension, false);

            FROMDATE = DateTime.Now.AddDays(-1);
            TODATE   = DateTime.Now;
        }
コード例 #15
0
        private void UnitPrint_Load(object sender, EventArgs e)
        {
            System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
            ReportParameter[] rptParams             = new ReportParameter[(23)];
            rptParams[0]  = new ReportParameter("FuelType", FuelType);
            rptParams[1]  = new ReportParameter("EquipmentNo", EquipmentNo);
            rptParams[2]  = new ReportParameter("Model", Model);
            rptParams[3]  = new ReportParameter("PlateNo", PlateNo);
            rptParams[4]  = new ReportParameter("EngineNo", EngineNo);
            rptParams[5]  = new ReportParameter("ChassisNo", ChassisNo);
            rptParams[6]  = new ReportParameter("Piston", Piston);
            rptParams[7]  = new ReportParameter("Cylinders", Cylinders);
            rptParams[8]  = new ReportParameter("TruckType", TruckType);
            rptParams[9]  = new ReportParameter("Make", Make);
            rptParams[10] = new ReportParameter("BodyType", BodyType);
            rptParams[11] = new ReportParameter("YearModel", YearModel);
            rptParams[12] = new ReportParameter("GrossWT", GrossWT);
            rptParams[13] = new ReportParameter("ExistingReading", ExistingReading);
            rptParams[14] = new ReportParameter("CurrentReading", CurrentReading);
            rptParams[15] = new ReportParameter("StatusOfPurchase", StatusOFPurchase);
            rptParams[16] = new ReportParameter("DateOfPurchase", DateOfPurchase.Replace(" 12:00:00 AM", ""));
            rptParams[17] = new ReportParameter("UnitPrice", UnitPrice);
            rptParams[18] = new ReportParameter("CRNo", CRNo);
            rptParams[19] = new ReportParameter("Supplier", Supplier);
            rptParams[20] = new ReportParameter("MVFileNo", MVFileNo);
            rptParams[21] = new ReportParameter("Register", Register);
            rptParams[22] = new ReportParameter("Series", Series);

            reportViewer1.LocalReport.SetParameters(rptParams);

            var setup = reportViewer1.GetPageSettings();

            //setup.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            pg.Margins.Top    = 0; //Convert.ToInt32(0.2);
            pg.Margins.Bottom = 0;
            pg.Margins.Left   = 0;
            pg.Margins.Right  = 0;

            pg.Landscape = false;


            reportViewer1.SetPageSettings(pg);

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);

            //this.reportviewer1.loca= datagridl;
            //this.m_FuelMainLogSheetReportBindingSource.DataSource = DataGridl;

            //string exportOption = "Excel";

            //string exportOption1 = "Excel";
            //RenderingExtension extension1 = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption1, StringComparison.CurrentCultureIgnoreCase));
            //if (extension1 != null)
            //{
            //    System.Reflection.FieldInfo fieldInfo = extension1.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            //    fieldInfo.SetValue(extension1, false);
            //}


            string exportOption = "EXCELOPENXML";
            //string exportOption = "PDF";
            RenderingExtension extension = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));

            if (extension != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension, false);
            }


            string exportOption1 = "WORDOPENXML";
            //string exportOption = "PDF";
            RenderingExtension extension1 = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption1, StringComparison.CurrentCultureIgnoreCase));

            if (extension1 != null)
            {
                System.Reflection.FieldInfo fieldInfo = extension1.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                fieldInfo.SetValue(extension1, false);
            }

            this.reportViewer1.RefreshReport();



            //this.reportViewer1.RefreshReport();
        }