コード例 #1
0
        } // End Sub GetFooter

        public static byte[] GetPDF()
        {
            string report = "Report2.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return(GetReport2(report, formatInfo));
        } // End Sub GetFooterPDF
コード例 #2
0
        // Testing ReportViewer 2015
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Basic_SQL.SQL.GetSqlServerTypesDll(@"d:\");

            byte[] ba = Portal_Reports.Umzugsmitteilung.GetUmzugsmitteilung(new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml), "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE");
            return;

            RenderReport();
            return;

            this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer();
            EnableFormat("foo");


            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image);
            formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml);


            // this.m_Viewer.LocalReport.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/SimpleTest.rdl");

            using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("SimpleTest.rdl"))
            {
                this.m_Viewer.LocalReport.LoadReportDefinition(reportDefinition);
            }


            Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
            rds.Name = "DATA_Columns"; //This refers to the dataset name in the RDLC file
            string strSQL = @"SELECT TOP 100 * FROM information_schema.columns";

            // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
            // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
            rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
            strSQL    = null;

            this.m_Viewer.LocalReport.DataSources.Add(rds);


            Microsoft.Reporting.WebForms.Warning[] warnings;
            string[] streamids;
            string   mimeType;
            string   encoding;
            string   extension;

            byte[] result = this.m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

            string savePath = @"D:\";

            if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
            }

            savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension);
            System.IO.File.WriteAllBytes(savePath, result);
        } // End Sub Page_Load
コード例 #3
0
        } // End Sub GetUmzugsmitteilung

        // D:\reportviewerz\2005
        // Depends on TFS://COR-Library\COR_Reports\COR_Reports.csproj
        // Pre: No value is NULL
        // Post: output report bytes
        public static byte[] GetFooter(string report, COR_Reports.ReportFormatInfo formatInfo, string in_aperturedwg, string in_stylizer)
        {
            byte[] baReport = null;

            try
            {
                COR_Reports.ReportTools.ReportDataCallback_t myFunc = delegate(COR_Reports.ReportViewer viewer, System.Xml.XmlDocument doc)
                {
                    // viewer["format"] = formatInfo.FormatName;
                    // viewer["extension"] = formatInfo.Extension;
                    // viewer["report"] = report;

                    //string extension = viewer["extension"];
                    ////////////////////////////

                    System.Collections.Generic.List <COR_Reports.ReportParameter> lsParameters =
                        new System.Collections.Generic.List <COR_Reports.ReportParameter>();

                    lsParameters.Add(new COR_Reports.ReportParameter("in_aperturedwg", in_aperturedwg));
                    lsParameters.Add(new COR_Reports.ReportParameter("in_stylizer", in_stylizer));
                    // lsParameters.Add(new COR_Reports.ReportParameter("datastart", "dateTimePickerStartRaport.Text"));
                    // lsParameters.Add(new COR_Reports.ReportParameter("dataStop", "dateTimePickerStopRaport.Text"));

                    viewer.SetParameters(lsParameters);
                    lsParameters.Clear();
                    lsParameters = null;

                    // Add data sources
                    COR_Reports.ReportDataSource rds = new COR_Reports.ReportDataSource();
                    rds.Name = "DATA_Planinfo"; //This refers to the dataset name in the RDLC file
                    string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rds.Name);
                    strSQL = strSQL.Replace("@in_aperturedwg", "'" + in_aperturedwg.Replace("'", "''") + "'");
                    strSQL = strSQL.Replace("@in_stylizer", "'" + in_stylizer.Replace("'", "''") + "'");

                    rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
                    strSQL    = null;
                    viewer.DataSources.Add(rds);
                }; // End Sub ReportDataCallback_t

                baReport = COR_Reports.ReportTools.RenderReport(report, formatInfo, myFunc);
            }
            catch (System.Exception ex)
            {
                Basic_SQL.SQL.Log(ex);
                throw;
            }


            // If testing
            if (System.StringComparer.InvariantCultureIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                using (System.IO.FileStream fs = System.IO.File.Create(@"D:\" + System.IO.Path.GetFileNameWithoutExtension(report) + formatInfo.Extension))
                {
                    fs.Write(baReport, 0, baReport.Length);
                } // End Using fs
            }

            return(baReport);
        } // End Sub GetFooter
コード例 #4
0
        } // End Sub Page_Load

        public static byte[] GetFooterPDF()
        {
            string in_stylizer    = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";

            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return(GetFooter(report, formatInfo, in_aperturedwg, in_stylizer));
        } // End Sub GetFooterPDF
