private string GetHtmlTable(CoreGrid grid, List <Hashtable> data)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(
                "<html><head><style> table, td {border:1px solid black} table { border-collapse:collapse; background:transparent}</style></head> ");

            stringBuilder.Append("<table>");
            stringBuilder.Append("<tr>");
            foreach (CoreColumn column in grid.Columns)
            {
                if (column.Visible)
                {
                    string arg       = string.IsNullOrEmpty(column.HeaderText) ? column.DataField : column.HeaderText;
                    string sizeRowPx = column.ExcelWidthRowPx != 0 ? column.ExcelWidthRowPx + "px;" : "";
                    if (!string.IsNullOrWhiteSpace(sizeRowPx))
                    {
                        stringBuilder.AppendFormat("<td style=\"width: {0}\">{1}</td>", sizeRowPx, arg);
                    }
                    else
                    {
                        stringBuilder.AppendFormat("<td>{0}</td>", arg);
                    }
                }
            }
            stringBuilder.Append("</tr>");
            for (int i = 0; i < data.Count; i++)
            {
                stringBuilder.Append("<tr>");
                for (int j = 0; j < grid.Columns.Count; j++)
                {
                    CoreColumn coreColumn = grid.Columns[j];
                    if (coreColumn.Visible)
                    {
                        string arg2 =
                            (!string.IsNullOrEmpty(coreColumn.DataField) &&
                             !string.IsNullOrEmpty(coreColumn.DataFormatString))
                                                ? coreColumn.FormatDataValue(data[i][coreColumn.DataField], coreColumn.HtmlEncode)
                                                : (data[i][coreColumn.DataField]?.ToString());
                        stringBuilder.AppendFormat("<td>{0}</td>", arg2);
                    }
                }

                stringBuilder.Append("</tr>");
            }
            stringBuilder.Append("</table>");
            return(stringBuilder.ToString());
        }
示例#2
0
 internal static JsonTreeResponse PrepareJsonTreeResponse(JsonTreeResponse response, CoreGrid grid, List <Hashtable> data)
 {
     for (int i = 0; i < data.Count; i++)
     {
         for (int j = 0; j < grid.Columns.Count; j++)
         {
             CoreColumn coreColumn = grid.Columns[j];
             if (!string.IsNullOrEmpty(coreColumn.DataField) && !string.IsNullOrEmpty(coreColumn.DataFormatString))
             {
                 data[i][coreColumn.DataField] = coreColumn.FormatDataValue(data[i][coreColumn.DataField], coreColumn.HtmlEncode);
             }
         }
         response.rows[i] = data[i];
     }
     return(response);
 }
        private string GetOutput(CoreGrid grid, List <Hashtable> data)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (ExportSettings.ExportHeaders)
            {
                foreach (CoreColumn column in grid.Columns)
                {
                    stringBuilder.AppendFormat("{0}{1}", QuoteText(column.DataField), ExportSettings.CSVSeparator);
                }
            }
            stringBuilder.Append("\n");
            for (int i = 0; i < data.Count; i++)
            {
                for (int j = 0; j < Columns.Count; j++)
                {
                    if (Columns[j].Visible)
                    {
                        CoreColumn coreColumn = grid.Columns[j];
                        string     text       = (!string.IsNullOrEmpty(coreColumn.DataField) && !string.IsNullOrEmpty(coreColumn.DataFormatString)) ? coreColumn.FormatDataValue(data[i][coreColumn.DataField], coreColumn.HtmlEncode) : (data[i][coreColumn.DataField] as string);
                        stringBuilder.AppendFormat("{0}{1}", data[i][coreColumn.DataField], ExportSettings.CSVSeparator);
                    }
                }
                stringBuilder.Append("\n");
            }
            return(stringBuilder.ToString());
        }