Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Dynamically generate a MS Word document using ASP.Net

Dynamically generate a MS Word document using ASP.Net

Scheduled Pinned Locked Moved C#
csharpasp-netquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john kuruvila
    wrote on last edited by
    #1

    How we can Dynamically generate a MS Word document using ASP.Net????? Jijo kuruvila software developer trivandrum

    H 1 Reply Last reply
    0
    • J john kuruvila

      How we can Dynamically generate a MS Word document using ASP.Net????? Jijo kuruvila software developer trivandrum

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If all you need to support was Word 2003, you can use the published Word 2003 XML Schema that you can download (as well as documentation) at http://www.microsoft.com/downloads/details.aspx?familyid=fe118952-3547-420a-a412-00a2662442d9&displaylang=en[^]. Generate XML through a variety of means (using the DOM with the System.Xml classes or using an XSLT using the System.Xml.Xsl classes) and - if you display the generated content in Internet Explorer and have Word 2003 installed - it should open up in Word. If you need to support downl-level versions, I suggest you use XHTML (XML with a default namespace to mimic HTML for older browsers) with the following processor instruction at the top:

      <?xml version="1.0">
      <?mso-application progid="Word.Document"?>

      This would be supported by Word 2000 and newer. If you want to support older clients yet and generate binary content, then you'll have to use automation (generating an RCW (runtime callable wrapper) from the Word typelib usign VS.NET->Add Reference->COM or tlbimp.exe), which isn't safe in a multi-threaded server application like ASP.NET. You'd be responsible for thread safety. If you must use that route, be sure to create an RCW (an "interop assembly") from the oldest typelib you want to support. Since Office components (and all COM servers should be written this way, though that's not always the case) are backwards compatible, they support older interfaces. You could even generate an RCW from a new typelib, but you must be sure not to use interfaces that are new to a version you might want to support. Because this would be on a server you would most likely control, however, you should get some control over what version is installed. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      J 1 Reply Last reply
      0
      • H Heath Stewart

        If all you need to support was Word 2003, you can use the published Word 2003 XML Schema that you can download (as well as documentation) at http://www.microsoft.com/downloads/details.aspx?familyid=fe118952-3547-420a-a412-00a2662442d9&displaylang=en[^]. Generate XML through a variety of means (using the DOM with the System.Xml classes or using an XSLT using the System.Xml.Xsl classes) and - if you display the generated content in Internet Explorer and have Word 2003 installed - it should open up in Word. If you need to support downl-level versions, I suggest you use XHTML (XML with a default namespace to mimic HTML for older browsers) with the following processor instruction at the top:

        <?xml version="1.0">
        <?mso-application progid="Word.Document"?>

        This would be supported by Word 2000 and newer. If you want to support older clients yet and generate binary content, then you'll have to use automation (generating an RCW (runtime callable wrapper) from the Word typelib usign VS.NET->Add Reference->COM or tlbimp.exe), which isn't safe in a multi-threaded server application like ASP.NET. You'd be responsible for thread safety. If you must use that route, be sure to create an RCW (an "interop assembly") from the oldest typelib you want to support. Since Office components (and all COM servers should be written this way, though that's not always the case) are backwards compatible, they support older interfaces. You could even generate an RCW from a new typelib, but you must be sure not to use interfaces that are new to a version you might want to support. Because this would be on a server you would most likely control, however, you should get some control over what version is installed. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

        J Offline
        J Offline
        john kuruvila
        wrote on last edited by
        #3

        Thanx a lot....:) Jijo kuruvila software developer trivandrum

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups