Open XML SDK 2.0 weird issues
I was creating and modifying .docx Word files with the Open XML SDK and have got some strange behaviors.
One if them was that I wrote some code to open a blank document and added some Paragraphs with Bold fonts.
Then I opened it with Word and all was ok. I saw my created Paragraph on bold.
The problem was when I tried to open it on another computer. Word told me that the file was corrupted.
So I decided to open it with the Productivity Tool and validate the corrupted file and I got some info like this.
Error description:The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:rFonts'. Content type of part with error: application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml
Location Path.xpath:/w:document[1]/w:body[1]/w:p[6]/w:r[1]/w:rPr[1] |
The code I used was something like this:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
Bold bold1 = new Bold();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Trebuchet MS" };
Color color1 = new Color(){ Val = "000000" };
runProperties1.Append(bold1);
runProperties1.Append(runFonts1);
runProperties1.Append(color1);
return runProperties1;
}
And when I deleted the Bold , all worked fine.
Someday I’d like to know why this happens…
Perhaps it happens in this CTP version…
Labels: Open XML SDK
0 Comments:
Post a Comment
<< Home