Hello everyone,
I am facing a problem in creating a TOC(table of content) in word document which is created by script.
my word document have many sections(means pages). each page have one heading with few details of model or object.
I want to create index/Summary/TOC for this report with page number.
My current scenario is like this:
//for cover page
output.BeginSection(true,Constants.SECTION_COVER);
//some code here
output.EndSection();
for(int i=0;i<100;i++)
{
output.BeginSection(true,Constants.SECTION_DEFAULT);
//some code
output.EndSection();
for()
{
output.BeginSection(true,Constants.SECTION_DEFAULT);
//some code
output.EndSection();
}
}
So please suggest where and how we can create TOC(table of content).
I tried with below code in "Index section" but didn't got succeeded.
output.BeginSection(200, 200, 10, 10, 30, 30, 30, 30, false, Constants.SECTION_INDEX); output.SetAutoTOCNumbering(true); //Defines the style for the four levels in the TOC output.SetTOCFormat(0, "Arial", 20, Constants.C_BLACK, Constants.C_WHITE, Constants.FMT_LEFT | Constants.FMT_BOLD | Constants.FMT_ITALIC, 0, 0, 0, 0); output.SetTOCFormat(1, "Arial", 16, Constants.C_GREEN, Constants.C_WHITE, Constants.FMT_LEFT | Constants.FMT_BOLD, 5, 5, 2, 2); output.SetTOCFormat(2, "Arial", 12, Constants.C_RED, Constants.C_WHITE, Constants.FMT_LEFT | Constants.FMT_ITALIC, 10 , 5, 2, 2); output.SetTOCFormat(3, "Arial", 10, Constants.C_BLUE, Constants.C_WHITE, Constants.FMT_LEFT, 15, 5, 2, 2); //Output text output.OutputLn("Table_of_Contents", "Arial", 30, Constants.C_BLACK, Constants.C_WHITE, Constants.FMT_LEFT, 0); //Adds the table of content output.OutputField(Constants.FIELD_TOC, "Arial", 10, Constants.C_BLACK, Constants.C_WHITE, Constants.FMT_LEFT); output.EndSection();
please help and let me know if further details are required.
Thanks,
Ankit