.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Write Data into a MS-Word Document

Posted By:Lakhan Pal Garg       Posted Date: June 30, 2010    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

This Code Will Write the Text "My Name is Lakhan Pal Garg.\r\nI am a Senior Software Engineer.\r\nAnd i am Working in a Product Based Company." into a doc file. A open/save dialog box will be visible at the end of the function. you can either directly open or can Save the doc file.

private void GenerateWordDoc()
        string strContent = "My Name is Lakhan Pal Garg.\r\nI am a Senior Software Engineer.\r\nAnd i am Working in a Product Based Company.";
        string attach = "attachment; filename=Lakhan.doc";
        HttpContext.Current.Response.Charset = "";

        HttpContext.Current.Response.ContentType = "application/msword";
        HttpContext.Current.Response.AddHeader("content-disposition", attach);


Lakhan Pal Garg


Further Readings:

Author: Peter         Company URL: http://www.dotnetspark.com
Posted Date: July 20, 2010

Easiest way to writing data to word using c#, I use it long time, name Spire.Doc, may help to you.

Author: Hannah         Company URL: http://www.dotnetspark.com
Posted Date: December 31, 2013

I am using Aspose.Words for .NET Library for managing my word documents including reading, writing, editing and converting my word docs to other formats. Try it, i hope it will help you solve your problem.


Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend