Jump to content

_IEtablewritearray copying table correctyl


erikj
 Share

Recommended Posts

I have a table with four columns -the rows vary by day. These cells include extraneous information. I have figured out everything up to how get the info copied from the tables and into excel (terrible formatted though).

Is there a way that I can pick and choose what information is copied out of these cells? For Example, only copy Event:, Time: and Room: and their associated values.

#include <IE.au3>; Include the UDF
#include <Array.au3>
#include <ExcelCom_udf.au3>
; Create an IE Browser
;
$oIE = _IECreate()
_IENavigate($oIE, "http://128.164.182.42:8001/cgi-bin/Calendars/calendar.cgi?calendar=All_Room_view&list=on&days=0")
Sleep(750)
$oTable = _IETableGetCollection($oIE, 0)
; Read the table cells into a 2-D array
$otable2 = _IETableWriteToArray($oTable, True)
; Write the array contents out to the console
$todayevent = "c:\todaysevents.xlsx"
$oExcel= _ExcelBookOpen($todayevent)
sleep(1500)
    _ExcelWriteSheetFromArray($oExcel, $otable2, 1, 1, 1, 1)
sleep(1500)
$oIE = _IEQuit($oIE)

The html looks like this:

CODE

<TABLE BORDER = "1" CELLPADDING = "5" CELLSPACING = "0" CLASS="milummain" WIDTH="100%">

<TR>

<TD COLSPAN=4 BGCOLOR="#DBE4F8" ALIGN=CENTER CLASS="monthhead" >

Events For Today Friday September 26, 2008 - Forward 0 Days

</TD>

</TR>

<TR CLASS="milummain" >

<TD BACKGROUND="./Calendar_art2/bluegrad2.gif"><B>Date</B></TD>

<TD WIDTH=190 BACKGROUND="./Calendar_art2/bluegrad2.gif"><B>Time</B></TD>

<TD BACKGROUND="./Calendar_art2/bluegrad2.gif"><B>Event Name</B></TD>

<TD BACKGROUND="./Calendar_art2/bluegrad2.gif"><B>Event Details</B></TD><TR>

<TD BGCOLOR="#ffffff"VALIGN="top" class="milummain" style="color:990033">Friday , <A HREF=calendar.cgi/calendar.cgi?offset=14&calendar=./All_Room_view&day=26&year=2008&month=9&session_file=&view_day=on style=color:990033>9/26/2008</A></TD>

<TD BGCOLOR="#ffffff"VALIGN="top" class="milummain" style="color:990033">8:15 AM - 3:30 PM</TD>

<TD BGCOLOR="#ffffff"VALIGN="top" class="milummain" style="color:990033">Test Event</TD>

<TD BGCOLOR="#ffffff"VALIGN="top" class="milummain" style="color:990033">Names are: 401{2129-G}-12max, All Room View<BR>Keyword: None<BR>Label: None<BR>Agenda: TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST

TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST

TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST

TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST

TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST

TESTTESTTESTTEST</TD></TR>

<TD BGCOLOR="#DBE4F8" COLSPAN=4 CLASS="milummain">Event Colors Represent The Number of Day Until The Event :<BR><SPAN style="color:990033">Red = Today</SPAN>, <SPAN style="COLOR:FF6600">Orange = Tomorrow</SPAN> , <SPAN Style="COLOR:336633">Green = Three Days Away </Span>& Blue = More Than 3 Days Away</TD>

</TD>

</TR>

</TABLE>

Thanks Everyone!

Link to comment
Share on other sites

I have a table with four columns -the rows vary by day. These cells include extraneous information. I have figured out everything up to how get the info copied from the tables and into excel (terrible formatted though).

Is there a way that I can pick and choose what information is copied out of these cells? For Example, only copy Event:, Time: and Room: and their associated values.

Modify the array before writing it to the Excel sheet. Remove the unwanted columns.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Modify the array before writing it to the Excel sheet. Remove the unwanted columns.

:)

hmm, i wish i had enough autoit experience to know what that meant and how to do it. the help file, while helpful for sure, doesnt get too in depth with manipulations like that. i know this should be a learning experience with breadcrumb hints along the way, but is there anything more specific you can give me to get me going?

Link to comment
Share on other sites

hmm, i wish i had enough autoit experience to know what that meant and how to do it. the help file, while helpful for sure, doesnt get too in depth with manipulations like that. i know this should be a learning experience with breadcrumb hints along the way, but is there anything more specific you can give me to get me going?

When you read the table from IE, the result is a two dimensional array (row/col like a spreadsheet). Your description sounds like you want all the rows, but not all the columns, copied to an Excel spreadsheet. What I propose is to edit the array by copying only the data you want to a new 2D array, and then writing that array to Excel with _IEWriteSheetFromArray().

The hard part is that, while it is easy to delete a row with _ArrayDelete(), you are on your own to delete a column (it can be done, but there is no function for it in Array.au3).

The method that requires the least code from you takes advantage of the fact that the IE table reads transposed from typical usage. The first dimension is columns and the second is rows. This means _ArrayDelete() can be used to delete unwanted columns, then you only need the code to transpose the array (flip Row/Col).

Something like this:

#include <IE.au3>
#include <Array.au3>

$oIE = _IE_Example("table")
$oTable = _IETableGetCollection($oIE, 0); Read the 1st table
$aTableData = _IETableWriteToArray($oTable, False); False = do not transpose
_ArrayDisplay($aTableData, "Before")

; Delete second and fourth columns, which are rows 1 and 3 in the current array
; Note they must be deleted in reverse order, or the row numbers will change
_ArrayDelete($aTableData, 3)
_ArrayDelete($aTableData, 1)
_ArrayDisplay($aTableData, "After")

; Transpose the array into a new one for writing to Excel
Global $aNewTable[UBound($aTableData, 2)][UBound($aTableData)]
For $r = 0 To UBound($aTableData) - 1
    For $c = 0 To UBound($aTableData, 2) - 1
        $aNewTable[$c][$r] = $aTableData[$r][$c]
    Next
Next
_ArrayDisplay($aNewTable, "Transposed")

; Write to Excel
; ... open book etc.
_ExcelWriteSheetFromArray($oExcel, $aNewTable)

; Close IE
_IEQuit($oIE)

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...