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. How to merge my content with a existing word document.

How to merge my content with a existing word document.

Scheduled Pinned Locked Moved C#
csharpdatabasetutorial
2 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.
  • E Offline
    E Offline
    Exelioindia
    wrote on last edited by
    #1

    Hi all, I have an scenario, I have to merge some dynamic content (to say data retrived from DB) in an existing word document without losing the existing content in that document. So that when ever there is a new conent, i use the same word document file and append my content. Please suggest me how to do this, else provide me some URL to learn and do using C#. Thanks in advance

    Know is Drop, Unknown is Ocean

    L 1 Reply Last reply
    0
    • E Exelioindia

      Hi all, I have an scenario, I have to merge some dynamic content (to say data retrived from DB) in an existing word document without losing the existing content in that document. So that when ever there is a new conent, i use the same word document file and append my content. Please suggest me how to do this, else provide me some URL to learn and do using C#. Thanks in advance

      Know is Drop, Unknown is Ocean

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Following code will help you..

      StringBuilder strBuilder = newStringBuilder();
      strBuilder.Append("<h1 title='Header' align='Center'>Writing To Word Using ASP.NET</h1> ".ToString());
      strBuilder.Append("<br>".ToString());
      strBuilder.Append("<table align='Center'>".ToString());
      strBuilder.Append("<tr>".ToString());
      strBuilder.Append("<td style='width:100px;color:green'><b>amiT</b></td>".ToString());
      strBuilder.Append("<td style='width:100px;color:red'>India</td>".ToString());
      strBuilder.Append("</tr>".ToString());
      strBuilder.Append("</table>".ToString());
      // string strPath = Request.PhysicalApplicationPath + "\\document\\Test.doc";
      string strPath = filename;
      //string strTextToWrite = TextBox1.Text;
      FileStream fStream = newFileStream (strPath,FileMode.Append);
      fStream.Close();
      StreamWriter sWriter = newStreamWriter(strPath);
      sWriter.Write(strBuilder);
      sWriter.Close();

      Find following links for more help... http://www.daniweb.com/forums/thread210396.html[^] http://devpinoy.org/blogs/keithrull/archive/2007/05/23/how-to-merge-multiple-microsoft-word-documents-in-c.aspx[^] http://csharpdotnetfreak.blogspot.com/2009/06/read-write-word-filestream-streamwriter.html[^] HTH

      Jinal Desai - LIVE Experience is mother of sage....

      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