Sign in to follow this  
Followers 0
litlmike

Using Ie.au3 With Excelcom.au3 Question

5 posts in this topic

I want to take a table from a webpage, and write it into Excel.

For this purpose let's use this webpage:

http://pda.hko.gov.hk/wxreporte.htm, and take the table from there into Excel.

I can get the first column to work, but not the second.

Below that is the code I am using.

Thanks in advance.

#include <IE.au3>; Include the UDF
#include <ExcelCom.au3>

; Create an IE Browser

$oIE = _IECreate()

; Navigate to your URL
_IENavigate($oIE, "http://pda.hko.gov.hk/wxreporte.htm")

; Get a reference to the Second table on the webpage (where the detail is stored)
;    note that object indexes are 0-based, so the second table is index 1
;
$oTable2 = _IETableGetObjByIndex($oIE, 1)

; Read the table cells into a 2-D array
;
$aWeather = _IETableWriteToArray($oTable2)

; Write the array contents out to an .xls
$FilePath = @ScriptDir & "\Test.xls"
_XLCreateBlank($FilePath)


;Confuse myself
;$rows = UBound($aWeather)
;$cols = UBound($aWeather, 2)
;$dims = UBound($aWeather, 0)

$rows_num = 1
For $i = 0 to Ubound($aWeather, 2) - 1
    _XLWrite($FilePath, 1, "A", $rows_num, $aWeather[0][$i], "Visible")
    $rows_num = $rows_num + 1
Next

$cols_num = 1
For $i = 0 to Ubound($aWeather, 2) - 1
    _XLWrite($FilePath, 1, "A", $cols_num, $aWeather[0][$i], "Visible")
    $cols_num = $cols_num + 1
Next

;~ For $i = 0 to Ubound($aWeather, 2) - 1
;~   _XLWrite($FilePath, 1, "A", $dims, $aWeather[0][$i], "Visible")
;~ Next

Share this post


Link to post
Share on other sites



Have you examined the contents of the array to see if your trouble is with the capture of the data into the array or the writing of the array contents to Excel?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Have you examined the contents of the array to see if your trouble is with the capture of the data into the array or the writing of the array contents to Excel?

Dale

Hi Dale. Actually no, I just assumed the capture of the data into the array was correct, since I just took this from your example in IE.au3. Hehe. I assumed the problem was with writing to Excel.

I tried running the example you have in IE.au3 for _IETableWriteToArray(), but it doesn't seem to ConsoleWrite (whatever that is), and so I really don't know how to test that the data. In that, I am not sure how _IETableWriteToArray() actually captures the data. In that, is it 2-dimensional? I remember in IE.au3 it said:

_IETableWriteToArray()

Reads the contents of a table into an array.

Note: Currently, if any of the cells span more than one column, the column offsets will be incorrect

I don't expect anyone to do the work for me, but can you give me some more direction? Thanks!

Share this post


Link to post
Share on other sites

_IETableWriteToArray() writes all rows and columns into a 2-D array.

ConsoleWrite works well if you are using SciTe as your text editor (highly recommended by the way -- see the downloads page). It writes messages to a special resizable window at the bottom of the editor.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

_IETableWriteToArray() writes all rows and columns into a 2-D array.

ConsoleWrite works well if you are using SciTe as your text editor (highly recommended by the way -- see the downloads page). It writes messages to a special resizable window at the bottom of the editor.

Dale

Ahh, I was wondering where the output for ConsoleWrite was going! Yes I do use Scite. Thanks for the info.

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  
Followers 0