public Word.TableCell GenerateCell(string val, string w, int span = 0, bool bold = false, string sz = "12", string s = "style22", string f = "Courier New", Word.JustificationValues halign = Word.JustificationValues.Left) { Word.LeftMargin margin = new Word.LeftMargin { Type = new EnumValue <Word.TableWidthUnitValues>(Word.TableWidthUnitValues.Dxa), Width = new StringValue("10") }; Word.TableCellWidth width = new Word.TableCellWidth { Type = new EnumValue <Word.TableWidthUnitValues>(Word.TableWidthUnitValues.Dxa), Width = w }; Word.Shading shading = new Word.Shading { Fill = "auto", Val = new EnumValue <Word.ShadingPatternValues>(Word.ShadingPatternValues.Clear) }; Word.TableCellMargin cellmargin = new Word.TableCellMargin(margin); Word.VerticalTextAlignmentOnPage align = new Word.VerticalTextAlignmentOnPage { Val = new EnumValue <Word.VerticalJustificationValues>(Word.VerticalJustificationValues.Center) }; Word.GridSpan gspan = new Word.GridSpan { Val = span }; Word.TableCellProperties props = new Word.TableCellProperties(width, shading, cellmargin, align, gspan); Word.Paragraph paragraph = GenerateParagraph(val, bold, sz, s, f, halign); Word.TableCell cell = new Word.TableCell(props, paragraph); return(cell); }
public Word.Paragraph GenerateParagraph(string val, bool bold = false, string sz = "12", string s = "style22", string f = "Courier New", Word.JustificationValues align = Word.JustificationValues.Left) { Word.ParagraphStyleId pstyle = new Word.ParagraphStyleId { Val = s }; Word.Justification jut = new Word.Justification { Val = new EnumValue <Word.JustificationValues>(align) }; Word.ParagraphProperties pprop = new Word.ParagraphProperties(pstyle, jut); Word.RunProperties rprop = new Word.RunProperties( new Word.RunFonts { Ascii = f, ComplexScript = f, HighAnsi = f }, new Word.Bold { Val = new OnOffValue(bold) }, new Word.BoldComplexScript { Val = new OnOffValue(bold) }, new Word.FontSize { Val = sz }); Word.Text text = new Word.Text(val); Word.Run run = new Word.Run(rprop, text); return(new Word.Paragraph(pprop, run)); }
public static void SetJustification(ParagraphProperties pp, JustificationValues jv) { OpenXmlElementHelper.SetChild(pp, new Justification { Val = jv }); }