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 Apr 20, 2015 2:40 pm

We're using OpenXml Power Tools (available via nuget) to merge documents and document fragments together and Spire.Doc to manipulate them before and after they are merged. I'm running into problems if the documents have numbered or bulleted lists in them and it seems to be related to something Spire.Doc is doing to the documents.

Here is the code (simplified from here):

Code: Select all
        public void moo()
        {
            var filename = @"test.docx";
            var doc = new Document(filename);
            doc.SaveToFile("temp.docx", FileFormat.Docx);
            var wmlDoc = new WmlDocument("temp.docx");
            var source = new Source(wmlDoc);
            var newDoc = OpenXmlPowerTools.DocumentBuilder.BuildDocument(new List<Source> {source});
        }


Test.docx is attached (zipped). The error I see is "Sequence contains no elements". This code works fine if I create the WmlDocument directly from "test.docx" instead of "temp.docx". It also works if I remove the numbered list.

I'm going to run a comparison of test.docx and temp.docx to see what changes have been made by Spire.doc but wanted to see if anyone had some insight while I'm doing that.

kbaley
 
Posts: 6
Joined: Mon Apr 06, 2015 7:21 pm

Tue Apr 21, 2015 8:49 am

Hello,

Thanks for your inquiry. By investigation about OpenXml Power Tools source codes , the error is caused by the reason that there is no the element (w:nsid) in the numbering.xml file, this is because it is not essential according to the Specification, so Spire.Doc doesn't write the element.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Apr 21, 2015 12:42 pm

Thanks Gary. I'll dig into its source and figure it out.

kbaley
 
Posts: 6
Joined: Mon Apr 06, 2015 7:21 pm

Return to Spire.Doc