Пример #1
0
        public void TestSetGetColor()
        {
            // create a table
            XWPFDocument doc     = new XWPFDocument();
            CT_Tbl       ctTable = new CT_Tbl();
            XWPFTable    table   = new XWPFTable(ctTable, doc);
            // table has a single row by default; grab it
            XWPFTableRow tr = table.GetRow(0);

            Assert.IsNotNull(tr);
            // row has a single cell by default; grab it
            XWPFTableCell cell = tr.GetCell(0);

            cell.SetColor("F0000F");
            String clr = cell.GetColor();

            Assert.AreEqual("F0000F", clr);
        }
Пример #2
0
        private static void CopyCell(XWPFTableCell templateCell, XWPFTableCell cell)
        {
            cell.SetColor(templateCell.GetColor());

            CT_TcBorders templateBorders = templateCell.GetCTTc().tcPr.tcBorders;

            if (templateBorders != null)
            {
                CT_TcBorders borders = cell.GetCTTc().AddNewTcPr().AddNewTcBorders();
                WordGenerator.CopyBorders(templateBorders, borders);
            }

            for (int i = 0; i < cell.Paragraphs.Count; i++)
            {
                cell.RemoveParagraph(0);
            }

            foreach (XWPFParagraph templateph in templateCell.Paragraphs)
            {
                XWPFParagraph ph = cell.AddParagraph();
                WordGenerator.CopyParagraph(templateph, ph);
            }
        }