コード例 #5
0
        } // End Sub GetFooterHtmlFragment

        public static byte[] GetLegends()
        {
            string in_stylizer    = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";

            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "LegendenDesign2008.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return(GetLegends(report, formatInfo, in_aperturedwg, in_stylizer));
        } // End Sub GetFooterPDF
コード例 #6
0
        // Testing ReportViewer 2015
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Basic_SQL.SQL.GetSqlServerTypesDll(@"d:\");

            byte[] ba = Portal_Reports.Umzugsmitteilung.GetUmzugsmitteilung(new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml), "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE");
            return;

            RenderReport();
            return;

            this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer();
            EnableFormat("foo");

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image);
            formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml);

            // this.m_Viewer.LocalReport.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/SimpleTest.rdl");

            using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("SimpleTest.rdl"))
            {
                this.m_Viewer.LocalReport.LoadReportDefinition(reportDefinition);
            }

            Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
            rds.Name = "DATA_Columns"; //This refers to the dataset name in the RDLC file
            string strSQL = @"SELECT TOP 100 * FROM information_schema.columns";
            // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
            // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
            rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
            strSQL = null;

            this.m_Viewer.LocalReport.DataSources.Add(rds);

            Microsoft.Reporting.WebForms.Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] result = this.m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

            string savePath = @"D:\";
            if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
                savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);

            savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension);
            System.IO.File.WriteAllBytes(savePath, result);
        }
コード例 #7
0
        } // End Sub Page_Load

        protected static void RenderReport()
        {
            Microsoft.Reporting.WebForms.ReportViewer m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer();
            // EnableFormat("foo");


            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml);

            using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("TestReport.rdl"))
            {
                m_Viewer.LocalReport.LoadReportDefinition(reportDefinition);
            }


            Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
            rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file
            string strSQL = @"SELECT TOP 10 * FROM T_Benutzer";

            // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
            // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
            rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
            strSQL    = null;

            m_Viewer.LocalReport.DataSources.Add(rds);


            Microsoft.Reporting.WebForms.Warning[] warnings;
            string[] streamids;
            string   mimeType;
            string   encoding;
            string   extension;

            byte[] result = m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

            string savePath = @"D:\";

            if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);
            }

            savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension);
            System.IO.File.WriteAllBytes(savePath, result);
        }
コード例 #8
0
        public static string GetFooterHtmlFragment()
        {
            string retVal = "";
            string in_stylizer = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";
            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            byte[] baReport = GetFooter(report, formatInfo, in_aperturedwg, in_stylizer);
            if (baReport != null)
                retVal = System.Text.Encoding.UTF8.GetString(baReport);

            return retVal;
        }
コード例 #9
0
        } // End Sub GetFooterPDF

        public static string GetFooterHtmlFragment()
        {
            string retVal         = "";
            string in_stylizer    = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";

            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            byte[] baReport = GetFooter(report, formatInfo, in_aperturedwg, in_stylizer);
            if (baReport != null)
            {
                retVal = System.Text.Encoding.UTF8.GetString(baReport);
            }

            return(retVal);
        } // End Sub GetFooterHtmlFragment
コード例 #10
0
        } // End Sub Page_Load

        public static byte[] GetFooterPDF()
        {
            string in_stylizer    = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";

            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);

            // byte[] foot = GetFooter(report, formatInfo, in_aperturedwg, in_stylizer);

            byte[] foot = GetUmzugsmitteilung("UM_Umzugsmitteilung.rdl", formatInfo, "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE");
            // System.IO.File.WriteAllBytes(@"d:\Test_UM_Umzugsmitteilung" + formatInfo.Extension, foot);

            return(foot);
        } // End Sub GetFooterPDF
