Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 2nd, 2007, 07:01 PM
Registered User
Join Date: Jan 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export Gridview to Excel and Hide column


I have a gridview in my asp.net 2.0 vb application and I export the whole table to Excel using a button. The first column of the gridview is an edit column. When I export it, it just shows up as text in the excel file. How do I remove this column so it doesn't get exported to Excel?


Reply With Quote
  #2 (permalink)  
Old November 3rd, 2011, 04:58 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

you can easily export DataGrid to Excel in your Excel ASP.NET application with this Excel C# component.

Here is a sample code (to change what columns to export just use another overload of InsertDataTable method):
DataTable people = (DataTable)Session["people"];
// Create excel file.
ExcelFile ef = new ExcelFile();
ExcelWorksheet ws = ef.Worksheets.Add("DataSheet");
ws.InsertDataTable(people, "A1", true);
// Stream file to browser, in required type.
switch (this.RadioButtonList1.SelectedValue)
    case "XLS":
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment; filename=" +
    case "XLSX":
        Response.ContentType = "application/vnd.openxmlformats";
        Response.AddHeader("Content-Disposition", "attachment; filename=" +
        // With XLSX it is a bit more complicated as MS Packaging API
        // can't write directly to Response.OutputStream.
        // Therefore we use temporary MemoryStream.
        MemoryStream ms = new MemoryStream();
Reply With Quote
  #3 (permalink)  
Old March 1st, 2012, 02:16 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help me out Plx

i am new user.. i have no programming background kindly help me out what should i do
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView - Hide column and retrieve value snufse ASP.NET 2.0 Basics 1 July 24th, 2008 03:22 PM
Export ALL records from GridView into Excel or CSV kevorkian ASP.NET 2.0 Basics 7 June 17th, 2008 01:28 PM
Export GridView data to Excel file rao965 ASP.NET 2.0 Professional 0 June 14th, 2007 10:18 AM
Adding to Export Of GridView to Excel rsearing ASP.NET 2.0 Professional 17 January 25th, 2007 02:41 AM

All times are GMT -4. The time now is 02:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.