Solved

ASP.Net export multiple gridview to one excel sheet

Posted on 2013-01-28
2
961 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

632 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