コード例 #11
0
        protected static void RenderReport()
        {
            Microsoft.Reporting.WebForms.ReportViewer m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer();
            // EnableFormat("foo");

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image);
            // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml);

            using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("TestReport.rdl"))
            {
                m_Viewer.LocalReport.LoadReportDefinition(reportDefinition);
            }

            Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
            rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file
            string strSQL = @"SELECT TOP 10 * FROM T_Benutzer";
            // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
            // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
            rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
            strSQL = null;

            m_Viewer.LocalReport.DataSources.Add(rds);

            Microsoft.Reporting.WebForms.Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] result = m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);

            string savePath = @"D:\";
            if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
                savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory);

            savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension);
            System.IO.File.WriteAllBytes(savePath, result);
        }
コード例 #12
0
        } // End Sub GetFooterPDF

        // D:\reportviewerz\2005
        // Depends on TFS://COR-Library\COR_Reports\COR_Reports.csproj
        // Pre: No value is NULL
        // Post: output report bytes
        public static byte[] GetReport2(string report, COR_Reports.ReportFormatInfo formatInfo)
        {
            byte[] baReport = null;

            try
            {
                COR_Reports.ReportTools.ReportDataCallback_t myFunc = delegate(COR_Reports.ReportViewer viewer, System.Xml.XmlDocument doc)
                {
                    // Add data sources
                    COR_Reports.ReportDataSource rds = new COR_Reports.ReportDataSource();
                    rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file
                    string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rds.Name);


                    rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
                    strSQL    = null;
                    viewer.DataSources.Add(rds);
                }; // End Sub ReportDataCallback_t

                baReport = COR_Reports.ReportTools.RenderReport(report, formatInfo, myFunc);
            }
            catch (System.Exception ex)
            {
                Basic_SQL.SQL.Log(ex);
                throw;
            }


            // If testing
            if (System.StringComparer.InvariantCultureIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                using (System.IO.FileStream fs = System.IO.File.Create(@"D:\" + System.IO.Path.GetFileNameWithoutExtension(report) + formatInfo.Extension))
                {
                    fs.Write(baReport, 0, baReport.Length);
                } // End Using fs
            }

            return(baReport);
        } // End Sub GetReport2
コード例 #13
0
        // Pre: No value is NULL
        // Post: output report bytes
        public static byte[] GetUmzugsmitteilung(COR_Reports.ReportFormatInfo formatInfo, string in_ump_uid, string in_sprache)
        {
            string report = "UM_Umzugsmitteilung.rdl";

            byte[] baReport = null;

            // if (string.IsNullOrEmpty(in_ump_uid)) in_ump_uid = "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC";
            if (string.IsNullOrEmpty(in_sprache))
            {
                in_sprache = "DE";
            }


            // formatInfo = new Portal_Reports.ReportFormatInfo(ExportFormat.Word);


            try
            {
                COR_Reports.ReportTools.ReportDataCallback_t myFunc = delegate(COR_Reports.ReportViewer viewer, System.Xml.XmlDocument doc)
                {
                    // viewer["format"] = formatInfo.FormatName;
                    // viewer["extension"] = formatInfo.Extension;
                    // viewer["report"] = report;

                    //string extension = viewer["extension"];
                    ////////////////////////////

                    System.Collections.Generic.List <COR_Reports.ReportParameter> lsParameters =
                        new System.Collections.Generic.List <COR_Reports.ReportParameter>();


                    lsParameters.Add(new COR_Reports.ReportParameter("in_mandant", "0"));
                    lsParameters.Add(new COR_Reports.ReportParameter("proc", "administrator"));
                    lsParameters.Add(new COR_Reports.ReportParameter("in_sprache", in_sprache));
                    // lsParameters.Add(new Portal_Reports.ReportParameter("in_report_name", "UM_Umzugsmitteilung"));

                    // lsParameters.Add(new Portal_Reports.ReportParameter("in_stichtag", System.DateTime.Now.ToString("dd.MM.yyyy")));

                    // lsParameters.Add(new Portal_Reports.ReportParameter("def_pageformat", "Seite {0} von {1}"));
                    // lsParameters.Add(new Portal_Reports.ReportParameter("def_dateformat", "d.MM.yyyy"));

                    lsParameters.Add(new COR_Reports.ReportParameter("in_umzugsuid", in_ump_uid));
                    // lsParameters.Add(new COR_Reports.ReportParameter("datastart", "dateTimePickerStartRaport.Text"));
                    // lsParameters.Add(new COR_Reports.ReportParameter("dataStop", "dateTimePickerStopRaport.Text"));

                    viewer.SetParameters(lsParameters);
                    lsParameters.Clear();
                    lsParameters = null;

                    {
                        // Add data sources
                        COR_Reports.ReportDataSource rds = new COR_Reports.ReportDataSource();
                        rds.Name = "DATA_Umzugsmitteilung"; //This refers to the dataset name in the RDLC file
                        string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rds.Name);
                        strSQL    = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
                        strSQL    = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
                        rds.Value = SQL.GetDataTable(strSQL);

                        strSQL = null;
                        viewer.DataSources.Add(rds);
                    }

                    {
                        COR_Reports.ReportDataSource rdsHeader = new COR_Reports.ReportDataSource();
                        rdsHeader.Name = "DATA_Umzugsheader"; //This refers to the dataset name in the RDLC file
                        string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rdsHeader.Name);
                        strSQL          = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
                        rdsHeader.Value = SQL.GetDataTable(strSQL);
                        strSQL          = null;
                        viewer.DataSources.Add(rdsHeader);
                    }

                    {
                        COR_Reports.ReportDataSource rdsTranslation = new COR_Reports.ReportDataSource();
                        rdsTranslation.Name = "DATA_Report_Translation"; //This refers to the dataset name in the RDLC file
                        string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rdsTranslation.Name);
                        strSQL = strSQL.Replace("@in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
                        rdsTranslation.Value = SQL.GetDataTable(strSQL);
                        strSQL = null;
                        viewer.DataSources.Add(rdsTranslation);
                    }
                };

                baReport = COR_Reports.ReportTools.RenderReport(report, formatInfo, myFunc);
            }
            catch
            {
                // Basic_SQL.SQL.Log(ex);
                throw;
            }


            // If testing
            if (System.StringComparer.InvariantCultureIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                using (System.IO.FileStream fs = System.IO.File.Create(@"D:\" + System.IO.Path.GetFileNameWithoutExtension(report) + formatInfo.Extension))
                {
                    fs.Write(baReport, 0, baReport.Length);
                } // End Using fs
            }

            return(baReport);
        } // End Sub GetFooterPDF
コード例 #14
0
ファイル: Form1.cs プロジェクト: ststeiger/Modify_SSRS_Report
        private System.Data.DataTable ProcessWorkbook()
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            byte[] ba     = null;
            bool   bDebug = true;

            string fn = @"D:\ExampleMultitabReport.xlsx";

            if (!System.IO.File.Exists(fn) || !bDebug)
            {
                // COR_Reports.ReportFormatInfo pdfFormatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
                // COR_Reports.ReportFormatInfo htmlFormatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
                // COR_Reports.ReportFormatInfo excelFormatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Excel);
                COR_Reports.ReportFormatInfo excelOpenXmlFormatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml);
                ba = GetFooter("ExampleMultitabReport.rdl", excelOpenXmlFormatInfo);
            }
            else
            {
                ba = System.IO.File.ReadAllBytes(fn);
            }



            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(ba))
            {
                // Get the file we are going to process
                // Open and read the XlSX file.
                // System.IO.FileInfo existingFile = new System.IO.FileInfo(fn);
                // using (OfficeOpenXml.ExcelPackage package = new OfficeOpenXml.ExcelPackage(existingFile))
                using (OfficeOpenXml.ExcelPackage package = new OfficeOpenXml.ExcelPackage(ms))
                {
                    // Get the work book in the file
                    OfficeOpenXml.ExcelWorkbook workBook = package.Workbook;
                    if (workBook != null)
                    {
                        // dt = ProcessingFunction(workBook);

                        // OfficeOpenXml.ExcelWorksheet ws = workBook.Worksheets.First();
                        OfficeOpenXml.ExcelWorksheet roomsWorksheet      = workBook.Worksheets["Räume"];
                        OfficeOpenXml.ExcelWorksheet UsageTypesWorksheet = workBook.Worksheets["Nutzungsarten"];

                        if (roomsWorksheet == null)
                        {
                            return(dt);
                        }

                        if (roomsWorksheet != null)
                        {
                            UsageTypesWorksheet.Hidden = OfficeOpenXml.eWorkSheetHidden.Hidden;
                        }



                        int iStartRow = roomsWorksheet.Dimension.Start.Row;
                        int iEndRow   = roomsWorksheet.Dimension.End.Row;

                        int iStartColumn = roomsWorksheet.Dimension.Start.Column;
                        int iEndColumn   = roomsWorksheet.Dimension.End.Column;



                        // OfficeOpenXml.ExcelRange cell = roomsWorksheet.Cells["A1"];
                        OfficeOpenXml.ExcelRange cell = null; // ewbGroupPermissionWorksheet.Cells[1, 1]; // Cells[y, x]
                        for (int j = 1; j <= iEndColumn; ++j)
                        {
                            cell = roomsWorksheet.Cells[3, j]; // Cells[y, x]
                            string title = GetCellValueAsString(cell);

                            // if (string.IsNullOrWhiteSpace(title)) continue;

                            dt.Columns.Add(title, typeof(string));
                        } // Next j

                        System.Console.WriteLine(dt.Columns.Count);


                        int ord = dt.Columns["NA Lang DE"].Ordinal + 1;


                        // https://stackoverflow.com/questions/29764226/add-list-validation-to-column-except-the-first-two-rows
                        // public static string GetAddress(int FromRow, int FromColumn, int ToRow, int ToColumn)
                        string range = OfficeOpenXml.ExcelRange.GetAddress(4, ord, OfficeOpenXml.ExcelPackage.MaxRows, ord);
                        OfficeOpenXml.DataValidation.Contracts.IExcelDataValidationList val = roomsWorksheet.DataValidations.AddListValidation(range);

                        string char1 = "A";
                        string char2 = "A";
                        int    num1  = 1;
                        int    num2  = 300;

                        // https://stackoverflow.com/questions/20259692/epplus-number-of-drop-down-items-limitation-in-excel-file
                        //val.Formula.ExcelFormula = string.Format("=DropDownWorksheetName!${0}${1}:${2}${3}", char1, num1, char2, num2);
                        val.Formula.ExcelFormula = string.Format("=Nutzungsarten!{0}", "H2:H72");
                        val.ShowErrorMessage     = true;
                        val.Error = "Select a value from list of values ...";



                        for (int i = 4; i <= iEndRow; ++i)
                        {
                            for (int j = 1; j <= iEndColumn; ++j)
                            {
                                cell = roomsWorksheet.Cells[3, j]; // Cells[y, x]

                                cell.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
                                cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.HotPink);

                                // cell.Style.Font.Strike;

                                OfficeOpenXml.Style.ExcelRichText ert = roomsWorksheet.Cells[2, 1].RichText.Add("RichText");
                                ert.Bold   = true;
                                ert.Color  = System.Drawing.Color.Red;
                                ert.Italic = true;
                                ert.Size   = 12;


                                ert           = roomsWorksheet.Cells[2, 1].RichText.Add("Test");
                                ert.Bold      = true;
                                ert.Color     = System.Drawing.Color.Purple;
                                ert.Italic    = true;
                                ert.UnderLine = true;
                                ert.Strike    = true;

                                ert        = roomsWorksheet.Cells[2, 1].RichText.Add("123");
                                ert.Color  = System.Drawing.Color.Peru;
                                ert.Italic = false;
                                ert.Bold   = false;


                                // Can't add validation when a validation already exists
                                // OfficeOpenXml.DataValidation.Contracts.IExcelDataValidationList cellValidation = cell.DataValidation.AddListDataValidation();
                                break;

                                // https://stackoverflow.com/questions/9859610/how-to-set-column-type-when-using-epplus
                                // https://stackoverflow.com/questions/22832423/excel-date-format-using-epplus
                            } // Next j
                            break;
                        }     // Next i
                    }         // End if (workBook != null)

                    using (System.IO.FileStream fs = new System.IO.FileStream(@"D:\ModifiedExcelFile.xlsx", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                    {
                        package.SaveAs(fs);
                    } // End using fs
                }     // End Using package
            }         // End Using ms

            return(dt);
        }
