display data from database in ms.word?

asp.net , csharp , db Tirupati, India
  • 12 years ago
    Hi, my requriment is i want to display data from database in ms.word? Iam using asp.net with C# bcoz iam inserting resume in sqlserver, so i want to display that resume in word
  • 12 years ago

    I've done this myself.

    I'm hoping you know how to get data form your database. I'm not going to go into much detail here, I don't have the time.

    The trick to remember is that you have to control the output sent to the web browser form your code so it's not normal "text/html" but the msWord MIME type.

    To do this you have to set the contentType property of the HttpResponse object to "application/msword"

    Then you're going to also want to add a header that tells the browser what to do with it. In this case you use the .AddHeader method of the HttpResponse object to add the following header...

    [Visual Basic]
    Response.Addheader("content-disposition", "attachment; filename=mywordfilename.doc")

    Response.AddHeader("content-disposition", "attachment; filename=mywordfilename.doc");

    I'm sure if you search Google for "content-dispotion" and "application/msword" and "mime" you'll get good hits.

    Good luck.

  • 12 years ago

    Your links to MSDN are a nice touch CF, shall bear this in mind in future.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray