Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Save an Excel file, created from a DataGrid, programmatically..

Reply
Thread Tools

Save an Excel file, created from a DataGrid, programmatically..

 
 
tapasmahata tapasmahata is offline
Junior Member
Join Date: Jan 2008
Location: Kolkata
Posts: 7
 
      01-12-2008
Hi,

I need to Save my Excel File which I created from a DataGrid to my Hard Drive(C:\) using the C#.NET codes. It can be saved by the dialog box but I don't need that....I need the prior..

SomeOne Please Help Me....

Thanks

Tapas Mahata

Code Sample :

public void ExportToSpreadsheet(DataGrid dg, string name)
{

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=" + name);
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
dg.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();


}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aspnet.mdf file still is created even though i created a custom provider? Sunfire ASP .Net 1 11-10-2007 04:30 AM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
OleDbDataAdapter created in code behaves differently from one created by wizard. tom c ASP .Net 6 09-06-2006 04:46 PM
are the objects created in the stack guarranted to have been created? jimjim C++ 12 06-03-2005 12:57 PM
schemalocation entry in XML created by castor created sources? Ulf Heyder XML 0 10-16-2003 02:14 PM



Advertisments