コード例 #15
0
        // Pre: No value is NULL
        // Post: output report bytes
        public static byte[] GetUmzugsmitteilung(COR_Reports.ReportFormatInfo formatInfo, string in_ump_uid, string in_sprache)
        {
            string report = "UM_Umzugsmitteilung2.rdl";

            byte[] baReport = null;

            // if (string.IsNullOrEmpty(in_ump_uid)) in_ump_uid = "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC";
            if (string.IsNullOrEmpty(in_sprache))
            {
                in_sprache = "DE";
            }


            // formatInfo = new Portal_Reports.ReportFormatInfo(ExportFormat.Word);


            try
            {
                COR_Reports.ReportTools.ReportDataCallback_t myFunc = delegate(COR_Reports.ReportViewer viewer, System.Xml.XmlDocument doc)
                {
                    // viewer["format"] = formatInfo.FormatName;
                    // viewer["extension"] = formatInfo.Extension;
                    // viewer["report"] = report;

                    //string extension = viewer["extension"];
                    ////////////////////////////

                    System.Collections.Generic.List <COR_Reports.ReportParameter> lsParameters =
                        new System.Collections.Generic.List <COR_Reports.ReportParameter>();


                    viewer.SetParameters(lsParameters);
                    lsParameters.Clear();
                    lsParameters = null;

                    {
                        // Add data sources
                        COR_Reports.ReportDataSource rds = new COR_Reports.ReportDataSource();
                        rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file
                        string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rds.Name);
                        rds.Value = SQL.GetDataTable(strSQL);

                        strSQL = null;
                        viewer.DataSources.Add(rds);
                    }
                };

                baReport = COR_Reports.ReportTools.RenderReport(report, formatInfo, myFunc);
            }
            catch
            {
                // Basic_SQL.SQL.Log(ex);
                throw;
            }


            // If testing
            if (System.StringComparer.InvariantCultureIgnoreCase.Equals(System.Environment.UserDomainName, "COR"))
            {
                using (System.IO.FileStream fs = System.IO.File.Create(@"D:\" + System.IO.Path.GetFileNameWithoutExtension(report) + formatInfo.Extension))
                {
                    fs.Write(baReport, 0, baReport.Length);
                } // End Using fs
            }

            return(baReport);
        } // End Sub GetFooterPDF
コード例 #16
0
        public static byte[] GetFooterPDF()
        {
            string in_stylizer = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";
            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return GetFooter(report, formatInfo, in_aperturedwg, in_stylizer);
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: ststeiger/Modify_SSRS_Report
        // Depends on TFS://COR-Library\COR_Reports\COR_Reports.csproj
        // COR_Legende.ReportFooterSTZH.GetFooterPDF
        //Public Shared Function GetFooter(report As String, formatInfo As COR_Reports.ReportFormatInfo, in_aperturedwg As String, in_stylizer As String, in_sprache As String, ByRef AdjustHeight As Boolean) As Byte()
        public static byte[] GetFooter(string report, COR_Reports.ReportFormatInfo formatInfo)
        {
            byte[] baReport = null;

            try
            {
                COR_Reports.ReportTools.ReportDataCallback_t cb = (COR_Reports.ReportViewer viewer, System.Xml.XmlDocument doc) =>
                {
                    //Dim lsParameters As New System.Collections.Generic.List(Of COR_Reports.ReportParameter)()



                    //lsParameters.Add(New COR_Reports.ReportParameter("in_aperturedwg", "G00020-OG02_0000"))
                    //lsParameters.Add(New COR_Reports.ReportParameter("in_stylizer", "REM Bodenbelag"))
                    //lsParameters.Add(New COR_Reports.ReportParameter("in_sprache", "DE"))

                    //If leg.IsBKB AndAlso False Then
                    //    lsParameters.Add(New COR_Reports.ReportParameter("proc", leg.UserInfo.BE_User))
                    //End If

                    //' lsParameters.Add(new COR_Reports.ReportParameter("datastart", "dateTimePickerStartRaport.Text"))
                    //' lsParameters.Add(new COR_Reports.ReportParameter("dataStop", "dateTimePickerStopRaport.Text"))

                    //viewer.SetParameters(lsParameters)
                    //lsParameters.Clear()
                    //lsParameters = Nothing


                    string sprache = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpperInvariant();

                    // Add data sources
                    {
                        // This refers to the dataset name in the RDL/RDLC file
                        COR_Reports.ReportDataSource rdsDATA_Raum = new COR_Reports.ReportDataSource();
                        rdsDATA_Raum.Name = "DATA_Raum";
                        string strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rdsDATA_Raum.Name);
                        strSQL = strSQL.Replace("@in_sprache", "'" + sprache + "'");
                        System.Data.DataTable dt = GetDataTable(strSQL);
                        rdsDATA_Raum.Value = dt;
                        viewer.DataSources.Add(rdsDATA_Raum);


                        // This refers to the dataset name in the RDL/RDLC file
                        COR_Reports.ReportDataSource rdsDATA_Nutzungsart = new COR_Reports.ReportDataSource();
                        rdsDATA_Nutzungsart.Name = "DATA_Nutzungsart";
                        strSQL = COR_Reports.ReportTools.GetDataSetDefinition(doc, rdsDATA_Nutzungsart.Name);
                        strSQL = strSQL.Replace("@in_sprache", "'" + sprache + "'");
                        System.Data.DataTable dt2 = GetDataTable(strSQL);
                        rdsDATA_Nutzungsart.Value = dt2;
                        viewer.DataSources.Add(rdsDATA_Nutzungsart);
                    }
                };

                baReport = COR_Reports.ReportTools.RenderReport(report, formatInfo, cb);

                using (System.IO.FileStream fs = System.IO.File.Create("D:\\" + System.IO.Path.GetFileNameWithoutExtension(report) + formatInfo.Extension))
                {
                    fs.Write(baReport, 0, baReport.Length);
                } // End Using fs
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
            }

            return(baReport);
        } // GetFooter
コード例 #18
0
        public static byte[] GetLegends()
        {
            string in_stylizer = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";
            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "LegendenDesign.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return GetLegends(report, formatInfo, in_aperturedwg, in_stylizer);
        }
コード例 #19
0
        public static byte[] GetPDF()
        {
            string report = "Report2.rdl";

            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            return GetReport2(report, formatInfo);
        }
コード例 #20
0
        }             // End Sub EnableFormat

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
                return;
            }

            Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource();
            rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file
            string strSQL = @"SELECT * FROM T_Benutzer";

            // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'");
            // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'");
            rds.Value = Basic_SQL.SQL.GetDataTable(strSQL);
            strSQL    = null;


            Microsoft.Reporting.WebForms.ReportViewer rs = new Microsoft.Reporting.WebForms.ReportViewer();
            //EnableFormat(rs, "HTML4.0");
            EnableFormat(rs, "IMAGE");

            using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("PaginationTest.rdl"))
            {
                rs.LocalReport.LoadReportDefinition(reportDefinition);
            } // End Using reportDefinition

            rs.LocalReport.DataSources.Add(rds);


            Microsoft.Reporting.WebForms.Warning[] warnings;
            string[] streamids;
            string   mimeType;
            string   encoding;
            string   extension;


            //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment);
            //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.MHTML);
            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image);


            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>";

            byte[] result = rs.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
            System.Console.WriteLine(result);


            //Page page = new Page();
            TestRender page = new TestRender();

            //System.Web.UI.ScriptManager scriptManager = new ScriptManager();

            //System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
            //form.Controls.Add(scriptManager);
            //rs.AsyncRendering = false;
            //form.Controls.Add(rs);
            //page.Controls.Add(form);

            //page.RenderControl


            //// page.DataBind();  //exception here


            //// RenderControlToHtml2(page);
            string s = RenderControlToHtml(page);

            System.Console.WriteLine(s);
        } // End Sub Page_Load
コード例 #21
0
        public static byte[] GetFooterPDF()
        {
            string in_stylizer = "REM Bodenbelag";
            string in_aperturedwg = "G00020-OG02_0000";
            in_aperturedwg = "S0691_0000";
            in_aperturedwg = "G00020-OG02_0000";

            string report = "Planinfo_StadtZuerich.rdl";

            //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.PDF);
            COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml);

            // byte[] foot = GetFooter(report, formatInfo, in_aperturedwg, in_stylizer);

            byte[] foot = GetUmzugsmitteilung("UM_Umzugsmitteilung.rdl", formatInfo, "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE");
            // System.IO.File.WriteAllBytes(@"d:\Test_UM_Umzugsmitteilung" + formatInfo.Extension, foot);

            return foot;
        }