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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Exporting DataGridView to excel

Exporting DataGridView to excel

Scheduled Pinned Locked Moved C#
csshelpquestion
5 Posts 3 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.
  • H Offline
    H Offline
    Hum Dum
    wrote on last edited by
    #1

    On application i am working there presents two gridview more like master-detail form. When user click on row in master grid, its details got displayed in second grid. Now i want to export these to excel. I can export both grid to different excel files, i.e one excel for master grid, and other for detail. But i want to export them in single file. Is there a way to achieve this? need help.

    R D 2 Replies Last reply
    0
    • H Hum Dum

      On application i am working there presents two gridview more like master-detail form. When user click on row in master grid, its details got displayed in second grid. Now i want to export these to excel. I can export both grid to different excel files, i.e one excel for master grid, and other for detail. But i want to export them in single file. Is there a way to achieve this? need help.

      R Offline
      R Offline
      Rashmi_Karnam
      wrote on last edited by
      #2

      Can I have code U r Using for Export to Excel?

      Rashmi.M.K

      1 Reply Last reply
      0
      • H Hum Dum

        On application i am working there presents two gridview more like master-detail form. When user click on row in master grid, its details got displayed in second grid. Now i want to export these to excel. I can export both grid to different excel files, i.e one excel for master grid, and other for detail. But i want to export them in single file. Is there a way to achieve this? need help.

        D Offline
        D Offline
        Dan Mos
        wrote on last edited by
        #3

        sure there is. Look at this article. It specifically for exporting datagridview(s) to excel. As for two datagrids on the same file I wouldexport one to sheet1 and the second to sheet2 or Mater and Details.

        H 1 Reply Last reply
        0
        • D Dan Mos

          sure there is. Look at this article. It specifically for exporting datagridview(s) to excel. As for two datagrids on the same file I wouldexport one to sheet1 and the second to sheet2 or Mater and Details.

          H Offline
          H Offline
          Hum Dum
          wrote on last edited by
          #4

          thanks for reply. exporting to excel is not an issue. also exporting them to separate files is ok. But my problem is how to correlate them as i do in my application. Hope you had seen master detail standard ex for notrhwind DB. Now whenever user click on particular order, its corresponding details displayed in 2nd grid. I also doing this, and exporting them also(but in 2 files). NO ISSUE. But how to correlate them in excel file. so that user can identify this detail belong to that order.

          D 1 Reply Last reply
          0
          • H Hum Dum

            thanks for reply. exporting to excel is not an issue. also exporting them to separate files is ok. But my problem is how to correlate them as i do in my application. Hope you had seen master detail standard ex for notrhwind DB. Now whenever user click on particular order, its corresponding details displayed in 2nd grid. I also doing this, and exporting them also(but in 2 files). NO ISSUE. But how to correlate them in excel file. so that user can identify this detail belong to that order.

            D Offline
            D Offline
            Dan Mos
            wrote on last edited by
            #5

            I would export them as I mentioned and then record a macro for some VLookUP or something (I don't know what you want exactly). An then adapt the macro to C# code so that the exported files/sheets are already linked. [Edit] Or simpler. I would create a template file that contains all the formulas(Excel or custom VBAs) and export the datas in that template. Now when the user enters a text in cell F5 for example the formulas will autocomplete the details for that text. Something like that. It's easier than creating formulas from C#. [/Edit]

            modified on Tuesday, March 2, 2010 8:35 AM

            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