I think that the problem here is that you send an xml content and tell that it's a file with .docx extension. In fact, docx is more than just xml and that's the reason why you get xml structure instead of document.
You can try to play with MIME type and set instead of application/msword one of the following values
In general, OpenXML can create real docx using WordprocessingDocument.Create(), so if you will not find any solution with xml, try to change the way you create documents.
None
0 Points
11 Posts
How to generate docx
Oct 29, 2013 08:40 AM|Preethi.Xavier|LINK
We are generating a document using a Word 2010 XML template via VB.Net code with out using word objects.(Using Office Open XMl)
We are getting unwanted tags when we open the Word 2010 XML Template in MS Word 2003.
Please suggest how to generate document compatible for MS Word 2003 & above.
The Below code is Currently used in generating the document.
We have given the MIME Type as
Response.ContentType = "application/msword"
And pushed the below content into Response using "Binary write".
--- Sample XML template
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"><pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" .............................. etc
We have Users using different version of office.
User Y has Word 2010 , and when he generates the document from the URL, it opens successfully.
User X has Word 2003 & Compatibility Pack Office 2007 installed , when he opens the document he gets unwanted tags as shown below.
All-Star
35149 Points
9075 Posts
Re: How to generate docx
Oct 29, 2013 09:48 AM|smirnov|LINK
None
0 Points
11 Posts
Re: How to generate docx
Oct 30, 2013 05:37 AM|Preethi.Xavier|LINK
1. I dont save but using Response i push the xml content into a temp doc with .docx extension.
2. Yes ,I can open a Word 2010 , saved as .docx in Word 2003 machine.
but a Word 2010 Xml document, saved as .xml when opened in word 2003 machine i get unwanted tags.
All-Star
35149 Points
9075 Posts
Re: How to generate docx
Oct 30, 2013 06:05 AM|smirnov|LINK
I think that the problem here is that you send an xml content and tell that it's a file with .docx extension. In fact, docx is more than just xml and that's the reason why you get xml structure instead of document.
You can try to play with MIME type and set instead of application/msword one of the following values
application/vnd.ms-word.document.12
application/vnd.openxmlformats-officedocument.wordprocessingml.document
or
text/xml
In case of Response.ContentType="text/xml" you might tell that extension is ".xml" and not ".docx"
Additionally, check an article here at http://msdn.microsoft.com/en-us/magazine/cc164064.aspx regarding xml docs.
Let me know if it helps.
In general, OpenXML can create real docx using WordprocessingDocument.Create(), so if you will not find any solution with xml, try to change the way you create documents.
None
0 Points
11 Posts
Re: How to generate docx
Nov 01, 2013 08:17 AM|Preethi.Xavier|LINK
When i tried to generate .docx, I used the below MIME type
application/vnd.ms-word.document.12
application/vnd.openxmlformats-officedocument.wordprocessingml.document
even then i get unwanted tags when opened in 2003 and unable to open in 2010 it throws error
i have XML file in flat opc format.. i want to convert it into .docx format.
All-Star
35149 Points
9075 Posts
Re: How to generate docx
Nov 02, 2013 05:49 PM|smirnov|LINK
Use WordprocessingDocument.Create() and similar methods.
Read more here http://msdn.microsoft.com/en-us/library/office/ff478190.aspx