Export To Excel all rows RRS feed

  • Question

  • Hi friends I'm  showing only 25 rows at a time on the datagrid . But my query returns count that there is 2000 rows. So there is a button Export to Excel & on click it I want to populate all 2000 rows to an excel sheet at a time. I searched but all answers are only for Export to excel from datagrid. Hav any solution for my current situation. 

    Wednesday, August 10, 2011 8:12 AM

All replies

  • Just before exporting all the rows i believe there will be an event you can hook up to which contains the list of rows that it is being exported. Try manipulating that list  like do an addrange() or modify that list.

    Like reassign the list to the one with 2000 rows or just append it to that list. however you want to. I did this using telerik radgridview export feature.


    Wednesday, August 10, 2011 7:26 PM
  • Hi SilverKali

    If I assigns only 20-30 rows(less data) then it is working. But If i assigns more rows then the Remote Server Does Not Found error shows. I'm not understanding what is the problem. So is there ant fissible way to export all the rowsa at a time.

    Thursday, August 11, 2011 1:45 AM
  • remote server does not found in a exporting event?. Are you trying to pass it to a wcf service. if so increase the size of the data that can be transmitted.

    Thursday, August 11, 2011 1:08 PM
  • Now My Requirement is like below.

    When run the query it will retrive data from database & will fill the datagrid with paging. Let assume the query returns 5000 rows & in the datagrid I'm showing 50 records at a time. I want to  generate a excel file & export all 5000 rows at a time to it when the user clicks the Export Button. So how to do this in a most feasible way.

    Monday, August 22, 2011 10:14 AM
  • One approach would be to create the Export button as a Link button.  This could then open an ASP.NET .ashx handler page that calls your query and simply writes out the 5000 results to the response in CSV format.  If you then set the MIME type of the response to CSV the browser will prompt the user to save it or open in Excel (Assuming that file extension is mapped to Excel).

    Monday, August 22, 2011 10:27 AM
  • Hi Tregarick

    Thanks.Hav u any sample or link which will descibe me in details. Can u mail me the sample on jkumarsahoo@live.com

    Monday, August 22, 2011 10:33 AM
  • when you fire the exporting event, in it there will be a property of the source of data that its exporting. just assign your whole 5000 rows object to that source. it will take care of it.

    Monday, August 22, 2011 12:22 PM
  • Hi Rakun,

    This link show an example of creating and asp.net handler for serving up a CSV file http://www.publicidentity.ca/?p=5.  There are several other articles just google 'ashx handler CSV'.

    In your Silverlight app just add a normal Hyperlink button and set the URI to your handler using a relative path (Assuming your Silverlight app is hosted for the same place).  Remember to set the button to open up the link in a new window.

    Hope that helps.

    Monday, August 22, 2011 1:34 PM