wordpress hit counter
Re: creating WordML document using OpenXml - WordprocessingML - Formats - OpenXML Developer

Re: creating WordML document using OpenXml

Formats

Discussions about working with different Open XML Formats

creating WordML document using OpenXml

  • rated by 0 users
  • This post has 6 Replies |
  • 0 Followers
  • Can anyone tell me how to create WordML document using OpenXml SDK(c#.net)?


  • i tried with my code.But during the file creation its writing some junk values in the file.i m using Microsoft Windows Professional version 2002 service pack 2.What would be the solution for this problem?
  • Mano. Could you provide a bit more detail please? A little confused by the version numbers you gave. Can you please advise 1. Which version of the Open XML Format SDK you are using 2. Which version of .NET you are attempting to use 3. Which version of Microsoft Office (or any other client) you are trying to open the file in. If you feel comfortable please also feel free to post some code showing your issue. Thanks Chris
  • thank u for responding  Chris.I have given below the details u need
    1.OpenXml SDK version 2.0
    2..Net framework3.5
    3.Microsoft office 2003
    code:
    public static void CreateWordMLDocument(string docName)

            {
                // Create a Wordprocessing document.
               using (WordprocessingDocument package = WordprocessingDocument.Create(docName, DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
               {
                    // Add a new main document part.
                    package.AddMainDocumentPart();
                    // Create the Document DOM.
                    package.MainDocumentPart.Document =
                        new Document(
                            new Body(
                                new Paragraph(
                                    new Run(
                                        new Text("Hello World!")))));
                    // Save changes to the main document part.
                    package.MainDocumentPart.Document.Save();
                   }
                }
            static void Main(string[] args)
            {
                CreateWordMLDocument("Mydoc.xml");

            }

    this is the output i m getting ....
    Mydoc.xml:

    PK    jnG:žF%Õþ   Ç     word/document.xml ¢ (                      í½`I–%&/mÊ{JõJ×àt¡€`$ؐ@ìÁˆÍæ’ìiG#)«*ÊeVe]f@Ì흼÷Þ{ï½÷Þ{ï½÷º;N'÷ßÿ?\fdlöÎJÚÉž!€ªÈ?~|?"þÇ¿÷|ü{¼[”ée^7Eµüì£ÝñÎGi¾œV³byñÙGëö|ûà£ßãèñÕ£Y5]/òe›Rûeóè곏æm»zt÷n3ç‹¬W«|IߝWõ"kéÏúâîUUÏVu5Í›†À-Ê»{;;ŸÞ]dÅò#€œT³kü\áŸÿ´GßÎ˲J¿[Õåìw}|Ÿàßšÿ]ñ¿òÖ]‡ÑÑÿPK
         jnG:7šö›*  *   _rels/.rels ¢ (                      <?xml version="1.0" encoding="utf-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/word/document.xml" Id="R1aa4a88f31c14a97" /></Relationships>PK
         jnG:ßWZ  Z    [Content_Types].xml ¢ (                      <?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" /><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /></Types>PK-     jnG:žF%Õþ   Ç                    word/document.xmlPK-
         jnG:7šö›*  *               I  _rels/.relsPK-
         jnG:ßWZ  Z               ¸  [Content_Types].xmlPK      ¹   _   
  • hi..Chris..
    I downloaded the compatibility pack for office 2007 and specified the file format in docx extension.So i got the desired output now.
    Now my doubt is..will i be able create a wordML document supporting Office 2003 using OpenXmlSDK2.0?
  • Hi Mano,

    Word 2003 does not support Open XML File Format.

    you may refer to this for more info.

  • Hi mano,

    you could use the software solution TDIWiz (www.tdiwiz.com) to accomplish your task. It enables to create Word documents programmatically (2003 format as well as 2007) without own programming.

Page 1 of 1 (7 items)