Solved

ASP.Net export multiple gridview to one excel sheet

Posted on 2013-01-28
2
898 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
2 Comments
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 250 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 250 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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