Пример #1
0
 /// <summary>
 /// Parses the XML.
 /// </summary>
 /// <returns></returns>
 /// <Remarks>
 /// Created Time: 2008-7-17 15:56
 /// Created By: jack_que
 /// Last Modified Time:  
 /// Last Modified By: 
 /// </Remarks>
 public HtmlReport ParseXml()
 {
     report = new HtmlReport();
     if (this.reportXmlFile == null || this.reportXmlFile.Equals(string.Empty))
     {
         throw new Exception("The xml file for reporting is not found!");
     }
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load(reportXmlFile);
     XmlNode rootNode = xmlDoc.DocumentElement;
     report.Capation = CreateCaption(rootNode);
     report.TotalRows = GetTotalRows(rootNode);
     report.Columns = GetColumns(rootNode);
     return report;
 }
Пример #2
0
        /// <summary>
        /// Generates the report HTML.
        /// </summary>
        /// <returns></returns>
        /// <Remarks>
        /// Created Time: 2008-7-21 12:55
        /// Created By: jack_que
        /// Last Modified Time:  
        /// Last Modified By: 
        /// </Remarks>
        public string GenerateReportHtml(string tabId)
        {
            if (report == null)
            {
                report = ParseXml();
            }

            StringBuilder builder = new StringBuilder();
            builder.Append(@"<table id='").Append(tabId).Append("_table' ")
                .Append("width='100%' border='1' class='rep-border'>")
                .Append("<caption style='text-align:").Append(report.Capation.Style.Align).Append(";")
                .Append("color:").Append(report.Capation.Style.Color).Append(";")
                .Append("font-size:").Append(report.Capation.Style.FontSize).Append("px;'>")
                .Append(report.Capation.Title).Append("</caption>")
                .Append(CreateHeader()).Append(CreateBody()).Append("</table>");
            return builder.ToString().EscapeHtml();
        }
Пример #3
0
        private void SortReportStruct(ref HtmlReport _reportStruct, ref ReportDataSetConvertor _convert)
        {
            HtmlReport leftReport = new HtmlReport();
            HtmlReport rightReport = new HtmlReport();

            //处理排序的列
            for (int i = 0; i < _convert.ColumnOrder.Count; i++)
            {
                for (int j = 0; j < _reportStruct.Columns.Count; j++)
                {
                    if (_reportStruct.Columns[j].Header.HeaderValue.Trim().Equals(_convert.ColumnOrder[i].Trim()))
                    {
                        leftReport.Columns.Add(_reportStruct.Columns[j]);
                        _reportStruct.Columns.RemoveAt(j);
                        break;
                    }
                }
            }

            //处理排在最后的列
            for (int i = 0; i < _convert.ColumnOrder.Count; i++)
            {
                for (int j = 0; j < _reportStruct.Columns.Count; j++)
                {
                    if (_reportStruct.Columns[j].Header.HeaderValue.Trim().Equals("->" + _convert.ColumnOrder[i].Trim()))
                    {
                        rightReport.Columns.Add(_reportStruct.Columns[j]);
                        _reportStruct.Columns.RemoveAt(j);
                        break;
                    }
                }
            }

            //处理余下的列
            for (int i = 0; i < _reportStruct.Columns.Count; i++)
            {
                leftReport.Columns.Add(_reportStruct.Columns[i]);
            }

            //处理排在尾部的列
            for (int i = 0; i < rightReport.Columns.Count; i++)
            {
                leftReport.Columns.Add(rightReport.Columns[i]);
            }

            _reportStruct.Columns.Clear();

            for (int i = 0; i < leftReport.Columns.Count; i++)
            {
                _reportStruct.Columns.Add(leftReport.Columns[i]);
            }
        }
Пример #4
0
        /// <summary>
        /// Generates the report.
        /// </summary>
        /// <returns></returns>
        /// <Remarks>
        /// Created Time: 2008-7-20 12:47
        /// Created By: jack_que
        /// Last Modified Time:  
        /// Last Modified By: 
        /// </Remarks>
        public string GenerateReport()
        {
            if (report == null)
            {
                report = ParseXml();
            }
            StringBuilder builder = new StringBuilder();
            builder.Append("<html><meta http-equiv='Content-Type' content='text/html; charset=utf-8'><body>")
                   .Append(@"<table width='100%' border='1'>")
                   .Append("<tr><td colspan='").Append(report.ColumnSpan()).Append("' ")
                   .Append("align='").Append(report.Capation.Style.Align).Append("' ")
                   .Append("style='font-size:").Append(report.Capation.Style.FontSize).Append("px;")
                   .Append("color:").Append(report.Capation.Style.Color).Append(";'>")
                   .Append(report.Capation.Title).Append("</td></tr>");

            builder.Append(CreateHeader());
            builder.Append(CreateBody());
            builder.Append("</table></body></html>");
            return builder.ToString();
        }
Пример #5
0
        private void AddFixedRows(ref HtmlReport _reportStruct, ref ReportDataSetConvertor _convert)
        {
            for (int i = 0; i < _convert.FixedRows.Count; i++)
            {
                HtmlRow row = new HtmlRow();
                row.Header.HeaderText = _convert.FixedRows[i].RowText;
                row.Header.HeaderValue = _convert.FixedRows[i].RowValue;
                row.RowSpan = _convert.FixedRows[i].ChildCount;

                _reportStruct.Rows.Add(row);
            }
        }