473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

copy the selective html content & paste it in Excel 2007 programmatically (Vb.net)

I've a form where an webrowser contains a html file. I want to copy a selective portion of the html content and paste that content in an excel 2007 file where it will be pasted as a normal text (not in HTML code). I want to have the excel part should be as it is done manually (i.e. it should be in proper format as it is in the HTML file).

Platform/OS/Version : GUI/Windows XP/2005
Language :Vb.Net

Expand|Select|Wrap|Line Numbers
  1. Private Sub frmParse_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         WebBrowser1.Navigate(New Uri("http://sec.gov/Archives/edgar/data/1089951/000119312508074840/0001193125-08-074840-index.htm"))
  3. End Sub
  4.  
  5. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  6.         Dim sr As StreamReader = New StreamReader(WebBrowser1.DocumentStream)
  7.         Dim xlAppOut As Excel.Application
  8.         Dim xlBookOut As Excel.Workbook
  9.         Dim xlSheet1 As Excel.Worksheet
  10.         xlAppOut = CreateObject("Excel.Application")
  11.         xlBookOut = xlAppOut.Workbooks.Add
  12.         xlSheet1 = xlBookOut.Worksheets.Item(1)
  13.         xlAppOut.Visible = True
  14.         Clipboard.Clear()
  15.         Dim strContent As String = GetSelection(WebBrowser1)
  16.         Clipboard.SetText(strContent)
  17.         xlSheet1.Paste()
  18. End Sub
  19.  
  20. Private Function GetSelection(ByVal webBrowser As WebBrowser) As String
  21.         GetSelection = ""
  22.         Dim doc As IHTMLDocument2 = CType(webBrowser.Document.DomDocument, IHTMLDocument2)
  23.         Dim sel As IHTMLSelectionObject = doc.selection
  24.         Dim range As IHTMLTxtRange = CType(sel.createRange, IHTMLTxtRange)
  25.         GetSelection = range.htmlText
  26. End Function
  27.  
May 6 '08 #1
0 1558

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: bill | last post by:
Hi All, When I send html content with Excel MIME type, the page break style sheet {page-break-before: always} doesn't work at Excel spreadsheet. Any idea to convert html page break style sheet to...
5
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be...
0
by: arindams | last post by:
I'm getting problem in pasting HTML text in Excel 2007 whereas it is working fine in Excel 2003. The data pasted in excel 2007 is showing the the HTML code which is not desired. I need to have the...
9
by: AGP | last post by:
I have a VB6 application that has an OLE container with an embedded Excel chart. Our office updated to Excel 2007 and now although the app works the charts looks like crap. Since the app is fairly...
0
by: =?Utf-8?B?ZGlzcGxheW5hbWU=?= | last post by:
The following code used to outputs to Excel 2003 fine. Do I need to change it to output to Excel 2007? <% Response.ContentType = "application/vnd.ms-excel" Response.AddHeader...
2
by: deepadevid | last post by:
Hi, when I tried to copy a worksheet programmatically in Excel 2007 the chartObjects are not getting copied. I am getting empty charts inside my new worksheet. This is working in Excel 2003. ...
8
by: K Viltersten | last post by:
I understand that the new versions of MS Word, MS Excel etc. allow for creation of a document using XML tags (the technique or format is called OOXML, i think). I imagine that the idea behind...
4
by: rshin2020 | last post by:
How do I convert data/information from C#.net language to Excel 2007 spreadsheet to be displayed? I have no clear idea at all how this is going to take place. If the codes are given, how do i test...
0
by: Puffy | last post by:
Using C#, I need to copy the contents of one worksheet (Excel.Worksheet) to another worksheet. Everything gets copied (including pivot charts) when I execute the code for the 1st time. But when I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.