XML to Word file using C# asp.Net RRS feed

  • Question

  • Hi

    I want to generate word file from the XML in a descriptive format.

    Till now i am just being able to create file with the data but there is no format or spaces.

                                        <Component>2219-NEW </Component>



    public bool GenerateWordFile(ref OceEntityLayer.VersionReleaseEntity objVersionRelEntity)
                DataSet ds;
                XmlDataDocument xmlDoc;
                XslCompiledTransform xslTran;
                XmlElement root;
                XPathNavigator nav;
                XmlTextWriter writer;
                    // objVersionReleaseBL.
                    //Convertion starts from here
                    XmlDocument XDoc = new XmlDocument();
                    //Create the DataSet from the XML file
                    ds = new DataSet();
                    //Create the XML from the DataSet
                    xmlDoc = new XmlDataDocument(ds);
                    //Load the XSLT for Transformation
                    xslTran = new XslCompiledTransform();
                    //Determine the Root object in the XML
                    root = xmlDoc.DocumentElement;
                    //Create the XPath Navigator to navigate throuth the XML
                    nav = root.CreateNavigator();
                    //First delete the RTF, if already exist
                    if (File.Exists("versionReleaseNote.rtf"))
                    //Create the RTF by Transforming the XML and XSLT
                    writer = new XmlTextWriter("versionReleaseNote.rtf", System.Text.Encoding.Default);
                    xslTran.Transform(nav, writer);
                    //Close the Writer after Transformation
                    //Release all objects
                    writer = null;
                    nav = null;
                    root = null;
                    xmlDoc = null;
                    ds = null;

                    // MessageBox.Show("Document created successfully.....");
                    // txtMessage.Text = "Document created successfully.....";

                catch (Exception ex)
                    writer = null;
                    nav = null;
                    root = null;
                    xmlDoc = null;
                    ds = null;
                    //txtMessage.Text = Convert.ToString(ex.Message);
                return true;

    • Moved by edhickey Tuesday, August 23, 2011 1:51 PM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    • Moved by Cindy Meister MVPModerator Tuesday, August 23, 2011 4:09 PM Open XML specific (From:Word for Developers)
    Tuesday, August 23, 2011 6:14 AM


All replies