Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.Net export multiple gridview to one excel sheet

Posted on 2013-01-28
2
Medium Priority
?
983 Views
Last Modified: 2013-02-13
I have an ASP.Net page (C# code behind). The page had 4 gridviews on it, each showing records based on who is logged in. What I want to do is take the contents of each grid and export them to the same excel spreadsheet sheet. Is there a way to do this? Possibly tell it to export each grid to a different cell range? Thanks for any help.
0
Comment
Question by:dodgerfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 1000 total points
ID: 38829870
Hi

you can export each one to separate excel sheet or you can export all of them to one excel sheet

what you can do is to join all the data tables into one table

for example
 gridview1 datasource is dt1
 gridview2 datasource is dt2
 gridview3 datasource is dt3
 gridview4 datasource is dt4

in code behind create a new data table and add all the dt's to It

then export this dt to one excel sheet
Thanks
0
 
LVL 14

Accepted Solution

by:
binaryevo earned 1000 total points
ID: 38830740
I personally use the OpenXML standards for newer versions of Office ( Im pretty sure 2007+ work with OpenXML ).  You can either do one of two things with this approach, code it manually ( not recommended as it is very time consuming ) or you can simply utilize a wrapper.  The wrapper I use is called closed XML ( http://closedxml.codeplex.com ) and is very easy to implement.  The closed xml wrapper will handle all of your requirements and more... I typically add sorting functionality on exports and header formatting when it makes sense.  Take a look at the link there is a plethora of cool stuff you can do with this library.

Hope this helps
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question