本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFTable.GetRow方法的典型用法代码示例。如果您正苦于以下问题:C# XWPFTable.GetRow方法的具体用法?C# XWPFTable.GetRow怎么用?C# XWPFTable.GetRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.XWPF.UserModel.XWPFTable
的用法示例。
在下文中一共展示了XWPFTable.GetRow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例3: SetHeadings
private void SetHeadings(ref XWPFDocument doc, XWPFTable table)
{
XWPFParagraph p1 = doc.CreateParagraph();
XWPFRun r1 = p1.CreateRun();
r1.SetBold(true);
r1.SetText("Category");
r1.SetBold(true);
r1.SetFontFamily("Courier");
table.GetRow(0).GetCell(0).SetParagraph(p1);
XWPFParagraph p2 = doc.CreateParagraph();
XWPFRun r2 = p2.CreateRun();
r2.SetBold(true);
r2.SetText("Category");
r2.SetBold(true);
r2.SetFontFamily("Courier");
table.GetRow(0).GetCell(1).SetParagraph(p2);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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();
}
示例7: 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);
}
示例8: GetTable
/// <summary>
/// 获取节点中表的信息
/// </summary>
/// <param name="table">table</param>
private TableInfo GetTable(XWPFTable table)
{
try
{
TableInfo mTable = new TableInfo();
List<ColumnInfo> list = new List<ColumnInfo>();
List<PkKeyInfo> listPkKeyInfo = new List<PkKeyInfo>();
mTable.ListColumnInfo = list;
mTable.ListPkKeyInfo = listPkKeyInfo;
//表的ID
mTable.TableObjectID = Guid.NewGuid().ToString();
//表的中文名称
mTable.Name = table.GetRow(0).GetCell(1).GetText().Trim();
//表的英文名称
mTable.Code = table.GetRow(1).GetCell(1).GetText().Trim();
//表的描述
mTable.Comment = mTable.Name;
//标题列
var row = table.GetRow(3);
//缓存列索引和名称
Dictionary<int, string> dic = new Dictionary<int, string>();
int i = 0;
foreach (var cell in row.GetTableCells())
{
dic.Add(i, cell.GetText().Trim());
i++;
}
int iRow = 4;
row = table.GetRow(iRow);
while (row != null)
{
InitColumns(row, dic, mTable);
iRow = iRow + 1;
row = table.GetRow(iRow);
}
if (string.IsNullOrEmpty(mTable.Comment))
{
mTable.Comment = mTable.Name;
}
if (mTable.ListPkKeyInfo != null && mTable.ListPkKeyInfo.Count > 0)
{
foreach (PkKeyInfo pkInfo in mTable.ListPkKeyInfo)
{
mTable.PkKeyNameList = mTable.PkKeyNameList + pkInfo.Name + ",";
}
}
if (!string.IsNullOrEmpty(mTable.PkKeyNameList))
{
mTable.PkKeyNameList = mTable.PkKeyNameList.Substring(0, mTable.PkKeyNameList.Length - 1);
}
return mTable;
}
catch (Exception ex)
{
throw ex;
}
}