Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2006, 07:45 AM
Authorized User
 
Join Date: Jan 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default exporting to excel from datagrid

hello
i am dispalying certain records from sql into datagrid.now i hav provided checkboxes in datagrid to select item.
now i want to transfer those selected item into excel sheet.
(1)i don't want all the rows in datagrid to be transferred to exported to excel ,only those rows who are selected by checkbox shud go to excel sheet.
(2)and in my datagrid iam displaying only certain cloumns from the table in sql,but i want to export all the columns of the particular row which was selected in datagrid.

help me with solution in vb.net

 
Old June 1st, 2006, 04:13 AM
Authorized User
 
Join Date: Oct 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My suggestion is,
Create a dynamic Datagrid and populate it with the data from database based on your selection. Then export it to Excel on the fly as follows

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
this.ClearControls(datadrid);
datagrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();


Software proffesional from Bangalore,INDIA
 
Old June 9th, 2006, 08:53 AM
Registered User
 
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
For the Excel functionality, there is a .net component called Spire.DataExport,Totally independent and not affiliated with and free download. I have heard that it is quite good for generating Excel files.
see: http://www.e-iceblue.com






Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting data from datagrid to excel??? twyce C# 3 March 4th, 2010 04:51 AM
Problem in exporting data from datagrid to Excel deb_kareng ASP.NET 2.0 Professional 4 August 4th, 2007 09:21 AM
problem in exporting datagrid to excel swati_joshi ASP.NET 1.0 and 1.1 Professional 3 June 4th, 2006 11:26 PM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM
Exporting DataGrid To Excel chiefg C# 2 December 31st, 2003 12:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.