コード例 #1
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);
            }
        }
コード例 #2
0
        public void setLocalReport(ReportViewer reportViewer, LocalReport report)
        {
            var currentReportProperty = reportViewer.GetType().GetProperty("CurrentReport", BindingFlags.NonPublic | BindingFlags.Instance);

            if (currentReportProperty != null)
            {
                var currentReport    = currentReportProperty.GetValue(reportViewer, null);
                var localReportField = currentReport.GetType().GetField("m_localReport", BindingFlags.NonPublic | BindingFlags.Instance);
                if (localReportField != null)
                {
                    localReportField.SetValue(currentReport, report);
                }
            }
            reportViewer.RefreshReport();
        }
コード例 #3
0
ファイル: Utility.cs プロジェクト: pangxb/SchoolHealth
        internal static bool ReportPageSetup(ReportViewer viewer)
        {
            Type t = viewer.GetType();


            try
            {
                string methodName = "OnPageSetup";
                t.InvokeMember(methodName, flags | BindingFlags.InvokeMethod, null, viewer, new object[] { null, EventArgs.Empty });
                return(true);
            }
            catch
            {
                return(false);
            }
        }