public override void Visit(ExportCell cell, Action inner) { inner(); var escapedValue = EscapeForCsv(cell.Text); _Csv.Append(escapedValue); AppendColumnDelimiters(cell.ColumnSpan); }
private void SetWrap(ExportCell cell) { if (!cell.AllowWrapping.HasValue || !cell.AllowWrapping.Value) { _Html.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true"); } }
private void SetColumnSpan(ExportCell cell) { if (cell.ColumnSpan.HasValue && cell.ColumnSpan.Value > 1) { _Html.AddAttribute(HtmlTextWriterAttribute.Colspan, cell.ColumnSpan.ToString()); } }
public void AddCell(ExportCell cell) { if (cell.HorizontalAlignment == HorizontalAlign.NotSet) { cell.HorizontalAlignment = DefaultHorizontalAlign; } Cells.Add(cell); }
public override void Visit(ExportCell cell, Action inner) { SetColumnSpan(cell); SetHorizontalAlignment(cell.HorizontalAlignment); SetWrap(cell); StartTag(HtmlTextWriterTag.Td); SetContent(cell); inner(); EndTag(); }
private void SetContent(ExportCell cell) { if (string.IsNullOrEmpty(cell.Markup)) { _Html.WriteEncodedText(cell.Text.Replace(" ", " ")); } else { _Html.Write(cell.Markup); } }
private static void SetContent(Control control, ExportCell cell, HtmlTextWriter htmlwriter) { if (control is IButtonControl) { var button = control as IButtonControl; cell.Text += button.Text; } else { control.RenderControl(htmlwriter); } }
private static void SetColspan(HtmlTag cell, ExportCell exportCell) { if (!cell.HasAttr(HtmlAttributeConstants.Colspan)) { return; } int colspan; if (int.TryParse(cell.Attr(HtmlAttributeConstants.Colspan), out colspan)) { exportCell.ColumnSpan = colspan; } }
private static void RenderInnerControlContent(TableCell tableCell, ExportCell cell) { if (!tableCell.HasControls()) { return; } using (var writer = new StringWriter()) using (var html = new HtmlTextWriter(writer)) { tableCell.Controls.OfType<Control>() .Where(c => c.Visible) .Where(c => !(c is HiddenField)) .ForEach(c => SetContent(c, cell, html)); cell.Markup += writer.ToString(); } cell.Text += HtmlTagRegex.Replace(cell.Markup, String.Empty); }
private static void RenderInnerControlContent(TableCell tableCell, ExportCell cell) { if (!tableCell.HasControls()) { return; } using (var writer = new StringWriter()) using (var html = new HtmlTextWriter(writer)) { tableCell.Controls.OfType <Control>() .Where(c => c.Visible) .Where(c => !(c is HiddenField)) .ForEach(c => SetContent(c, cell, html)); cell.Markup += writer.ToString(); } cell.Text += HtmlTagRegex.Replace(cell.Markup, String.Empty); }
private static void VisitTableCell(HtmlTag cell, ExportRow exportRow) { var tag = cell.TagName().ToLower(); if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th) { cell.Children.ForEach(c => VisitTableCell(c, exportRow)); return; } var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img); var text = cell.Children.Any() ? cell.ToString() : cell.Text(); var exportCell = new ExportCell { Text = ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty), Markup = isImage ? cell.FirstChild().ToString():string.Empty }; SetColspan(cell, exportCell); exportRow.AddCell(exportCell); }
public abstract void Visit(ExportCell cell, Action inner);
private static void VisitTableCell(HtmlTag cell, ExportRow exportRow) { var tag = cell.TagName().ToLower(); if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th ) { cell.Children.ForEach(c => VisitTableCell(c, exportRow)); return; } var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img); var text = cell.Children.Any() ? cell.ToString() : cell.Text(); var exportCell = new ExportCell { Text = ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty), Markup = isImage ? cell.FirstChild().ToString():string.Empty }; SetColspan(cell, exportCell); exportRow.AddCell(exportCell); }
private static void SetColspan(HtmlTag cell, ExportCell exportCell) { if (!cell.HasAttr(HtmlAttributeConstants.Colspan)) { return; } int colspan; if(int.TryParse(cell.Attr(HtmlAttributeConstants.Colspan), out colspan)) { exportCell.ColumnSpan = colspan; } }