C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Export DataSet to Word files in ASP.NET with C#


Posted Date: 06 Aug 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: Mexi Renjith MammanMember Level: Gold    
Rating: Points: 5



This code sample exprts data from a DataSet object to a Word file. The code consists of a eventhandler that handles a click event on a button.


protected void ibtnExport_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
DataSet dsMail = new DataSet();
dsMail = objNews.ExportMailDetails(Request.Form["chkNewsLetter"]);

StringBuilder sbContent = new StringBuilder();

for (int i = 0; i <= dsMail.Tables[0].Rows.Count - 1; i++)
{

for (int j = 0; j <= dsMail.Tables[0].Columns.Count - 1; j++)
{

sbContent .Append(" " + dsMail.Tables[0].Rows[i][j].ToString()+ " ");

}

sbContent .Append("\n");
}

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

Response.Charset = "";

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType = "application/vnd.word";
Response.Write(sbContent .ToString());

Response.End();

}







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Export data to word file with C#  .  Export Data to Word File  .  Export data from Dataset with C#  .  Export data from DataSet to Word file  .  ASP.net / C#  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to dynamically change meta tags when using MasterPage in ASP.NET and C#
Previous Resource: Uses of ltrim and rtrim
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use