Exemple #1
0
        // 输出 RML 格式的表格
        // 本函数负责写入 <table> 元素
        // parameters:
        //      nTopLines   顶部预留多少行
        public void OutputRmlTable(
            Report report,
            SQLiteDataReader table,
            XmlTextWriter writer,
            int nMaxLines = -1)
        {
            // StringBuilder strResult = new StringBuilder(4096);
            int i, j;

#if NO
            if (nMaxLines == -1)
                nMaxLines = table.Count;
#endif

            writer.WriteStartElement("table");
            writer.WriteAttributeString("class", "table");

            writer.WriteStartElement("thead");
            writer.WriteStartElement("tr");

            int nEvalCount = 0; // 具有 eval 的栏目个数
            for (j = 0; j < report.Count; j++)
            {
                PrintColumn column = (PrintColumn)report[j];
                if (column.Colspan == 0)
                    continue;

                if (string.IsNullOrEmpty(column.Eval) == false)
                    nEvalCount++;

                writer.WriteStartElement("th");
                if (string.IsNullOrEmpty(column.CssClass) == false)
                    writer.WriteAttributeString("class", column.CssClass);
                if (column.Colspan > 1)
                    writer.WriteAttributeString("colspan", column.Colspan.ToString());

                writer.WriteString(column.Title);
                writer.WriteEndElement();   // </th>
            }

            writer.WriteEndElement();   // </tr>
            writer.WriteEndElement();   // </thead>


            // 合计数组
            object[] sums = null;   // 2008/12/1 new changed

            if (report.SumLine)
            {
                sums = new object[report.Count];
                for (i = 0; i < sums.Length; i++)
                {
                    sums[i] = null;
                }
            }

            NumberFormatInfo nfi = new CultureInfo("zh-CN", false).NumberFormat;
            nfi.NumberDecimalDigits = 2;

            writer.WriteStartElement("tbody");

            // Jurassic.ScriptEngine engine = null;
            if (nEvalCount > 0 && engine == null)
            {
                engine = new Jurassic.ScriptEngine();
                engine.EnableExposedClrTypes = true;
            }

            // 内容行循环
            for (i = 0; ; i++)  // i < Math.Min(nMaxLines, table.Count)
            {
                if (table.HasRows == false)
                    break;
                // Line line = table[i];

                if (engine != null)
                    engine.SetGlobalValue("reader", table);

                string strLineCssClass = "content";
#if NO
                if (report.OutputLine != null)
                {
                    OutputLineEventArgs e = new OutputLineEventArgs();
                    e.Line = line;
                    e.Index = i;
                    e.LineCssClass = strLineCssClass;
                    report.OutputLine(this, e);
                    if (e.Output == false)
                        continue;

                    strLineCssClass = e.LineCssClass;
                }
#endif

                // strResult.Append("<tr class='" + strLineCssClass + "'>\r\n");
                writer.WriteStartElement("tr");
                writer.WriteAttributeString("class", strLineCssClass);

                // 列循环
                for (j = 0; j < report.Count; j++)
                {
                    PrintColumn column = (PrintColumn)report[j];

                    if (column.ColumnNumber < -1)
                    {
                        throw (new Exception("PrintColumn对象ColumnNumber列尚未初始化,位置" + Convert.ToString(j)));
                    }

                    string strText = "";
                    if (column.ColumnNumber != -1)
                    {
                        if (string.IsNullOrEmpty(column.Eval) == false)
                        {
                            // engine.SetGlobalValue("cell", line.GetObject(column.ColumnNumber));
                            strText = engine.Evaluate(column.Eval).ToString();
                        }
                        else if (column.DataType == DataType.PriceDouble)
                        {
                            if (table.IsDBNull(column.ColumnNumber /**/) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                double v = table.GetDouble(column.ColumnNumber);
                                /*
                                NumberFormatInfo provider = new NumberFormatInfo();
                                provider.NumberDecimalDigits = 2;
                                provider.NumberGroupSeparator = ".";
                                provider.NumberGroupSizes = new int[] { 3 };
                                strText = Convert.ToString(v, provider);
                                 * */
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.PriceDecimal)
                        {
                            if (table.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = table.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.PriceDecimal)
                        {
                            if (table.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = table.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.Price)
                        {
                            // Debug.Assert(false, "");
                            if (table.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;	// 2005/5/26
                            else
                                strText = table.GetString(column.ColumnNumber);    // 
                        }
                        else
                            strText = table.GetString(column.ColumnNumber/*, column.DefaultValue*/);
                    }
                    else
                    {
                        strText = table.GetString(0);   // line.Entry;
                    }

                    writer.WriteStartElement(j == 0 ? "th" : "td");
                    if (string.IsNullOrEmpty(column.CssClass) == false)
                        writer.WriteAttributeString("class", column.CssClass);
                    writer.WriteString(strText);
                    writer.WriteEndElement();   // </td>

                    if (report.SumLine == true
                        && column.Sum == true
                        && column.ColumnNumber != -1)
                    {
                        try
                        {
                            // if (column.DataType != DataType.Currency)
                            {
                                object v = table.GetValue(column.ColumnNumber);
#if NO
                                if (report.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    report.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;

                                    v = e.Value;
                                }
#endif

                                if (sums[j] == null)
                                    sums[j] = v;
                                else
                                {
                                    sums[j] = AddValue(column.DataType,
            sums[j],
            v);
                                    // sums[j] = ((decimal)sums[j]) + v;
                                }
                            }
                        }
                        catch (Exception ex)	// 俘获可能因字符串转换为整数抛出的异常
                        {
                            throw new Exception("在累加 行 " + i.ToString() + " 列 " + column.ColumnNumber.ToString() + " 值的时候,抛出异常: " + ex.Message);
                        }
                    }
                }

                // strResult.Append("</tr>\r\n");
                writer.WriteEndElement();   // </tr>
            }
Exemple #2
0
        // 输出html格式的表格
        public string HtmlTable(Table table,
            int nMaxLines = -1)
        {
            StringBuilder strResult = new StringBuilder(4096);
            int i, j;

            if (nMaxLines == -1)
                nMaxLines = table.Count;

            strResult.Append("<table class='table'>\r\n");    //  border='0' bgcolor=Gainsboro cellspacing='2' cellpadding='2'

            // 表格标题
            strResult.Append("<tr class='column'>\r\n");

            for (j = 0; j < this.Count; j++)
            {
                PrintColumn column = (PrintColumn)this[j];
                if (column.Colspan == 0)
                    continue;

                string strText = column.Title;
                string strColspan = "";
                if (column.Colspan > 1)
                    strColspan = " colspan='" + column.Colspan.ToString() + "' ";
                strResult.Append( "<td class='"
                    + column.CssClass
                    + "'"
                    + strColspan + ">" + strText + "</td>\r\n");
            }

            strResult.Append( "</tr>\r\n");

            // 合计数组
            object[] sums = null;   // 2008/12/1 new changed

            if (this.SumLine)
            {
                sums = new object[this.Count];
                for (i = 0; i < sums.Length; i++)
                {
                    sums[i] = null;
                }
            }

            NumberFormatInfo nfi = new CultureInfo("zh-CN", false).NumberFormat;
            nfi.NumberDecimalDigits = 2;

            // 内容行循环
            for (i = 0; i < Math.Min(nMaxLines, table.Count); i++)
            {
                Line line = table[i];

                string strLineCssClass = "content";
                if (this.OutputLine != null)
                {
                    OutputLineEventArgs e = new OutputLineEventArgs();
                    e.Line = line;
                    e.Index = i;
                    e.LineCssClass = strLineCssClass;
                    this.OutputLine(this, e);
                    if (e.Output == false)
                        continue;

                    strLineCssClass = e.LineCssClass;
                }

                strResult.Append("<tr class='" + strLineCssClass + "'>\r\n");

                // 列循环
                for (j = 0; j < this.Count; j++)
                {

                    PrintColumn column = (PrintColumn)this[j];

                    if (column.ColumnNumber < -1)
                    {
                        throw (new Exception("PrintColumn对象ColumnNumber列尚未初始化,位置" + Convert.ToString(j)));
                    }


                    string strText = "";
                    if (column.ColumnNumber != -1)
                    {
                        if (column.DataType == DataType.PriceDouble)
                        {
                            if (line.IsNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                double v = line.GetDouble(column.ColumnNumber);
                                /*
                                NumberFormatInfo provider = new NumberFormatInfo();
                                provider.NumberDecimalDigits = 2;
                                provider.NumberGroupSeparator = ".";
                                provider.NumberGroupSizes = new int[] { 3 };
                                strText = Convert.ToString(v, provider);
                                 * */
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.PriceDecimal)
                        {
                            if (line.IsNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = line.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.PriceDecimal)
                        {
                            if (line.IsNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = line.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == DataType.Price)
                        {
                            // Debug.Assert(false, "");
                            if (line.IsNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;	// 2005/5/26
                            else
                                strText = line.GetPriceString(column.ColumnNumber);
                        }
                        else
                            strText = line.GetString(column.ColumnNumber, column.DefaultValue);
                    }
                    else
                    {
                        strText = line.Entry;
                    }


                    strResult.Append( "<td class='"
                        + column.CssClass
                        + "'>" + strText + "</td>\r\n");

                    if (this.SumLine == true
                        && column.Sum == true
                        && column.ColumnNumber != -1)
                    {
                        try
                        {
                            // if (column.DataType != DataType.Currency)
                            {
                                object v = line.GetObject(column.ColumnNumber);
                                if (this.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    this.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;

                                    v = e.Value;
                                }

                                if (sums[j] == null)
                                    sums[j] = v;
                                else
                                {
                                    sums[j] = AddValue(column.DataType,
            sums[j],
            v);
                                    // sums[j] = ((decimal)sums[j]) + v;
                                }
                            }
                                /*
                            else
                            {
                                string v = line.GetString(column.ColumnNumber);
                                if (this.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    this.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;
                                    v = (string)e.Value;
                                }
                                sums[j] = PriceUtil.JoinPriceString((string)sums[j],
                                    v);
                            }
                                 * */
                        }
                        catch (Exception ex)	// 俘获可能因字符串转换为整数抛出的异常
                        {
                            throw new Exception("在累加 行 " + i.ToString() + " 列 " + column.ColumnNumber.ToString() + " 值的时候,抛出异常: " + ex.Message );
                        }
                    }
                }

                strResult.Append("</tr>\r\n");
            }

            if (this.SumLine == true)
            {
                strResult.Append("<tr class='sum'>\r\n");

                for (j = 0; j < this.Count; j++)
                {
                    PrintColumn column = (PrintColumn)this[j];
                    string strText = "";

                    if (j == 0)
                        strText = "合计";
                    else if (column.Sum == true
                        && sums[j] != null)
                    {
                        if (column.DataType == DataType.PriceDouble)
                            strText = ((double)sums[j]).ToString("N", nfi);
                        else if (column.DataType == DataType.PriceDecimal)
                            strText = ((decimal)sums[j]).ToString("N", nfi);
                        else if (column.DataType == DataType.Price)
                        {
                            strText = StatisUtil.Int64ToPrice((Int64)sums[j]);
                        }
                        else
                            strText = Convert.ToString(sums[j]);

                        if (column.DataType == DataType.Currency)
                        {
                            string strSomPrice = "";
                            string strError = "";
                            // 汇总价格
                            int nRet = PriceUtil.SumPrices(strText,
                                out strSomPrice,
                                out strError);
                            if (nRet == -1)
                                strText = strError;
                            else
                                strText = strSomPrice;
                        }
                    }
                    else
                        strText = column.DefaultValue;  //  "&nbsp;";

                    strResult.Append("<td class='"
                        + column.CssClass
                        + "'>" + strText + "</td>\r\n");
                }

                strResult.Append("</tr>\r\n");
            }

            strResult.Append("</table>\r\n");
            return strResult.ToString();
        }
Exemple #3
0
        // 输出text格式的表格
        public string TextTable(Table table,
            int nMaxLines = -1)
        {
            StringBuilder strResult = new StringBuilder(4096);
            int i, j;

            if (nMaxLines == -1)
                nMaxLines = table.Count;
            // 表格标题
            for (j = 0; j < this.Count; j++)
            {
                PrintColumn column = (PrintColumn)this[j];
                string strText = column.Title;

                if (column.Colspan == 0)
                    strText = "";   // tab 字符不减少

                if (j != 0)
                    strResult.Append("\t");
                strResult.Append(strText);
            }

            strResult.Append("\r\n");

            // 合计数组
            object[] sums = null;

            if (this.SumLine)
            {
                sums = new object[this.Count];
                for (i = 0; i < sums.Length; i++)
                {
                    sums[i] = null;
                }
            }

            // 内容行循环
            for (i = 0; i < Math.Min(nMaxLines, table.Count); i++)
            {
                Line line = table[i];

                if (this.OutputLine != null)
                {
                    OutputLineEventArgs e = new OutputLineEventArgs();
                    e.Line = line;
                    e.Index = i;
                    this.OutputLine(this, e);
                    if (e.Output == false)
                        continue;
                }

                // 列循环
                for (j = 0; j < this.Count; j++)
                {

                    PrintColumn column = (PrintColumn)this[j];

                    if (column.ColumnNumber < -1)
                    {
                        throw (new Exception("PrintColumn对象ColumnNumber列尚未初始化,位置" + Convert.ToString(j)));
                    }

                    string strText = "";
                    if (column.ColumnNumber != -1)
                    {
                        if (column.DataType == DataType.Price)
                        {
                            if (line.IsNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;	// 2005/5/26
                            else
                                strText = line.GetPriceString(column.ColumnNumber);
                        }
                        else
                            strText = line.GetString(column.ColumnNumber, column.DefaultValue);
                    }
                    else
                    {
                        strText = line.Entry;
                    }

                    if (j != 0)
                        strResult.Append("\t");
                    strResult.Append(strText);

                    if (this.SumLine == true
                        && column.Sum == true
                        && column.ColumnNumber != -1)
                    {

                        /*
                        try
                        {
                            sums[j] += line.GetDouble(column.ColumnNumber);
                        }
                        catch	// 俘获可能因字符串转换为数值抛出的异常
                        {
                        }*/

                        try
                        {
                            // if (column.DataType != DataType.Currency)
                            {
                                object v = line.GetObject(column.ColumnNumber);
                                if (this.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    this.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;
                                    v = (decimal)e.Value;
                                }
                                if (sums[j] == null)
                                    sums[j] = v;
                                else
                                    sums[j] = AddValue(column.DataType,
            sums[j],
            v);
                            }
                            /*
                            else
                            {
                                string v = line.GetString(column.ColumnNumber);
                                if (this.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    this.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;
                                    v = (string)e.Value;
                                }
                                sums[j] = PriceUtil.JoinPriceString((string)sums[j],
                                    v);
                            }
                             * */

                        }
                        catch (Exception ex)	// 俘获可能因字符串转换为整数抛出的异常
                        {
                            throw new Exception("在累加 行 " + i.ToString() + " 列 " + column.ColumnNumber.ToString() + " 值的时候,抛出异常: " + ex.Message);
                        }

                    }


                }

                strResult.Append("\r\n");

            }

            if (this.SumLine == true)
            {
                for (j = 0; j < this.Count; j++)
                {
                    PrintColumn column = (PrintColumn)this[j];
                    string strText = "";

                    if (j == 0)
                        strText = "合计";
                    else if (column.Sum == true
                        && sums[j] != null)
                    {
                        if (column.DataType == DataType.Price)
                            strText = StatisUtil.Int64ToPrice((Int64)sums[j]);
                        else
                            strText = Convert.ToString(sums[j]);

                        if (column.DataType == DataType.Currency)
                        {
                            string strSomPrice = "";
                            string strError = "";
                                    // 汇总价格
                            int nRet = PriceUtil.SumPrices(strText,
            out strSomPrice,
            out strError);
                            if (nRet == -1)
                                strText = strError;
                            else
                                strText = strSomPrice;
                        }
                    }
                    else
                        strText = " ";

                    if (j != 0)
                        strResult.Append("\t");
                    strResult.Append(strText);
                }

                strResult.Append("\r\n");
            }

            return strResult.ToString();
        }
Exemple #4
0
        // 输出 RML 格式的表格
        // 本函数负责写入 <table> 元素
        // parameters:
        //      nTopLines   顶部预留多少行
        void OutputRmlTable(
            DbDataReader data_reader,
            XmlTextWriter writer,
            int nMaxLines = -1)
        {
            // StringBuilder strResult = new StringBuilder(4096);
            int i, j;

#if NO
            if (nMaxLines == -1)
                nMaxLines = table.Count;
#endif

            writer.WriteStartElement("table");
            WriteAttributeString(writer, "class", "table");

            writer.WriteStartElement("thead");
            writer.WriteStartElement("tr");

            int nEvalCount = 0; // 具有 eval 的栏目个数
            for (j = 0; j < this.Columns.Count; j++)
            {
                PrintColumn000 column = this.Columns[j];
                if (column.Colspan == 0)
                    continue;

                if (string.IsNullOrEmpty(column.Eval) == false)
                    nEvalCount++;

                writer.WriteStartElement("th");
                if (string.IsNullOrEmpty(column.CssClass) == false)
                    WriteAttributeString(writer, "class", column.CssClass);
                if (column.Colspan > 1)
                    WriteAttributeString(writer, "colspan", column.Colspan.ToString());

                WriteString(writer, column.Title);
                writer.WriteEndElement();   // </th>
            }

            writer.WriteEndElement();   // </tr>
            writer.WriteEndElement();   // </thead>

            // 合计数组
            object[] sums = null;   // 2008/12/1 new changed

            if (this.SumLine)
            {
                sums = new object[this.Columns.Count];
                for (i = 0; i < sums.Length; i++)
                {
                    sums[i] = null;
                }
            }

            NumberFormatInfo nfi = new CultureInfo("zh-CN", false).NumberFormat;
            nfi.NumberDecimalDigits = 2;

            writer.WriteStartElement("tbody");

            // Jurassic.ScriptEngine engine = null;
            if (nEvalCount > 0 && engine == null)
            {
                engine = new Jurassic.ScriptEngine();
                engine.EnableExposedClrTypes = true;
            }

            int nLineCount = 0;

            // 内容行循环
            for (i = 0; ; i++)  // i < Math.Min(nMaxLines, table.Count)
            {
                if (data_reader.Read() == false)
                {
                    if (data_reader.NextResult() == false)
                        break;

                    if (data_reader.Read() == false)
                        break;
                }

                nLineCount++;
#if NO
                if (table.HasRows == false)
                    break;
#endif
                // Line line = table[i];

                if (engine != null)
                {
                    engine.SetGlobalValue("line", data_reader);
                }

                string strLineCssClass = "content";
#if NO
                if (report.OutputLine != null)
                {
                    OutputLineEventArgs e = new OutputLineEventArgs();
                    e.Line = line;
                    e.Index = i;
                    e.LineCssClass = strLineCssClass;
                    report.OutputLine(this, e);
                    if (e.Output == false)
                        continue;

                    strLineCssClass = e.LineCssClass;
                }
#endif

                // strResult.Append("<tr class='" + strLineCssClass + "'>\r\n");
                writer.WriteStartElement("tr");
                WriteAttributeString(writer, "class", strLineCssClass);

                // 列循环
                for (j = 0; j < this.Columns.Count; j++)
                {
                    PrintColumn000 column = this.Columns[j];

                    if (column.ColumnNumber < -1)
                    {
                        throw (new Exception("PrintColumn对象ColumnNumber列尚未初始化,位置" + Convert.ToString(j)));
                    }

                    string strText = "";
                    if (column.ColumnNumber != -1)
                    {
                        // Debug.Assert(column.ColumnNumber < data_reader.FieldCount, "");

                        if (string.IsNullOrEmpty(column.Eval) == false)
                        {
                            // engine.SetGlobalValue("cell", line.GetObject(column.ColumnNumber));
                            engine.SetGlobalValue("rowNumber", nLineCount.ToString());
                            engine.SetGlobalValue("currency", new PriceUtil());
                            strText = engine.Evaluate(column.Eval).ToString();
                        }
                        else if (column.DataType == ColumnDataType.PriceDouble)
                        {
                            if (data_reader.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                double v = data_reader.GetDouble(column.ColumnNumber);
                                /*
                                NumberFormatInfo provider = new NumberFormatInfo();
                                provider.NumberDecimalDigits = 2;
                                provider.NumberGroupSeparator = ".";
                                provider.NumberGroupSizes = new int[] { 3 };
                                strText = Convert.ToString(v, provider);
                                 * */
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == ColumnDataType.PriceDecimal)
                        {
                            if (data_reader.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = data_reader.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == ColumnDataType.PriceDecimal)
                        {
                            if (data_reader.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;
                            else
                            {
                                decimal v = data_reader.GetDecimal(column.ColumnNumber);
                                strText = v.ToString("N", nfi);
                            }
                        }
                        else if (column.DataType == ColumnDataType.Price)
                        {
                            // Debug.Assert(false, "");
                            if (data_reader.IsDBNull(column.ColumnNumber) == true)
                                strText = column.DefaultValue;	// 2005/5/26
                            else
                                strText = data_reader.GetString(column.ColumnNumber);    // 
                        }
                        else if (column.DataType == ColumnDataType.String)
                        {
                            // strText = data_reader.GetString(column.ColumnNumber/*, column.DefaultValue*/);
                            // 2014/8/28
                            object o = data_reader.GetValue(column.ColumnNumber);
                            if (o != null)
                                strText = o.ToString();
                            else
                                strText = "";
                        }
                        else
                        {
                            object o = data_reader.GetValue(column.ColumnNumber);
                            if (o != null)
                                strText = o.ToString();
                            else
                                strText = "";
                        }
                    }
                    else
                    {
                        strText = data_reader.GetString(0);   // line.Entry;
                    }

                    writer.WriteStartElement(j == 0 ? "th" : "td");
                    if (string.IsNullOrEmpty(column.CssClass) == false)
                        WriteAttributeString(writer, "class", column.CssClass);
                    WriteString(writer, strText);
                    writer.WriteEndElement();   // </td>

                    if (this.SumLine == true
                        && column.Sum == true
                        && column.ColumnNumber != -1)
                    {
                        try
                        {
                            // if (column.DataType != DataType.Currency)
                            {
                                object v = null;

                                if (column.ColumnNumber < data_reader.FieldCount)
                                    v = data_reader.GetValue(column.ColumnNumber);
#if NO
                                if (report.SumCell != null)
                                {
                                    SumCellEventArgs e = new SumCellEventArgs();
                                    e.DataType = column.DataType;
                                    e.ColumnNumber = column.ColumnNumber;
                                    e.LineIndex = i;
                                    e.Line = line;
                                    e.Value = v;
                                    report.SumCell(this, e);
                                    if (e.Value == null)
                                        continue;

                                    v = e.Value;
                                }
#endif

                                if (sums[j] == null)
                                    sums[j] = v;
                                else
                                {
                                    sums[j] = AddValue(column.DataType,
            sums[j],
            v);
                                    // sums[j] = ((decimal)sums[j]) + v;
                                }
                            }
                        }
                        catch (Exception ex)	// 俘获可能因字符串转换为整数抛出的异常
                        {
                            throw new Exception("在累加 行 " + i.ToString() + " 列 " + column.ColumnNumber.ToString() + " 值的时候,出现异常: " + ExceptionUtil.GetAutoText(ex));
                        }
                    }
                }

                // strResult.Append("</tr>\r\n");
                writer.WriteEndElement();   // </tr>
            }

            writer.WriteEndElement();   // </tbody>

            if (this.SumLine == true)
            {
                SumLineReader sum_line = null;
                if (engine != null)
                {
                    // 准备 Line 对象
                    sum_line = new SumLineReader();
                    sum_line.FieldValues = sums;
                    sum_line.Read();
#if NO
                    for (j = 1; j < this.Columns.Count; j++)
                    {
                        PrintColumn000 column = this.Columns[j];
                        if (column.Sum == true
                            && sums[j] != null)
                        {
                            sum_line.SetValue(j - 1, sums[j]);
                        }
                    }
#endif
                    engine.SetGlobalValue("line", sum_line);
                    engine.SetGlobalValue("rowNumber", "");
                }

                // strResult.Append("<tr class='sum'>\r\n");
                writer.WriteStartElement("tfoot");
                writer.WriteStartElement("tr");
                WriteAttributeString(writer, "class", "sum");

                for (j = 0; j < this.Columns.Count; j++)
                {
                    PrintColumn000 column = this.Columns[j];
                    string strText = "";

                    if (j == 0)
                        strText = "合计(" + nLineCount.ToString() + "行)";
                    else if (column.Sum == true)
                    {
                        if (string.IsNullOrEmpty(column.Eval) == false)
                        {
                            engine.SetGlobalValue("currency", new PriceUtil());
                            strText = engine.Evaluate(column.Eval).ToString();
                        }
                        else if (column.Sum == true
                            && sums[j] != null)
                        {
                            if (column.DataType == ColumnDataType.PriceDouble)
                                strText = ((double)sums[j]).ToString("N", nfi);
                            else if (column.DataType == ColumnDataType.PriceDecimal)
                                strText = ((decimal)sums[j]).ToString("N", nfi);
                            else if (column.DataType == ColumnDataType.Price)
                            {
                                strText = StatisUtil.Int64ToPrice((Int64)sums[j]);
                            }
                            else
                                strText = Convert.ToString(sums[j]);

                            if (column.DataType == ColumnDataType.Currency)
                            {
                                string strSomPrice = "";
                                string strError = "";
                                // 汇总价格
                                int nRet = PriceUtil.SumPrices(strText,
                out strSomPrice,
                out strError);
                                if (nRet == -1)
                                    strText = strError;
                                else
                                    strText = strSomPrice;
                            }
                        }
                        else
                            strText = column.DefaultValue;  //  "&nbsp;";

                    }

#if NO
                    doc.WriteExcelCell(
    _lineIndex,
    j,
    strText,
    true);
#endif
                    writer.WriteStartElement(j == 0 ? "th" : "td");
                    if (string.IsNullOrEmpty(column.CssClass) == false)
                        WriteAttributeString(writer, "class", column.CssClass);
                    WriteString(writer, strText);
                    writer.WriteEndElement();   // </td>
                }

                // strResult.Append("</tr>\r\n");
                writer.WriteEndElement();   // </tr>
                writer.WriteEndElement();   // </tfoot>
            }

            writer.WriteEndElement();   // </table>
        }