GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DataGrid
Go To First  |  Previous Question  |  Next Question 
 DataGrid  |  Question 12 of 14    Print  
Export Data Grid content to Excel File
How to get the content of Datagrid into excel format?
I want to use this feature in Windows Application and C#, Visual Studio .NET 2003



  
Total Answers and Comments: 3 Last Update: February 25, 2008     Asked by: sekaranpg 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 26, 2007 13:11:10   #1  
Praveen        

RE: Export Data Grid content to Excel File

Response.Clear();

Response.Buffer true;

Response.ContentType "application/vnd.ms-excel";

Response.AddHeader("Content-Disposition" "attachment;filename ReviewDesignation.xls");//This
lets you always open the Excel window when exporting whether you click on open
or save.

Response.Charset "";

this.EnableViewState false;

System.IO.StringWriter oStringWriter new
System.IO.StringWriter();System.Web.UI.HtmlTextWriter oHtmlTextWriter

new System.Web.UI.HtmlTextWriter(oStringWriter);

this.ClearControls(dGrid);

dGrid.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());

Response.End();


 
Is this answer useful? Yes | No
October 27, 2007 08:29:03   #2  
sekaranpg Member Since: September 2005   Contribution: 6    

RE: Export Data Grid content to Excel File
I think this code is for web application. Is there any code for windows application
 
Is this answer useful? Yes | No
February 25, 2008 02:27:57   #3  
kundankum Member Since: February 2008   Contribution: 1    

RE: Export Data Grid content to Excel File
for windows application u use excel object to create excel file
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape