0

I can barely find stuff for npoi when I do its for poi and its lacking.

I found this for poi:

CTP ctP = p.getCTP();
CTSimpleField toc = ctP.addNewFldSimple();
toc.setInstr("TOC \\h");
toc.setDirty(STOnOff.TRUE);enter code here`enter code here`

And was able to "adapt" into this

 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;

(When I wrote Field not working, its 'cause i can't find the c# variation)

Also found

XWPFDocument doc = new XWPFDocument();
doc.CreateTOC();

But can't find how to set it up.

Might be simple but I'm still trying to learn and can't find proper documentation.(Also if you can help me add pagination would be awesome)

Thanks in advance :)

1 Answers1

0
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;
    }
edjoker
  • 157
  • 1
  • 14