本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFTable类的典型用法代码示例。如果您正苦于以下问题:C# XWPFTable类的具体用法?C# XWPFTable怎么用?C# XWPFTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XWPFTable类属于NPOI.XWPF.UserModel命名空间,在下文中一共展示了XWPFTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSetGetVertAlignment
public void TestSetGetVertAlignment()
{
// instantiate the following classes so they'll Get picked up by
// the XmlBean process and Added to the jar file. they are required
// for the following XWPFTableCell methods.
CT_Shd ctShd = new CT_Shd();
Assert.IsNotNull(ctShd);
CT_VerticalJc ctVjc = new CT_VerticalJc();
Assert.IsNotNull(ctVjc);
ST_Shd stShd = ST_Shd.nil;
Assert.IsNotNull(stShd);
ST_VerticalJc stVjc = ST_VerticalJc.top;
Assert.IsNotNull(stVjc);
// 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.SetVerticalAlignment(XWPFTableCell.XWPFVertAlign.BOTH);
XWPFTableCell.XWPFVertAlign al = cell.GetVerticalAlignment();
Assert.AreEqual(XWPFTableCell.XWPFVertAlign.BOTH, al);
}
示例2: 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);
}
}
}
示例3: Row2Cell1Contains
private bool Row2Cell1Contains(XWPFTable table, string value)
{
try
{
System.Diagnostics.Debug.WriteLine(string.Format("Rows: {0}", table.Rows.Count));
if (table.Rows.Count > 2)
{
XWPFTableCell cel = table.Rows[2].GetCell(1);
{
string celtext = CellText.GetCellText(cel);
//System.Diagnostics.Debug.WriteLine(string.Format("Row: 2, Cell: 1 - {0} ", celtext));
if (celtext.StartsWith(value))
return true;
}
}
else
{
return false;
}
}
catch (System.NullReferenceException nullex)
{
string message = nullex.Message;
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
return false;
}
示例4: TestCreateRow
public void TestCreateRow()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl table = new CT_Tbl();
CT_Row r1 = table.AddNewTr();
r1.AddNewTc().AddNewP();
r1.AddNewTc().AddNewP();
CT_Row r2 = table.AddNewTr();
r2.AddNewTc().AddNewP();
r2.AddNewTc().AddNewP();
CT_Row r3 = table.AddNewTr();
r3.AddNewTc().AddNewP();
r3.AddNewTc().AddNewP();
XWPFTable xtab = new XWPFTable(table, doc);
Assert.AreEqual(3, xtab.NumberOfRows);
Assert.IsNotNull(xtab.GetRow(2));
//add a new row
xtab.CreateRow();
Assert.AreEqual(4, xtab.NumberOfRows);
//check number of cols
Assert.AreEqual(2, table.GetTrArray(0).SizeOfTcArray());
//check creation of first row
xtab = new XWPFTable(new CT_Tbl(), doc);
Assert.AreEqual(1, xtab.GetCTTbl().GetTrArray(0).SizeOfTcArray());
}
示例5: 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);
}
}
}
示例6: SecondRowFirstCellContainsInnoc
private bool SecondRowFirstCellContainsInnoc(XWPFTable table)
{
XWPFTableCell cel = table.Rows[1].GetCell(0);
{
string celtext = CellText.GetCellText(cel);
if (celtext.StartsWith("Inoc"))
return true;
}
return false;
}
示例7: FirstRowContainsGc
private bool FirstRowContainsGc(XWPFTable table)
{
List<XWPFTableCell> cells = table.Rows[0].GetTableCells();
foreach (XWPFTableCell cel in cells)
{
string celtext = CellText.GetCellText(cel);
if (celtext.StartsWith("GC"))
return true;
}
return false;
}
示例8: TestTblGrid
public void TestTblGrid()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl ctTable = new CT_Tbl();
CT_TblGrid cttblgrid = ctTable.AddNewTblGrid();
cttblgrid.AddNewGridCol().w = 123;
cttblgrid.AddNewGridCol().w = 321;
XWPFTable xtab = new XWPFTable(ctTable, doc);
Assert.AreEqual(123, xtab.GetCTTbl().tblGrid.gridCol[0].w);
Assert.AreEqual(321, xtab.GetCTTbl().tblGrid.gridCol[1].w);
}
示例9: TestGetText
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());
}
示例10: TestSetGetCantSplitRow
public void TestSetGetCantSplitRow()
{
// 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);
tr.IsCantSplitRow = true;
bool isCant = tr.IsCantSplitRow;
//assert(isCant);
Assert.IsTrue(isCant);
}
示例11: TestSetGetRepeatHeader
public void TestSetGetRepeatHeader()
{
// 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);
tr.SetRepeatHeader(true);
bool isRpt = tr.IsRepeatHeader();
//assert(isRpt);
Assert.IsTrue(isRpt);
}
示例12: TestSetGetColor
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);
}
示例13: Test54099
public void Test54099()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl ctTable = new CT_Tbl();
XWPFTable table = new XWPFTable(ctTable, doc);
XWPFTableRow tr = table.GetRow(0);
XWPFTableCell cell = tr.GetCell(0);
CT_Tc ctTc = cell.GetCTTc();
CT_TcPr tcPr = ctTc.AddNewTcPr();
CT_HMerge hMerge = tcPr.AddNewHMerge();
hMerge.val = (ST_Merge.restart);
CT_TcBorders tblBorders = tcPr.AddNewTcBorders();
CT_VMerge vMerge = tcPr.AddNewVMerge();
}
示例14: TestConstructor
public void TestConstructor()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl ctTable = new CT_Tbl();
XWPFTable xtab = new XWPFTable(ctTable, doc);
Assert.IsNotNull(xtab);
Assert.AreEqual(1, ctTable.SizeOfTrArray());
Assert.AreEqual(1, ctTable.GetTrArray(0).SizeOfTcArray());
Assert.IsNotNull(ctTable.GetTrArray(0).GetTcArray(0).GetPArray(0));
ctTable = new CT_Tbl();
xtab = new XWPFTable(ctTable, doc, 3, 2);
Assert.IsNotNull(xtab);
Assert.AreEqual(3, ctTable.SizeOfTrArray());
Assert.AreEqual(2, ctTable.GetTrArray(0).SizeOfTcArray());
Assert.IsNotNull(ctTable.GetTrArray(0).GetTcArray(0).GetPArray(0));
}
示例15: 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();*/
}