private void GetTable(TableTextItem ti)
        {
            var data = new DataTable();

            using (var stream = new MemoryStream())
            {
                var writer = new StreamWriter(stream);
                writer.Write(ti.DataTableXml);
                writer.Flush();
                stream.Position = 0;
                data.ReadXml(stream);
            }

            Pdf.AddTable(data, ti.Content, "NoHeading1", "", "", Pdf.Width);
        }
        private StringBuilder GetTable(TableTextItem ti)
        {
            var data = new DataTable();

            using (var stream = new MemoryStream())
            {
                var writer = new StreamWriter(stream);
                writer.Write(ti.DataTableXml);
                writer.Flush();
                stream.Position = 0;
                data.ReadXml(stream);
            }

            var    erg = new StringBuilder();
            string css;

            erg.AppendFormat("<table class=\"{0}\">\r\n", CssTable);

            if (!string.IsNullOrEmpty(ti.Content))
            {
                erg.AppendFormat("<caption>{0}</caption>\r\n", ti.Content);
            }

            erg.Append("<tr>\r\n");
            foreach (DataColumn col in data.Columns)
            {
                string s;

                css = CssThLeft;

                var dt = col.DataType.ToString().ToLower().Replace("system.", "");

                switch (dt)
                {
                case "boolean":
                    css = CssThCenter;
                    s   = col.ColumnName;
                    break;

                case "char":
                    s = col.ColumnName;
                    break;
                //case "sbyte":

                //    break;
                case "decimal":
                case "double":
                case "single":
                    css = CssThRight;
                    s   = col.ColumnName;
                    break;

                case "datetime":
                case "timespan":
                    css = CssThCenter;
                    s   = col.ColumnName;
                    break;

                case "byte":
                case "int16":
                case "int32":
                case "int64":
                case "uint16":
                case "uint32":
                case "uint64":
                    css = CssThRight;
                    s   = col.ColumnName;
                    break;

                default:
                    s = col.ColumnName;
                    break;
                }

                erg.AppendFormat("<th class=\"{1}\">{0}</th>\r\n", s, css);
            }
            erg.Append("</tr>\r\n");

            var alternateRow = false;

            foreach (DataRow row in data.Rows)
            {
                erg.Append("<tr>\r\n");

                foreach (DataColumn col in data.Columns)
                {
                    string s;
                    css = alternateRow ? CssTdLeftAlt : CssTdLeft;

                    var dt = col.DataType.ToString().ToLower().Replace("system.", "");

                    switch (dt)
                    {
                    case "boolean":
                        css = alternateRow ? CssTdCenterAlt : CssTdCenter;
                        s   = row[col.ColumnName].ToString();
                        break;

                    case "char":
                        s = col.ColumnName;
                        break;
                    //case "sbyte":

                    //    break;
                    case "decimal":
                    case "double":
                    case "single":
                        css = alternateRow ? CssTdRightAlt : CssTdRight;
                        var nValue = Convert.ToDecimal(row[col.ColumnName]);
                        s = $"{nValue:#,##0.00}";
                        break;

                    case "datetime":
                        //case "timespan":
                        css = alternateRow ? CssTdCenterAlt : CssTdCenter;
                        var dValue = Convert.ToDateTime(row[col.ColumnName]);
                        s = $"{dValue:d}";
                        break;

                    case "byte":
                    case "int16":
                    case "int32":
                    case "int64":
                    case "uint16":
                    case "uint32":
                    case "uint64":
                        css = alternateRow ? CssTdRightAlt : CssTdRight;
                        var iValue = Convert.ToInt64(row[col.ColumnName]);
                        s = $"{iValue:#,##0}";
                        break;

                    default:

                        s = row[col.ColumnName].ToString();
                        break;
                    }

                    erg.AppendFormat("<td class=\"{1}\">{0}</td>\r\n", s, css);
                }

                erg.Append("</tr>\r\n");
                alternateRow = !alternateRow;
            }

            erg.Append("</table>\r\n");
            return(erg);
        }
        private StringBuilder GetTable(TableTextItem ti)
        {
            var erg = new StringBuilder();

            var data = new DataTable();

            using (var stream = new MemoryStream())
            {
                var writer = new StreamWriter(stream);
                writer.Write(ti.DataTableXml);
                writer.Flush();
                stream.Position = 0;
                data.ReadXml(stream);
            }

            foreach (DataColumn col in data.Columns)
            {
                switch (col.DataType.ToString().ToLower())
                {
                case "boolean":
                    erg.Append(col.ColumnName);
                    break;

                case "char":
                    var ml = col.MaxLength;

                    erg.Append(col.ColumnName.PadRight(ml));
                    break;
                //case "sbyte":

                //    break;
                case "decimal":
                case "double":
                case "single":
                    erg.Append(col.ColumnName.PadLeft(15));
                    break;

                case "datetime":
                case "timespan":
                    erg.Append(col.ColumnName.PadLeft(15));
                    break;

                case "byte":
                case "int16":
                case "int32":
                case "int64":
                case "uint16":
                case "uint32":
                case "uint64":
                    erg.Append(col.ColumnName.PadLeft(10));
                    break;

                default:

                    erg.Append(col.ColumnName.PadRight(15));
                    break;
                }
            }
            erg.Append("\r\n");

            foreach (DataRow row in data.Rows)
            {
                foreach (DataColumn col in data.Columns)
                {
                    switch (col.DataType.ToString().ToLower())
                    {
                    case "boolean":
                        erg.Append(row[col.ColumnName].ToString());
                        break;

                    case "char":
                        var ml = col.MaxLength;

                        erg.Append(col.ColumnName.PadRight(ml));
                        break;
                    //case "sbyte":

                    //    break;
                    case "decimal":
                    case "double":
                    case "single":
                        var nValue = Convert.ToDecimal(row[col.ColumnName]);
                        erg.Append($"{nValue:#,##0.00}".PadLeft(15));
                        break;

                    case "datetime":
                        //case "timespan":
                        var dValue = Convert.ToDateTime(row[col.ColumnName]);
                        erg.Append($"{dValue:d}".PadLeft(15));
                        break;

                    case "byte":
                    case "int16":
                    case "int32":
                    case "int64":
                    case "uint16":
                    case "uint32":
                    case "uint64":
                        var iValue = Convert.ToInt64(row[col.ColumnName]);
                        erg.Append($"{iValue:#,##0}".PadLeft(10));
                        break;

                    default:

                        erg.Append(row[col.ColumnName].ToString().PadRight(15));
                        break;
                    }
                }

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

            return(erg);
        }