Jump to content

Pasting HTML Table into Excel


Recommended Posts

I'm having trouble getting code that pastes an HTML table into Excel.

I can use the _ExcelWriteCell function to write to Excel but I can't figure out how to get the HTML table to paste into Excel.

I also tried putting the HTML table into the clipboard and pasting but that didn't work either.

Any ideas?

Here's what I have so far:

#include <IE.au3>
#include <Excel.au3>
#include <ClipBoard.au3>

$oIE = _IEAttach ("Bodybuilding.com")
$oExcel = _ExcelBookAttach("Data.xlsx", "FileName")
$oTable = _IEGetObjByName ($oIE, "label_outer_table")

;Correctly writes to cell
;_ExcelWriteCell($oExcel, "If you can read this, then Success!", 1, 1)

;Does not work
_ExcelWriteCell($oExcel, $otable, 1, 1)
Link to comment
Share on other sites

Take a look at:

_IETableWriteToArray() ;creates an array from an IE table

_ExcelWriteArray() ;writes an array into an excelsheet

That looks like it is what I need but I can't get it to work.

#include <IE.au3>
#include <Excel.au3>


$oIE = _IEAttach ("Bodybuilding.com")
$oExcel = _ExcelBookAttach("Data.xlsx", "FileName")
$oTable = _IEGetObjByName ($oIE, "label_outer_table")

;Correctly writes to cell
;_ExcelWriteCell($oExcel, "If you can read this, then Success!", 1, 1)

;Does not work
;_ExcelWriteCell($oExcel, $otable, 1, 1)
_ExcelWriteArray($oExcel, 1, 1, $oTable, 1 )

Nothing appears in Excel.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...