本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFParagraph类的典型用法代码示例。如果您正苦于以下问题:C# XWPFParagraph类的具体用法?C# XWPFParagraph怎么用?C# XWPFParagraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XWPFParagraph类属于NPOI.XWPF.UserModel命名空间,在下文中一共展示了XWPFParagraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XWPFTable
public XWPFTable(CT_Tbl table, IBody part)
{
this.part = part;
this.ctTbl = table;
tableRows = new List<XWPFTableRow>();
// is an empty table: I add one row and one column as default
if (table.SizeOfTrArray() == 0)
CreateEmptyTable(table);
foreach (CT_Row row in table.GetTrList()) {
StringBuilder rowText = new StringBuilder();
row.Table = table;
XWPFTableRow tabRow = new XWPFTableRow(row, this);
tableRows.Add(tabRow);
foreach (CT_Tc cell in row.GetTcList()) {
cell.TableRow = row;
foreach (CT_P ctp in cell.GetPList()) {
XWPFParagraph p = new XWPFParagraph(ctp, part);
if (rowText.Length > 0) {
rowText.Append('\t');
}
rowText.Append(p.GetText());
}
}
if (rowText.Length > 0) {
this.text.Append(rowText);
this.text.Append('\n');
}
}
}
示例2: XWPFHeader
public XWPFHeader(XWPFDocument doc, CT_HdrFtr hdrFtr)
: base(doc, hdrFtr)
{
/*
XmlCursor cursor = headerFooter.NewCursor();
cursor.SelectPath("./*");
while (cursor.ToNextSelection()) {
XmlObject o = cursor.Object;
if (o is CTP) {
XWPFParagraph p = new XWPFParagraph((CTP) o, this);
paragraphs.Add(p);
}
if (o is CTTbl) {
XWPFTable t = new XWPFTable((CTTbl) o, this);
tables.Add(t);
}
}
cursor.Dispose();*/
foreach (object o in hdrFtr.Items)
{
if (o is CT_P)
{
XWPFParagraph p = new XWPFParagraph((CT_P)o, this);
paragraphs.Add(p);
}
if (o is CT_Tbl)
{
XWPFTable t = new XWPFTable((CT_Tbl)o, this);
tables.Add(t);
}
}
}
示例3: XWPFSDTContent
public XWPFSDTContent(CT_SdtContentBlock block, IBody part, IRunBody parent)
{
foreach (object o in block.Items)
{
if (o is CT_P)
{
XWPFParagraph p = new XWPFParagraph((CT_P)o, part);
bodyElements.Add(p);
paragraphs.Add(p);
}
else if (o is CT_Tbl)
{
XWPFTable t = new XWPFTable((CT_Tbl)o, part);
bodyElements.Add(t);
tables.Add(t);
}
else if (o is CT_SdtBlock)
{
XWPFSDT c = new XWPFSDT(((CT_SdtBlock)o), part);
bodyElements.Add(c);
contentControls.Add(c);
}
else if (o is CT_R)
{
XWPFRun run = new XWPFRun((CT_R)o, parent);
runs.Add(run);
bodyElements.Add(run);
}
}
}
示例4: XWPFComment
public XWPFComment(CT_Comment comment, XWPFDocument document)
{
text = new StringBuilder();
id = comment.id.ToString();
author = comment.author;
foreach(CT_P ctp in comment.GetPList())
{
XWPFParagraph p = new XWPFParagraph(ctp, document);
text.Append(p.Text);
}
}
示例5: XWPFCommentsDecorator
public XWPFCommentsDecorator(XWPFParagraph paragraph, XWPFParagraphDecorator nextDecorator)
: base(paragraph, nextDecorator)
{
;
XWPFComment comment;
commentText = new StringBuilder();
foreach (CT_MarkupRange anchor in paragraph.GetCTP().GetCommentRangeStartList())
{
if ((comment = paragraph.Document.GetCommentByID(anchor.id)) != null)
commentText.Append("\tComment by " + comment.GetAuthor() + ": " + comment.GetText());
}
}
示例6: XWPFTableCell
/**
* 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();*/
}
示例7: XWPFHyperlinkDecorator
/**
* @param prgrph The paragraph of text to work on
* @param outputHyperlinkUrls Should we output the links too, or just the link text?
*/
public XWPFHyperlinkDecorator(XWPFParagraph prgrph, XWPFParagraphDecorator nextDecorator, bool outputHyperlinkUrls)
: base(prgrph, nextDecorator)
{
hyperlinkText = new StringBuilder();
// loop over hyperlink anchors
foreach (CT_Hyperlink1 link in paragraph.GetCTP().GetHyperlinkList())
{
foreach (CT_R r in link.GetRList())
{
// Loop over text Runs
foreach (CT_Text text in r.GetTList())
{
hyperlinkText.Append(text.Value);
}
}
if (outputHyperlinkUrls && paragraph.GetDocument().GetHyperlinkByID(link.id) != null)
{
hyperlinkText.Append(" <" + paragraph.GetDocument().GetHyperlinkByID(link.id).URL + ">");
}
}
}
示例8: XWPFTableCell
/**
* 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);
}
}
}
示例9: XWPFRun
/**
* @param r the CT_R bean which holds the run.attributes
* @param p the parent paragraph
*/
public XWPFRun(CT_R r, XWPFParagraph p)
{
this.run = r;
this.paragraph = p;
/**
* reserve already occupied Drawing ids, so reserving new ids later will
* not corrupt the document
*/
IList<NPOI.OpenXmlFormats.Wordprocessing.CT_Drawing> drawingList = r.GetDrawingList();
foreach (NPOI.OpenXmlFormats.Wordprocessing.CT_Drawing ctDrawing in drawingList)
{
List<CT_Anchor> anchorList = ctDrawing.GetAnchorList();
foreach (CT_Anchor anchor in anchorList)
{
if (anchor.docPr != null)
{
GetDocument().GetDrawingIdManager().Reserve(anchor.docPr.id);
}
}
List<CT_Inline> inlineList = ctDrawing.GetInlineList();
foreach (CT_Inline inline in inlineList)
{
if (inline.docPr != null)
{
GetDocument().GetDrawingIdManager().Reserve(inline.docPr.id);
}
}
}
//// Look for any text in any of our pictures or Drawings
StringBuilder text = new StringBuilder();
List<object> pictTextObjs = new List<object>();
foreach (NPOI.OpenXmlFormats.Wordprocessing.CT_Picture pic in r.GetPictList())
pictTextObjs.Add(pic);
foreach (NPOI.OpenXmlFormats.Wordprocessing.CT_Drawing draw in drawingList)
pictTextObjs.Add(draw);
foreach (object o in pictTextObjs)
{
//XmlObject[] t = o.SelectPath("declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' .//w:t");
//for (int m = 0; m < t.Length; m++)
//{
// NodeList kids = t[m].DomNode.ChildNodes;
// for (int n = 0; n < kids.Length; n++)
// {
// if (kids.Item(n) is Text)
// {
// if (text.Length > 0)
// text.Append("\n");
// text.Append(kids.Item(n).NodeValue);
// }
// }
//}
}
pictureText = text.ToString();
// Do we have any embedded pictures?
// (They're a different CT_Picture, under the Drawingml namespace)
pictures = new List<XWPFPicture>();
foreach (object o in pictTextObjs)
{
foreach (OpenXmlFormats.Dml.Picture.CT_Picture pict in GetCTPictures(o))
{
XWPFPicture picture = new XWPFPicture(pict, this);
pictures.Add(picture);
}
}
}
示例10: OnDocumentRead
/**
* Reads the document
* @throws IOException
*/
internal override void OnDocumentRead()
{
base.OnDocumentRead();
HdrDocument hdrDocument = null;
Stream is1;
try
{
is1 = GetPackagePart().GetInputStream();
hdrDocument = HdrDocument.Parse(is1);
headerFooter = hdrDocument.Hdr;
foreach (object o in headerFooter.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);
}
}
// parse the document with cursor and add
// the XmlObject to its lists
/*XmlCursor cursor = headerFooter.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();*/
}
catch (Exception e)
{
throw new POIXMLException(e);
}
}
示例11: OnDocumentRead
internal override void OnDocumentRead()
{
base.OnDocumentRead();
FtrDocument ftrDocument = null;
try {
XmlDocument xmldoc = ConvertStreamToXml(GetPackagePart().GetInputStream());
ftrDocument = FtrDocument.Parse(xmldoc, NamespaceManager);
headerFooter = ftrDocument.Ftr;
// parse the document with cursor and add
// the XmlObject to its lists
foreach (object o in headerFooter.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);
}
}
} catch (Exception e) {
throw new POIXMLException(e);
}
}
示例12: CreateParagraph
/**
* Appends a new paragraph to this document
* @return a new paragraph
*/
public XWPFParagraph CreateParagraph()
{
XWPFParagraph p = new XWPFParagraph(ctDocument.body.AddNewP(), this);
bodyElements.Add(p);
paragraphs.Add(p);
return p;
}
示例13: SetText
public void SetText(String text)
{
CT_P ctP = (ctTc.SizeOfPArray() == 0) ? ctTc.AddNewP() : ctTc.GetPArray(0);
XWPFParagraph par = new XWPFParagraph(ctP, this);
par.CreateRun().SetText(text);
}
示例14: AddParagraph
/**
* Add a Paragraph to this Table Cell
* @return The paragraph which was Added
*/
public XWPFParagraph AddParagraph()
{
XWPFParagraph p = new XWPFParagraph(ctTc.AddNewP(), this);
AddParagraph(p);
return p;
}
示例15: XWPFRun
public XWPFRun(CT_R r, XWPFParagraph p)
: this(r, (IRunBody)p)
{
}