[英]How to create a table of contents using NPOI?
当我为 poi 做它时,我几乎找不到 npoi 的东西和它的缺乏。
我为 poi 找到了这个:
CTP ctP = p.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(STOnOff.TRUE);enter code here`enter code here`
并且能够“适应”这个
XWPFParagraph p=doc.CreateParagraph();
CT_P ctP = p.GetCTP();
CT_SimpleField toc = ctP.***Field not working***;
toc.instr="TOC \\h";
toc.dirty=ST_OnOff.True;
(当我写 Field not working 时,是因为我找不到 c# 变体)
还发现
XWPFDocument doc = new XWPFDocument();
doc.CreateTOC();
但是找不到如何设置它。
可能很简单,但我仍在努力学习,找不到合适的文档。(另外,如果你能帮我添加分页就太好了)
提前致谢:)
private static XWPFTable createXTable(XWPFDocument myDoc, DataTable dtSource)
{
int rowCount = dtSource.Rows.Count;
int columnCount = dtSource.Columns.Count;
CT_Tbl table = new CT_Tbl();
XWPFTable xTable = new XWPFTable(table, myDoc, rowCount, columnCount);
xTable.Width = 5000;
for (int i = 0; i < rowCount; i++)
{
for (int j = 0; j < columnCount; j++)
{
xTable.GetRow(i).GetCell(j).SetParagraph(SetCellText(xTable, dtSource.Rows[i][j].ToString()));
}
}
return xTable;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.