Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Download

Download

Scheduled Pinned Locked Moved ASP.NET
questioncsshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ritwik Sanyal
    wrote on last edited by
    #1

    I am creating report using datagrid. There is a button for download outside the grid. Now when ever this download button will be clicked all the records in the datagrid will be saved in an excel file. How can I do that? Please help. Thanks in advance

    J 1 Reply Last reply
    0
    • R Ritwik Sanyal

      I am creating report using datagrid. There is a button for download outside the grid. Now when ever this download button will be clicked all the records in the datagrid will be saved in an excel file. How can I do that? Please help. Thanks in advance

      J Offline
      J Offline
      Jesse Squire
      wrote on last edited by
      #2

      There are a couple of ways to make this happen. The easiest way is to postback when the download button is clicked, set all but your datagrid to invisible, and change the content type (by setting Response.ContentType) to "application/vnd.ms-excel". If installed on the client machine, Excel will then open the HTML content and translate it. To be honest, I'm not sure what the behavior is when Excel is not present on the client machine. Below are a couple of quick Code Project articles that demonstrate this method.

      • Creating a formatted MS-Excel sheet using ASP[^]
      • Export to Excel[^]

      If that isn't adaquate for what you're looking to do, then you may wish to look into creating the Excel document on the server and redirecting to it. I'm by no means an expert in this area, so please take my advice with a grain of salt. Searching Code Project for "Excel" will yield several articles that offer a more informed and in-depth look at some of the below. There are various means to accomplish Excel document generation, such as using a 3rd party library, automating Excel, using an ODBC driver, or using Crystal Reports. In my opinion, you would be better off looking into a 3rd party solution, like XlsGen[^] then most of the others. Most of the others will require that all or part of Excel/MS Office be installed on the server :eek: in order to work. Hope that helps a bit. :) --Jesse

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups