Solved

ASP.Net export multiple gridview to one excel sheet

Posted on 2013-01-28
2
879 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now