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.

Wed Dec 03, 2014 12:38 pm

Hi there,

we have a problem when loading and saving a DOCX file with heading styles in it. I have attached a sample (in the zip). The content is german, sorry.

When this docx is opened with MS Word, everything is fine, see attached screenshot Before.png. Please see the german heading styles "Überschrift 1" (=Heading 1), "Überschrift 2" (=Heading 2), and so on.

Now I load this docx file into Spire.Doc and save it again as a docx with Spire.Doc (no processing between at all):

WordDocument.LoadFromFile( Filename, FileFormat.Docx );
WordDocument.SaveToFile( Filename, FileFormat.Docx );


When I open the docx in MS Word again, all the heading styles have changed. The former styles have added "1" in their names (e.g. "Überschrift 1" is now "Überschrift 11") and there are new Heading styles now (with 1, 2, 3, etc.). Please see attached screenshot After.png.

You should be able to reproduce this with the attached sample docx file.

Why that? How to work around this? The styles shall not be modified at all when just loading and saving a docx file. Is this a bug or a feature?

Thanks and regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Thu Dec 04, 2014 2:19 am

Dear Felix,

Thanks for your inquiry.

I tested your document with Spire.Doc v5.3.4 and the result is the same as the original document, please try that:
http://www.e-iceblue.com/downloads/hot_ ... _5.3.4.zip

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Dec 04, 2014 8:38 am

Hi Burning,

we use version 5.3.4 as well. And we can reproduce this effect without any Problems again and again. With the most simple console app:

Code: Select all
using Spire.Doc;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main ( string[] args )
        {
            var WordDocument = new Document();
            WordDocument.LoadFromFile( @"C:\Daten\Die Arten des Humors.docx", FileFormat.Docx );
            WordDocument.SaveToFile( @"C:\Daten\Die Arten des Humors 2.docx", FileFormat.Docx );
        }
    }
}


The resulting file "Die Arten des Humors 2.docx" contains those modified styles (Standard1, Überschrift 11, Überschrift 22, etc.). And it is significantly larger than before (35 KB after save, 30 KB before).

With no doubt you should be able to reproduce this. If not, then I'll begin to believe in spirits... ;-)

I have attached both docx files (before and after this "conversion").

Please help, thanks.

Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Thu Dec 04, 2014 9:41 am

Dear Felix,

Please refer to the code below to see if it help:
Code: Select all
CultureInfo cc = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Document document = new Document();
document.LoadFromFile("Die Arten des Humors.docx", FileFormat.Docx);
document.SaveToFile("Result.docx", FileFormat.Docx);
Thread.CurrentThread.CurrentCulture = cc;
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Dec 04, 2014 10:02 am

Hi Burning,

same result as before. :-(

Code: Select all
using System.Globalization;
using System.Threading;
using Spire.Doc;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main ( string[] args )
        {
            var CurrentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var WordDocument = new Document();
            WordDocument.LoadFromFile( @"C:\Daten\Die Arten des Humors.docx", FileFormat.Docx );
            WordDocument.SaveToFile( @"C:\Daten\Die Arten des Humors 2.docx", FileFormat.Docx );

            Thread.CurrentThread.CurrentCulture = CurrentCulture;
        }
    }
}

The culture setting seems not to make a difference.

?????? Crazy...

Other ideas?

Regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Fri Dec 05, 2014 6:49 am

Dear Felix,

Actually, when I opened "Die Arten des Humors 2.docx" which you claimed it contained modified styles (Überschrift 11, etc.), just found out that there was no "modifed styles", see picture below:
01.png

Also, I tried to change "Regional Options" to "German" in Control Panel, then generated new document which had no modified styles in result, just bigger than the original.

And here are my system information, programming environment, office version, please send us your information to see if we can help.
-----WinXP SP3 32bit
-----VS2010
-----Office 2010
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Fri Dec 05, 2014 8:44 am

Okay, now I believe in spirits. Huuuhuuuuuu :roll:

My environmemt:

Office 2013 (32 Bit)
Visual Studio 2013
Windows 8.1 and 7 (64 Bit)

Fascinating, really.

I swear, this is exactly the same docx I have here with those "1"-Styles in it. No kidding.

So, what?

Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Fri Dec 05, 2014 9:34 am

Dear Felix,

We'll do some investigation and inform you next week.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Fri Dec 05, 2014 11:03 am

Hi Burning,

just another observation we made:

The source docx file is not generated by MS Word but by another thirdparty component: TXTextControl (http://www.textcontrol.com).

As soon as we re-save this source docx file with MS Word beforehand, everything is fine and Spire.Doc does not create those additional styles with the "1"-postfix.

Okay, now one could think that TXTextControl is the source of all those problems, right? BUT, as you told me: you can not reproduce this effect at all. The file Die Arten des Humors.docx you have (the source docx), is generated by TXTextControl. And you still get not the results we have, right?

So the question stays: why (or WHEN) is Spire.Doc producing those additional styles with the "1"-postfix? There must be a reason for that.

Hopefully you find the reason. Even a workaround would help. I keep my fingers crossed.

Thanks and regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Mon Dec 08, 2014 3:06 am

Dear Felix,

Sorry for the delay reply.

I tested "Die Arten des Humors.docx" with Visual Studio 2013 in Windows 7 x64 system on the weekend, the result document displayed correctly, there is no additional style.

I mentioned that you used "TXTextControl" to generate the document. Since you buy Spire.Doc, I recommend you to use Spire.Doc to generate the document and avoid similar problem.

PS: I noticed that you mentioned "As soon as we re-save this source docx file with MS Word beforehand", have you opened and saved the source file after generated by "TXTextControl"? If so, the document might have been modified, thus we cannot reproduce this issue.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Mon Dec 08, 2014 7:33 am

Hi Burning,

the hints concerning TXTextControl and MS Word are just hints to give you some context informations.

But the ultimate cause still exists: here I have a DOCX file (Die Arten des Humors.docx) where Spire.Doc adds those "1"-Styles when saving. I can reproduce this on multiple machines under Windows XP, 7 and 8.1. Even our customers can reproduce this. And you can not reproduce this with the exactly same file, the same Spire.Doc version and the same OS!! WHY THAT?

What's the reason for this? What is so fundamentally different here?

Please can you investigate what COULD CAUSE those additional styles (Stanard1, Überschrift 11, etc.)when saving doc/docx files?

Thanks and regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Mon Dec 08, 2014 9:52 am

Dear Felix,

After installing the German Language Pack of Microsoft Office, I can see those additional styles in the generated document.
We'll do some investigation and let you as soon as possible.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Dec 10, 2014 9:06 am

Dear Felix,

I got news from our dev team that they have confirmed this issue and are working to fix it.
We will inform you if there is any update.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Dec 10, 2014 9:21 am

Great, thank you!

Regards
Felix

felix.brueckner@normfall.de
 
Posts: 10
Joined: Fri May 16, 2014 8:58 pm

Fri Dec 12, 2014 8:03 am

Dear Felix,

I got news from our dev team that they have fixed this issue and are going to test it, we will inform you if there is any update.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc