public void SetParagraph(XWPFParagraph p) { if (ctTc.SizeOfPArray() == 0) { ctTc.AddNewP(); } ctTc.SetPArray(0, p.GetCTP()); }
public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part) { this.ctTc = cell; this.part = part; this.tableRow = tableRow; if (cell.GetPList().Count < 1) { cell.AddNewP(); } this.bodyElements = new List <IBodyElement>(); this.paragraphs = new List <XWPFParagraph>(); this.tables = new List <XWPFTable>(); foreach (object obj in this.ctTc.Items) { if (obj is CT_P) { XWPFParagraph xwpfParagraph = new XWPFParagraph((CT_P)obj, (IBody)this); this.paragraphs.Add(xwpfParagraph); this.bodyElements.Add((IBodyElement)xwpfParagraph); } if (obj is CT_Tbl) { XWPFTable xwpfTable = new XWPFTable((CT_Tbl)obj, (IBody)this); this.tables.Add(xwpfTable); this.bodyElements.Add((IBodyElement)xwpfTable); } } }
public void TestGetText() { XWPFDocument doc = new XWPFDocument(); CT_Tbl table = new CT_Tbl(); CT_Row row = table.AddNewTr(); CT_Tc cell = row.AddNewTc(); CT_P paragraph = cell.AddNewP(); CT_R run = paragraph.AddNewR(); CT_Text text = run.AddNewT(); text.Value = ("finally I can Write!"); XWPFTable xtab = new XWPFTable(table, doc); Assert.AreEqual("finally I can Write!\n", xtab.GetText()); }
/** * If a table cell does not include at least one block-level element, then this document shall be considered corrupt */ public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part) { this.ctTc = cell; this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. if (cell.GetPList().Count < 1) { cell.AddNewP(); } bodyElements = new List <IBodyElement>(); paragraphs = new List <XWPFParagraph>(); tables = new List <XWPFTable>(); foreach (object o in ctTc.Items) { if (o is CT_P) { XWPFParagraph p = new XWPFParagraph((CT_P)o, this); paragraphs.Add(p); bodyElements.Add(p); } if (o is CT_Tbl) { XWPFTable t = new XWPFTable((CT_Tbl)o, this); tables.Add(t); bodyElements.Add(t); } } /* * XmlCursor cursor = ctTc.NewCursor(); * cursor.SelectPath("./*"); * while (cursor.ToNextSelection()) { * XmlObject o = cursor.Object; * if (o is CTP) { * XWPFParagraph p = new XWPFParagraph((CTP)o, this); * paragraphs.Add(p); * bodyElements.Add(p); * } * if (o is CTTbl) { * XWPFTable t = new XWPFTable((CTTbl)o, this); * tables.Add(t); * bodyElements.Add(t); * } * } * cursor.Dispose();*/ }
/** * If a table cell does not include at least one block-level element, then this document shall be considered corrupt */ public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part) { this.ctTc = cell; this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. if(cell.GetPList().Count<1) cell.AddNewP(); bodyElements = new List<IBodyElement>(); paragraphs = new List<XWPFParagraph>(); tables = new List<XWPFTable>(); foreach (object o in ctTc.Items) { if (o is CT_P) { XWPFParagraph p = new XWPFParagraph((CT_P)o, this); paragraphs.Add(p); bodyElements.Add(p); } if (o is CT_Tbl) { XWPFTable t = new XWPFTable((CT_Tbl)o, this); tables.Add(t); bodyElements.Add(t); } } /* XmlCursor cursor = ctTc.NewCursor(); cursor.SelectPath("./*"); while (cursor.ToNextSelection()) { XmlObject o = cursor.Object; if (o is CTP) { XWPFParagraph p = new XWPFParagraph((CTP)o, this); paragraphs.Add(p); bodyElements.Add(p); } if (o is CTTbl) { XWPFTable t = new XWPFTable((CTTbl)o, this); tables.Add(t); bodyElements.Add(t); } } cursor.Dispose();*/ }
/** * If a table cell does not include at least one block-level element, then this document shall be considered corrupt */ public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part) { this.ctTc = cell; this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. if (cell.GetPList().Count < 1) { cell.AddNewP(); } bodyElements = new List <IBodyElement>(); paragraphs = new List <XWPFParagraph>(); tables = new List <XWPFTable>(); foreach (object o in ctTc.Items) { if (o is CT_P) { XWPFParagraph p = new XWPFParagraph((CT_P)o, this); paragraphs.Add(p); bodyElements.Add(p); } if (o is CT_Tbl) { XWPFTable t = new XWPFTable((CT_Tbl)o, this); tables.Add(t); bodyElements.Add(t); } if (o is CT_SdtBlock) { XWPFSDT c = new XWPFSDT((CT_SdtBlock)o, this); bodyElements.Add(c); } if (o is CT_SdtRun) { XWPFSDT c = new XWPFSDT((CT_SdtRun)o, this); bodyElements.Add(c); } } }
/** * If a table cell does not include at least one block-level element, then this document shall be considered corrupt */ public XWPFTableCell(CT_Tc cell, XWPFTableRow tableRow, IBody part) { this.ctTc = cell; this.part = part; this.tableRow = tableRow; // NB: If a table cell does not include at least one block-level element, then this document shall be considered corrupt. if(cell.GetPList().Count<1) cell.AddNewP(); bodyElements = new List<IBodyElement>(); paragraphs = new List<XWPFParagraph>(); tables = new List<XWPFTable>(); foreach (object o in ctTc.Items) { if (o is CT_P) { XWPFParagraph p = new XWPFParagraph((CT_P)o, this); paragraphs.Add(p); bodyElements.Add(p); } if (o is CT_Tbl) { XWPFTable t = new XWPFTable((CT_Tbl)o, this); tables.Add(t); bodyElements.Add(t); } if (o is CT_SdtBlock) { XWPFSDT c = new XWPFSDT((CT_SdtBlock)o, this); bodyElements.Add(c); } if (o is CT_SdtRun) { XWPFSDT c = new XWPFSDT((CT_SdtRun)o, this); bodyElements.Add(c); } } }