ashutosh9910 Posted October 20, 2005 Posted October 20, 2005 Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment; filename=UserList.xls; sheet=Sheet2") Response.Charset = "" Me.EnableViewState = False Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter) dgSearchResult.RenderControl(oHtmlTextWriter) Response.Write(oStringWriter.ToString()) Response.End() The original code I got from this very firm and I modified it to the one above. Now the problem is with Paging Enabled, it only saves the excel file with the current page recods. Is there a way I could go about getting all the records in the excel file without them being displayed on the DataGrid Thanks Ashutosh Quote http://vyasashutosh.blogspot.com
bri189a Posted October 20, 2005 Posted October 20, 2005 Have a function that gets all records before performing your excel writing code. Quote
ashutosh9910 Posted October 21, 2005 Author Posted October 21, 2005 Have a function that gets all records before performing your excel writing code. Yes, but it is rendering data from the Data Grid and not from any data set, which shows only one page at a time. I am quite new to ASP.NET and to .NET for that matter. so plz excuse me if I am wrong Ashutosh Quote http://vyasashutosh.blogspot.com
kahlua001 Posted October 21, 2005 Posted October 21, 2005 Loop thru your dataset and build a tab delilimted string, then write it to your stream with the .xls file extension. I have never figured out how to write a xls from a datagrid without all the formatting junk that gets carried over from the html. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.