how to open existing excel sheet and export data from DataGridView in c#

Posted by Bageshkumarbagi under C# on 7/25/2013 | Points: 10 | Views : 1721 | Status : [Member] | Replies : 1
Hi,

I want to open existing Excel sheet which has some macro and i want to export some data from datagridview and process the macro. can you please help me its urgent.

Thanks in Advance.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied



Responses

Posted by: Brahmam on: 7/25/2013 [Member] Starter | Points: 25

Up
0
Down
gvAssetTransaction.DataSource = Session["Export"] as DataTable;
gvAssetTransaction.DataBind();
string attachment = "attachment; filename=AssetTransaction.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);

gvAssetTransaction.AllowPaging = false;
gvAssetTransaction.DataSource = Session["Export"] as DataTable;
gvAssetTransaction.DataBind();
Form.RenderControl(htw);
Response.Write(sw.ToString());


above code check

brahmam

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response