Ask a Question

How to Export Html table from web application.

Udayreddy_90
Contributor

How to Export Html table from web application.

In my scenario, I want to export html Table data (of web application)  to Excel sheet.



( I can did this by getting Cell by Cell data from the table but it is time consuming so ........

   I need another method to export total data single time)
1 REPLY 1
HKosova
SmartBear Alumni (Retired)

Hi,



Excel has a built-in HTML table import feature, when you can paste the <table>...</table> HTML text into a worksheet, and Excel will automatically transform it into the corresponding table.



To automate this process, you could use a script like this:

Sub ExcelTableImport

  Dim strTableFruits, oExcel



  ' Copy the HTML source code of the table to the clipboard

  Browsers.Item(btIexplorer).Run "http://www.w3schools.com/html/html_tables.asp"

  strTableFruits = Sys.Browser.Page("http://www.w3schools.com/html/html_tables.asp").Panel(0).Panel(0).Panel(2).Panel(0).Panel(1).Table(0).outerHTML

  Sys.Clipboard = strTableFruits



  ' Create an Excel workbook, paste the HTML table into it and save the file

  Set oExcel = CreateObject("Excel.Application")

  oExcel.Visible = True

  oExcel.Workbooks.Add

  oExcel.ActiveSheet.Paste

  oExcel.ActiveWorkbook.SaveAs "E:\HTMLTable.xlsx"

  oExcel.Quit

End Sub

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: