Пример #1
0
        public void Append(string text, string style = null)
        {
            var paragraph = new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(text)));

            if (style != null)
            {
                paragraph.ParagraphProperties = new ParagraphProperties(
                    new ParagraphStyleId
                {
                    Val = _document.GetStyleIdFromStyleName(style)
                });
            }

            _body.AppendChild(paragraph);
        }
Пример #2
0
        public void AppendCell(string value)
        {
            var cell = new TableCell();

            var index = _row.Descendants <TableCell>().Count();

            if (index < this._columnWidths.Length)
            {
                cell.Append(new TableCellProperties(
                                new TableCellWidth {
                    Width = this._columnWidths[index].ToString()
                }));
            }

            var paragraph = new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(value)));

            paragraph.ParagraphProperties = new ParagraphProperties(
                new ParagraphStyleId
            {
                Val = _document.GetStyleIdFromStyleName(_table.Descendants <TableRow>().Count() > 1 ? "Table Cell" : "Table Header")
            });
            cell.Append(paragraph);
            _row.Append(cell);
        }