Пример #1
0
        private static void setCellData(TableRow tr1, int index, string value)
        {
            var cell = tr1.Descendants <TableCell>().ElementAtOrDefault(index);

            DocumentFormat.OpenXml.Drawing.TextBody tb = cell.Elements <DocumentFormat.OpenXml.Drawing.TextBody>().First();
            Paragraph p = tb.Elements <Paragraph>().ElementAtOrDefault(0);
            Run       r = p.Elements <Run>().FirstOrDefault();

            //Run r = new Run();
            //RunProperties runProperties2 = new RunProperties() { Language = "en-US" };
            //DocumentFormat.OpenXml.Drawing.Text t = new DocumentFormat.OpenXml.Drawing.Text();
            //t.Text = value;
            //r.Append(runProperties2);
            //r.Append(t);
            //p.Append(r);
            if (r != null)
            {
                DocumentFormat.OpenXml.Drawing.Text t = r.Elements <DocumentFormat.OpenXml.Drawing.Text>().First();
                t.Text = value;
            }
            else
            {
            }
            //return t;
        }
Пример #2
0
        private void MergeParagraphs(int minRowIndex, int minColIndex, A.TableCell aTblCell)
        {
            A.TextBody mergedCellTextBody = ((SCTableCell)this[minRowIndex, minColIndex]).ATableCell.TextBody;
            bool       hasMoreOnePara     = false;
            IEnumerable <A.Paragraph> aParagraphsWithARun =
                aTblCell.TextBody.Elements <A.Paragraph>().Where(p => !p.IsEmpty());

            foreach (A.Paragraph aParagraph in aParagraphsWithARun)
            {
                mergedCellTextBody.Append(aParagraph.CloneNode(true));
                hasMoreOnePara = true;
            }

            if (hasMoreOnePara)
            {
                foreach (A.Paragraph aParagraph in mergedCellTextBody.Elements <A.Paragraph>().Where(p => p.IsEmpty()))
                {
                    aParagraph.Remove();
                }
            }
        }