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. General Programming
  3. C#
  4. Exporting html data to Excel [modified]

Exporting html data to Excel [modified]

Scheduled Pinned Locked Moved C#
csharphtmltutorialquestion
12 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.
  • B basi0014

    Guys, How do we copy a set of data from the web and paste it in Excel sheet, Programatically in C#? e.g. If i go to http://www.eurofound.europa.eu/eiro/2006/03/articles/no0603029i.htm[^] I want to copy this table 1 data and then paste it in Excel. In other words, does any one know how to parse the html data and save it in excel, Programatically in C#? Thanks for your expertise.

    modified on Tuesday, April 15, 2008 10:50 AM

    W Offline
    W Offline
    Waleed Eissa
    wrote on last edited by
    #2

    Copy and paste in notepad, then in notepad copy and paste in Excel ...

    Waleed Eissa Software Developer Sydney

    B 1 Reply Last reply
    0
    • W Waleed Eissa

      Copy and paste in notepad, then in notepad copy and paste in Excel ...

      Waleed Eissa Software Developer Sydney

      B Offline
      B Offline
      basi0014
      wrote on last edited by
      #3

      :) Thanks Waleed. I bet i did nt ask how to do that programatically in C# (assumed it to be understood.) So does any one know how to parse the html data and save it in excel, Programatically in C#?

      W 1 Reply Last reply
      0
      • B basi0014

        :) Thanks Waleed. I bet i did nt ask how to do that programatically in C# (assumed it to be understood.) So does any one know how to parse the html data and save it in excel, Programatically in C#?

        W Offline
        W Offline
        Waleed Eissa
        wrote on last edited by
        #4

        Well, you said copy and paste, you don't programmatically copy and paste, you import/export/parse .. etc .. this is why I was confused .. anyway, you have to parse the page (it's also called html scraping I believe) .. you can use mshtml to access the DOM of the page .. I have written a tool recently that does exactly this, read data from a table in an html page and save it to a table in a database but it only works with MySQL but I believe you could change the code easily, anyway, tell me if you want the code ... regards

        Waleed Eissa Software Developer Sydney

        B 1 Reply Last reply
        0
        • W Waleed Eissa

          Well, you said copy and paste, you don't programmatically copy and paste, you import/export/parse .. etc .. this is why I was confused .. anyway, you have to parse the page (it's also called html scraping I believe) .. you can use mshtml to access the DOM of the page .. I have written a tool recently that does exactly this, read data from a table in an html page and save it to a table in a database but it only works with MySQL but I believe you could change the code easily, anyway, tell me if you want the code ... regards

          Waleed Eissa Software Developer Sydney

          B Offline
          B Offline
          basi0014
          wrote on last edited by
          #5

          Thanks Waleed for helping out here. Now i know the right technical terms for what i want to acheive here :) If you can send me the code for your tool, i will really appreciate that man. ytb

          W 1 Reply Last reply
          0
          • B basi0014

            Thanks Waleed for helping out here. Now i know the right technical terms for what i want to acheive here :) If you can send me the code for your tool, i will really appreciate that man. ytb

            W Offline
            W Offline
            Waleed Eissa
            wrote on last edited by
            #6

            Sure, I uploaded the code to my website .. you may download it from http://www.waleedeissa.com/temp/HTM2MySQL.zip[^] BTW, you could just replace MySQL with OleDb and export to Excel using OleDb and this connection string: string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=YES;\"", excelFilePath) Just change HDR=YES to HDR=No if you don't have headers in your Excel sheet ...

            Waleed Eissa Software Developer Sydney

            modified on Wednesday, April 16, 2008 3:20 AM

            B 1 Reply Last reply
            0
            • W Waleed Eissa

              Sure, I uploaded the code to my website .. you may download it from http://www.waleedeissa.com/temp/HTM2MySQL.zip[^] BTW, you could just replace MySQL with OleDb and export to Excel using OleDb and this connection string: string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=YES;\"", excelFilePath) Just change HDR=YES to HDR=No if you don't have headers in your Excel sheet ...

              Waleed Eissa Software Developer Sydney

              modified on Wednesday, April 16, 2008 3:20 AM

              B Offline
              B Offline
              basi0014
              wrote on last edited by
              #7

              B Waleed, The link doesnt seem to be active. Can you kindly double check? Thanks

              W 1 Reply Last reply
              0
              • B basi0014

                B Waleed, The link doesnt seem to be active. Can you kindly double check? Thanks

                W Offline
                W Offline
                Waleed Eissa
                wrote on last edited by
                #8

                You're right, sorry, I fixed the link try it again... I also added a missing file, so if you already downloaded the file, then please download it again...

                Waleed Eissa Software Developer Sydney

                B 1 Reply Last reply
                0
                • B basi0014

                  Guys, How do we copy a set of data from the web and paste it in Excel sheet, Programatically in C#? e.g. If i go to http://www.eurofound.europa.eu/eiro/2006/03/articles/no0603029i.htm[^] I want to copy this table 1 data and then paste it in Excel. In other words, does any one know how to parse the html data and save it in excel, Programatically in C#? Thanks for your expertise.

                  modified on Tuesday, April 15, 2008 10:50 AM

                  S Offline
                  S Offline
                  sarvesh upadhyay
                  wrote on last edited by
                  #9

                  You can try this link http://www.codersource.net/csharp_screen_scraping.html[^]

                  Sarvesh Upadhyay Senior Software Engineer Birlasoft India Ltd. Microsoft Certified Professional Developer in Dotnet 2.0 Enterprise Application

                  1 Reply Last reply
                  0
                  • W Waleed Eissa

                    You're right, sorry, I fixed the link try it again... I also added a missing file, so if you already downloaded the file, then please download it again...

                    Waleed Eissa Software Developer Sydney

                    B Offline
                    B Offline
                    basi0014
                    wrote on last edited by
                    #10

                    Arite, I have written the problem scenario below. Can you help me with Step 2? How do i make my application launch the browser with username and password already entered in it? Sample Scenario: Step 1 - I want to launch a webpage (www.hotmail.com) using C# Application. Step 2 - I want my application to enter the username and password in the fields and then click the 'Sign In' button. Therefore when i launch this application, it takes me directly into the page where data is sitting (Emails) Here is the code that is working for Step 1 string url = "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1208358013&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(url); proc.StartInfo = startInfo; proc.Start();

                    W 2 Replies Last reply
                    0
                    • B basi0014

                      Arite, I have written the problem scenario below. Can you help me with Step 2? How do i make my application launch the browser with username and password already entered in it? Sample Scenario: Step 1 - I want to launch a webpage (www.hotmail.com) using C# Application. Step 2 - I want my application to enter the username and password in the fields and then click the 'Sign In' button. Therefore when i launch this application, it takes me directly into the page where data is sitting (Emails) Here is the code that is working for Step 1 string url = "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1208358013&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(url); proc.StartInfo = startInfo; proc.Start();

                      W Offline
                      W Offline
                      Waleed Eissa
                      wrote on last edited by
                      #11

                      Actually I never tried this before but I believe (not sure though) I saw an article here on codeproject.com that talks just about that , so, you could try searching the site .. I can tell you though that you don't need to do it in two steps, you can pass the username and password as a POST request but to do this in the browser this is what I'm not sure of, I'm almost sure it's possible but I don't have experience with that, so, I guess you need to do a little googling .. sorry man, wish I could help ...

                      Waleed Eissa Software Developer Sydney

                      1 Reply Last reply
                      0
                      • B basi0014

                        Arite, I have written the problem scenario below. Can you help me with Step 2? How do i make my application launch the browser with username and password already entered in it? Sample Scenario: Step 1 - I want to launch a webpage (www.hotmail.com) using C# Application. Step 2 - I want my application to enter the username and password in the fields and then click the 'Sign In' button. Therefore when i launch this application, it takes me directly into the page where data is sitting (Emails) Here is the code that is working for Step 1 string url = "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1208358013&rver=4.5.2130.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&id=64855"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(url); proc.StartInfo = startInfo; proc.Start();

                        W Offline
                        W Offline
                        Waleed Eissa
                        wrote on last edited by
                        #12

                        Well, just wanted to be sure that I understood correctly, are you talking about launching the default web browser e.g. IE or FireFox? (this is what I understood) or hosting a browser control in your application? ie. showing the page in your application .. it's much easier in the later case ...

                        Waleed Eissa Software Developer Sydney

                        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