private void AddColumn(SnapList list, string columnName, string caption) { SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables[0]; listHeaderTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; TableCell columnHeader = listHeaderCells.InsertAfter(listHeaderCells.Count - 1); listHeader.InsertText(columnHeader.ContentRange.Start, caption); CharacterProperties prop = listHeader.BeginUpdateCharacters(columnHeader.ContentRange); prop.Bold = true; prop.ForeColor = Color.YellowGreen; listHeader.EndUpdateCharacters(prop); SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables[0]; listRowTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listRowTableCells = listRowTable.FirstRow.Cells; TableCell column = listRowTableCells.InsertAfter(listRowTableCells.Count - 1); listRow.CreateSnText(column.ContentRange.Start, columnName); }
private static void FormatList(SnapList list) { // Customize the list header. SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } }
static void FormatData(SnapDocumentServer server) { #region #FormatData server.LoadDocumentTemplate("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); list.EditorRowLimit = 100500; SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } // Customize the row template. SnapDocument rowTemplate = list.RowTemplate; Table rowTable = rowTemplate.Tables[0]; rowTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in rowTable.Rows) { foreach (TableCell cell in row.Cells) { cell.Borders.Left.LineColor = System.Drawing.Color.Transparent; cell.Borders.Right.LineColor = System.Drawing.Color.Transparent; cell.Borders.Top.LineColor = System.Drawing.Color.Transparent; cell.Borders.Bottom.LineColor = System.Drawing.Color.LightGray; } } list.EndUpdate(); list.Field.Update(); #endregion #FormatData }
private void FormatList(SnapList list) { // Customize the list header. SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } // Customize the row template. SnapDocument rowTemplate = list.RowTemplate; Table rowTable = rowTemplate.Tables[0]; rowTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in rowTable.Rows) { foreach (TableCell cell in row.Cells) { cell.Borders.Left.LineColor = System.Drawing.Color.Transparent; cell.Borders.Right.LineColor = System.Drawing.Color.Transparent; cell.Borders.Top.LineColor = System.Drawing.Color.Transparent; cell.Borders.Bottom.LineColor = System.Drawing.Color.LightGray; } } }