public void CreateTOC() { TOC toc = new TOC(this.Document.body.AddNewSdt()); foreach (XWPFParagraph paragraph in this.paragraphs) { string style = paragraph.GetStyle(); if (style != null) { if (style.Substring(0, 7).Equals("Heading")) { try { int level = int.Parse(style.Substring("Heading".Length)); toc.AddRow(level, paragraph.GetText(), 1, "112723803"); } catch (FormatException ex) { Console.Write(ex.StackTrace); } } } } }
/** * */ public void CreateTOC() { CT_SdtBlock block = this.Document.body.AddNewSdt(); TOC toc = new TOC(block); foreach (XWPFParagraph par in paragraphs) { String parStyle = par.Style; if (parStyle != null && parStyle.Substring(0, 7).Equals("Heading")) { try { int level = Int32.Parse(parStyle.Substring("Heading".Length)); toc.AddRow(level, par.Text, 1, "112723803"); } catch (FormatException e) { Debug.Write(e.StackTrace); } } } }