public Table AppendTotalPriceTableInfo(List <string> tableData, Table table, bool header) { TableRow tr = new TableRow(); PreviousTablePropertyExceptions ptpex = new PreviousTablePropertyExceptions(); TableCellMarginDefault tcm = new TableCellMarginDefault(); tcm.TopMargin = new TopMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; tcm.BottomMargin = new BottomMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; ptpex.Append(tcm); tr.Append(ptpex); TableCell tc; TableCellProperties tcp = new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); tcp.TableCellMargin = new TableCellMargin(new RightMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }); tcp.TableCellMargin.LeftMargin = new LeftMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }; tcp.TableCellMargin.TopMargin = new TopMargin() { Type = TableWidthUnitValues.Pct, Width = "1" }; tcp.TableCellBorders = new TableCellBorders( new TopBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 }, new BottomBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 }, new LeftBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 }, new RightBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 }, new InsideHorizontalBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 }, new InsideVerticalBorder() { Val = new EnumValue <BorderValues>(BorderValues.None), Size = 0, Space = 0 } ); ParagraphProperties ppl = new ParagraphProperties(new Justification() { Val = JustificationValues.Left }); ParagraphProperties ppr = new ParagraphProperties(new Justification() { Val = JustificationValues.Right }); ppl.Append(new KeepLines()); ppl.Append(new KeepNext()); SpacingBetweenLines sp = new SpacingBetweenLines(); sp.After = "0"; ppl.Append(sp); ppr.Append(new KeepLines()); ppr.Append(new KeepNext()); SpacingBetweenLines spr = new SpacingBetweenLines(); spr.After = "0"; ppr.Append(spr); RunProperties rp = new RunProperties(new Bold() { Val = false }); Shading shading = new Shading(); rp.Bold.Val = false; rp.RunFonts = new RunFonts() { Ascii = "Calibri" }; rp.FontSize = new FontSize() { Val = new StringValue("26") }; shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto" }; tcp.Shading = shading; for (int i = 0; i < tableData.Count; i++) { tc = new TableCell(); //TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Dxa }; //tcp.Append(tableStyle, tableWidth); tcp.Append(tableWidth); if (i == 0 || i == 2 || i == 4) { tcp.TableCellWidth = new TableCellWidth() { Width = "4900", Type = TableWidthUnitValues.Dxa }; tc.Append((ParagraphProperties)ppr.Clone()); tc.Append((TableCellProperties)tcp.Clone()); } else { tcp.TableCellWidth = new TableCellWidth() { Width = "100", Type = TableWidthUnitValues.Dxa }; tc.Append((ParagraphProperties)ppl.Clone()); tc.Append((TableCellProperties)tcp.Clone()); } Run r = new Run(); r.PrependChild <RunProperties>((RunProperties)rp.Clone()); r.Append(new Text(tableData[i].ToString())); tc.Append(new Paragraph(r)); tr.Append(tc); } table.Append(tr); return(table); }
public Table AppendInvoiceTableInfo(List <string> tableData, Table table, bool header) { TableRow tr = new TableRow(); PreviousTablePropertyExceptions ptpex = new PreviousTablePropertyExceptions(); TableCellMarginDefault tcm = new TableCellMarginDefault(); tcm.TopMargin = new TopMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; tcm.BottomMargin = new BottomMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; ptpex.Append(tcm); tr.Append(ptpex); TableCell tc; TableCellProperties tcp = new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); tcp.TableCellMargin = new TableCellMargin(new RightMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }); tcp.TableCellMargin.LeftMargin = new LeftMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }; tcp.TableCellMargin.TopMargin = new TopMargin() { Type = TableWidthUnitValues.Pct, Width = "1" }; ParagraphProperties ppp = new ParagraphProperties(new Justification() { Val = JustificationValues.Center }); ppp.Append(new KeepLines()); ppp.Append(new KeepNext()); SpacingBetweenLines sp = new SpacingBetweenLines(); sp.After = "0"; ppp.Append(sp); if (!header) { RunProperties rp = new RunProperties(new Bold() { Val = false }); Shading shading = new Shading(); rp.Bold.Val = false; rp.RunFonts = new RunFonts() { Ascii = "Calibri" }; rp.FontSize = new FontSize() { Val = new StringValue("22") }; //shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "e3e6e7" }; shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto" }; tcp.Shading = shading; for (int i = 0; i < tableData.Count; i++) { tc = new TableCell(); //TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "50000", Type = TableWidthUnitValues.Auto }; tcp.Append(tableWidth); tc.Append((TableCellProperties)tcp.Clone()); tc.Append((ParagraphProperties)ppp.Clone()); Run r = new Run(); r.PrependChild <RunProperties>((RunProperties)rp.Clone()); r.Append(new Text(tableData[i].ToString())); tc.Append(new Paragraph(r)); tr.Append(tc); } } else { RunProperties rp = new RunProperties(new Bold() { Val = true }, new TabChar()); rp.Bold.Val = true; rp.RunFonts = new RunFonts() { Ascii = "Arial" }; rp.FontSize = new FontSize() { Val = new StringValue("20") }; //Color color = new Color() { Val = "365F91", ThemeColor = ThemeColorValues.Accent1, ThemeShade = "BF" }; Shading shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "a7c6d7" }; //ppp.Shading = shading; tcp.TableCellMargin.TopMargin.Width = "200"; tcp.Shading = shading; for (int i = 0; i < tableData.Count; i++) { tc = new TableCell(); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "50000", Type = TableWidthUnitValues.Auto }; tcp.Append(tableStyle, tableWidth); tc.Append((TableCellProperties)tcp.Clone()); tc.Append((ParagraphProperties)ppp.Clone()); Run r = new Run(); r.PrependChild <RunProperties>((RunProperties)rp.Clone()); r.Append(new Text(tableData[i].ToString())); tc.Append(new Paragraph(r)); tr.Append(tc); } } table.Append(tr); return(table); }