We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LINQ Reporting Engine - Update ToC

Hi,
Using version 21.8 of the ‘aspose words for .NET’ and I’m having an issue with the ToC being incorrect on document creation.

I am using the reporting engine to generate the data then insert it into a document with an existing placeholder ToC.

However after the document is generated the ToC is wrong and I am forced to right click > update fields to get it to generate correctly.

I have tried adding in “doc.updatefields();” but this doesn’t seem to have any effect.

Is this functionality incompatible with the reporting engine? do you have any iseas on how I can resolve this issue?

Thanks

@josephallison,

Please upgrade to the latest (21.9) version of Aspose.Words for .NET and see how it goes on your end? In case the problem still remains, then please compress the following resources into ZIP format and attach the .zip file here for testing:

  • A simplified source Word document
  • Aspose.Words v21.9 generated DOCX file showing the undesired behavior
  • Please also create a standalone simplified Console Application (source code without compilation errors) that helps us to reproduce this problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will then start further investigation into your particular scenario and provide you more information.

Hi @awais.hafeez,

Thanks for getting back to me, I’m afraid I’m unable to update to the latest 21.9 version as our license expired recently so would only work with 21.8

Please find attached a document generated with 21.8 showing the issue, if you right click on the ToC and click update you can see the list changes, where as I am expecting it to be done automatically on generation.

.637678352286581691.docx (595.4 KB)

@josephallison,

Please call Document.UpdateFields Method before saving to disk in DOCX format.

Hi @awais.hafeez,
I am already doing that in the code and it doesn’t seem to make a difference, I have attached a code block below

ViewModel vm = getViewModel();    
ReportingEngine engine = new ReportingEngine();
engine.Options = ReportBuildOptions.AllowMissingMembers | ReportBuildOptions.RemoveEmptyParagraphs | ReportBuildOptions.InlineErrorMessages;
engine.BuildReport(doc, vm, "Model");
doc.UpdateFields();
doc.Save(response, fileName + ".docx", ContentDisposition.Attachment, null);

Could this be caused by the template itself? Is there a specific was to create/add ToCs?

@josephallison,

As requested earlier, please provide the following resources here for testing on our end:

  • A simplified source Word template document
  • Aspose.Words v21.9 generated DOCX file showing the undesired behavior
  • Please also create a standalone simplified Console Application (source code without compilation errors) that helps us to reproduce this problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.