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. ASP.NET 2.0 C# with Excel

ASP.NET 2.0 C# with Excel

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabase
7 Posts 5 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.
  • W Offline
    W Offline
    wongeva
    wrote on last edited by
    #1

    hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG

    C B H 3 Replies Last reply
    0
    • W wongeva

      hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The server can do this. ASP.NET will not be involved in the process tho. It will be code that uses the Excel libraries, and will require excel on the server.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      W 1 Reply Last reply
      0
      • C Christian Graus

        The server can do this. ASP.NET will not be involved in the process tho. It will be code that uses the Excel libraries, and will require excel on the server.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        W Offline
        W Offline
        wongeva
        wrote on last edited by
        #3

        Hi, Christian Graus Can you send me the regarding code to me for refer..... THANKS From: eva

        C 1 Reply Last reply
        0
        • W wongeva

          hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG

          B Offline
          B Offline
          Binod K
          wrote on last edited by
          #4

          Hi, I didnt come across any such method ? But you can acieve it using this code. ----------------------------------------------------------------------- string s = "select * from person"; DataSet ds = GetDataSet(s); GridView1.DataSource = ds; GridView1.DataBind(); Response.ContentType = "application/ms-excel"; Response.AddHeader("Content- Disposition", "inline;filename=ExcelFile.xls"); ------------------------------------------------------------------------ I am not convince with Christian Graus answer. Excel is optional at Server. But it is required at Client Machine. If it is not installed at Client Machine, user cannot display the excel file, but he can download.

          A 1 Reply Last reply
          0
          • B Binod K

            Hi, I didnt come across any such method ? But you can acieve it using this code. ----------------------------------------------------------------------- string s = "select * from person"; DataSet ds = GetDataSet(s); GridView1.DataSource = ds; GridView1.DataBind(); Response.ContentType = "application/ms-excel"; Response.AddHeader("Content- Disposition", "inline;filename=ExcelFile.xls"); ------------------------------------------------------------------------ I am not convince with Christian Graus answer. Excel is optional at Server. But it is required at Client Machine. If it is not installed at Client Machine, user cannot display the excel file, but he can download.

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            The original post said " export it to Excel file(the function that set the width of each field is needed)" Christian is quite correct, to do this you need Excel installed on the server. What you are proposing is to display the data as Excel in a web page - not the same thing, but a viable work around as long as the fiel does not need writing to the server for some reason.

            Bob Ashfield Consultants Ltd

            1 Reply Last reply
            0
            • W wongeva

              Hi, Christian Graus Can you send me the regarding code to me for refer..... THANKS From: eva

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              When you download the Microsoft tools for Office, so you can do this, it will come with samples.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              1 Reply Last reply
              0
              • W wongeva

                hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG

                H Offline
                H Offline
                Henrik K Larsen
                wrote on last edited by
                #7

                Hi, There is an excellent article here on codeproject, that might help you... http://www.codeproject.com/KB/webforms/DAtaGridExportToExcel.aspx[^]


                Those who want most to speak up, are often those who have nothing clever to say.

                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