Community discussion forum

display data from database in ms.word?

  • 1 year 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
  • 1 year 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")

    [C#]
    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.

  • 1 year 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).

Want to stay in touch with what's going on? Follow us on twitter!