本文整理汇总了C#中CT_Tbl类的典型用法代码示例。如果您正苦于以下问题:C# CT_Tbl类的具体用法?C# CT_Tbl怎么用?C# CT_Tbl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CT_Tbl类属于命名空间,在下文中一共展示了CT_Tbl类的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: 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.GetNumberOfRows());
Assert.IsNotNull(xtab.GetRow(2));
//add a new row
xtab.CreateRow();
Assert.AreEqual(4, xtab.GetNumberOfRows());
//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());
}
示例3: 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);
}
示例4: 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);
}
示例5: 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.Text);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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();
}
示例9: 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);
}
示例10: 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));
}
示例11: XWPFTable
public XWPFTable(CT_Tbl table, IBody part, int row, int col)
: this(table, part)
{
CT_TblGrid ctTblGrid = table.AddNewTblGrid();
for (int j = 0; j < col; j++)
{
CT_TblGridCol ctGridCol= ctTblGrid.AddNewGridCol();
ctGridCol.w = 300;
}
for (int i = 0; i < row; i++)
{
XWPFTableRow tabRow = (GetRow(i) == null) ? CreateRow() : GetRow(i);
for (int k = 0; k < col; k++)
{
if (tabRow.GetCell(k) == null)
{
tabRow.CreateCell();
}
}
}
}
示例12: TestSetGetWidth
public void TestSetGetWidth()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl table = new CT_Tbl();
table.AddNewTblPr().AddNewTblW().w = "1000";
XWPFTable xtab = new XWPFTable(table, doc);
Assert.AreEqual(1000, xtab.Width);
xtab.Width = 100;
Assert.AreEqual(100, int.Parse(table.tblPr.tblW.w));
}
示例13: GetTable
/**
* if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
* the method will return this table
* if there is no corresponding {@link XWPFTable} the method will return null
* @param ctTable
*/
public XWPFTable GetTable(CT_Tbl ctTable)
{
foreach (XWPFTable table in tables)
{
if (table == null)
return null;
if (table.GetCTTbl().Equals(ctTable))
return table;
}
return null;
}
示例14: TestSetGetRowBandSize
public void TestSetGetRowBandSize()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl ctTable = new CT_Tbl();
XWPFTable table = new XWPFTable(ctTable, doc);
table.SetRowBandSize(12);
int sz = table.GetRowBandSize();
Assert.AreEqual(12, sz);
}
示例15: TestSetGetColBandSize
public void TestSetGetColBandSize()
{
XWPFDocument doc = new XWPFDocument();
CT_Tbl ctTable = new CT_Tbl();
XWPFTable table = new XWPFTable(ctTable, doc);
table.ColBandSize = 16;
int sz = table.ColBandSize;
Assert.AreEqual(16, sz);
}