Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Oct 17, 2022 8:16 am

Hi!

We have unfortunately encountered a problem when dynamically adding (one or more) Tables of Content.
We have a template docx (see attachment) where we want six different ToC's (in one page), based on chapter numbers that are created dynamically. After adding all chapters, we have tried two ways to add the ToC's:
- Use the built-in functions of Microsoft Word to differentiate between the ToC's and, when everything is added, call UpdateTableOfContents()
- Use code to add a new ToC and call UpdateTableOfContents(nameOfToc)

Both ways result in the same; in every place a ToC should be displayed, it shows "TOC", but they are all defined as proper ToC's, although only one (the first one) is already defined as a ToC in the template. This means that when the result file (see attachment) is opened in Word, and all ToC's are updated (f.e. via ctrl-a, F9), all ToC's are properly generated. So, the basis is there and is correct, but the ToC's simply are not generated.

Calling the UpdateTableOfContents methods twice, or calling the parameterless method after calling the other UpdateTableOfContents method does not help.

We are using version 10.9.6 (latest stable) of Spire.Doc.

Any help, but especially a fix, would be greatly appreciated!

Code snippet for adding ToC via Spire.Doc functionalities:
Code: Select all
private void AddTableOfContentsWithSwitch(Report report, string tocSwitch)
        {
            Document doc = (Document)report.Document;

            TableOfContent toc = new TableOfContent(doc, tocSwitch);
            report.AddBlankParagraph();
            Paragraph p = (Paragraph)report.CurrentParagraph;
            p.Items.Add(toc);
            p.AppendFieldMark(FieldMarkType.FieldSeparator);
            p.AppendText("TOC");
            p.AppendFieldMark(FieldMarkType.FieldEnd);

            doc.TOC = toc;
            doc.UpdateTableOfContents(toc);
        }


The tocSwitch contains f.e.
Code: Select all
"{\\t \"MW_NH_Header_B, 1\"}"

Demobv37d
 
Posts: 4
Joined: Mon Nov 22, 2021 2:10 pm

Mon Oct 17, 2022 10:17 am

Hi,

Thanks for your inquiry.
I reproduced your issue on my side and logged it into our bug tracking system with the ticket number SPIREDOC-8575. Once it is resolved or there is any update, I will inform you immediately. Apologize for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Thu Oct 27, 2022 9:38 am

Hi Nina,

Is there any kind of update you can provide me?

Thanks!

Demobv37d
 
Posts: 4
Joined: Mon Nov 22, 2021 2:10 pm

Thu Oct 27, 2022 10:10 am

Hi,

Sorry your issue is not resolved yet and our dev team is still investigating it due to its complexity. Please spare us more time, once there is any meaningful progress, I will let you know immediately.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1187
Joined: Tue Sep 27, 2016 1:06 am

Tue Nov 29, 2022 12:28 pm

Hi Nina,

It's been a month since the last reply, is there still no kind of update?
We can't roll out our product to our customers, and have had to postpone rolling out a few times, because of this...

Thanks in advance for your reply!

Demobv37d
 
Posts: 4
Joined: Mon Nov 22, 2021 2:10 pm

Fri Mar 10, 2023 9:41 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Doc Pack(hot fix) Version:11.3.1 which fixes the issue with SPIREDOC-8575.

Please download the new version from the following links to test.
Website download link: https://www.e-iceblue.com/Download/download-word-for-net-now.html
Nuget download link: https://www.nuget.org/packages/Spire.Doc/11.3.1


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc