Jump to content
Sign in to follow this  
ice1000

Pasting HTML Table into Excel

Recommended Posts

ice1000

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)

Share this post


Link to post
Share on other sites
Tvern

Take a look at:

_IETableWriteToArray() ;creates an array from an IE table

_ExcelWriteArray() ;writes an array into an excelsheet

Share this post


Link to post
Share on other sites
ice1000

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.

Share this post


Link to post
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
Sign in to follow this  

×