Free Support Forum - aspose.com

Headings are missing in Document map (or Navigation Panel)

Hi all,


I’m trying to export data to an word document. I have a main template to write down common data, beside that I also display a list of items based on another template, both template are using same style (as I clone the second one from the first). My code look like this:

private void ExportWorkItem(Document doc, WorkItemNode win) //doc is main document
{
WorkItem wi = win.WorkItem;

var workItemTemplate = _workItemTemplate.Clone(); // clone a item document from a template
DocumentBuilder builder = new DocumentBuilder(workItemTemplate);
// Write down data to item document
// Use heading 1 to write item title ()
// Do something else…
//…
///End write item data
// append item document to main document
foreach (Aspose.Words.Section section in workItemTemplate)
{
//Import section
Aspose.Words.Section newSection = (Aspose.Words.Section)doc.ImportNode(section, true, ImportFormatMode.KeepSourceFormatting);
//Append content of the src section to last section of dst document
doc.LastSection.AppendContent(newSection);
}
}

My problem is after append item document to main document, I expect headings I wrote in step () will show in document map (or navigation panel in MS Word 2010), but they don’t. The table of content is display correct, it contains all of them.
I’ve searched around but found no solution, any body know what I need to do?

Thanks so much for any help.
Dung


Hi Dung,

Please accept my apologies for late response.

Thanks for your inquiry. Could you please attach your input Word document along with item details (Use heading 1 to write item title (*)) here for testing? I will investigate the issue on my side and provide you more information.

Using the KeepSourceFormatting option allows to make sure the imported text looks in the destination document exactly like it was in the source document. If a matching style already exists in the destination document, the source style is copied and given a unique name by appending a suffix number to it, for example "Normal_0" or "Heading 1_5".

When using the UseDestinationStyles option, if a matching style already exists in the destination document, the style is not copied and the imported nodes are updated to reference the existing style.

Please read following documentation link for your kind reference.

http://www.aspose.com/docs/display/wordsnet/ImportFormatMode+Enumeration

Hi tahir,


Thanks for your reply, I just figure out the cause of my problem.

With “Use heading 1 to write item title(*)” I’ve replaced merge field (which is in heading 1 style) by item’s title. The merge field was put inside a table that’s why it didn’t show up in navigation.

Any way, I’m really appreciate your help, I’ve learn more with your information :slight_smile:

Thank you

Hi Dung,


Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.