jdelaney Posted May 17, 2012 Posted May 17, 2012 (edited) I can't give any specific reproduction, since I'm analyizing an internal web page, but I noticed that if a table includes empty fields (NULL), the _IETableWriteToArray shows the field as "0". This can cause issues when trying to validate data that is supposed to be "0" or NULL... is there a setting anywhere to adjust this? [0]|Task|Rule Name|Age From|Age To|Gender|Problem|Medication|Lab Test|Result From|Result To|Status [1]|Loading...|||||||||| [2]|0|0|0|0|0|0|0|0|0|0|Active [3]|0|Test1|Test2|Test3|Male|30781 - Tension headache|DiaBeta|HDL - HDL-cholesterol|Test4|Test5|Active [4]|0|Default GFR Rule, Do Not Delete|0|0|0|0|0|GFR - Glomerular filtration rate (GFR)|0|30|Active Example from above, in row 2, only the first, and fifth element should be 0, the others are NULL in the table. **removed remarks, they are valid...only includes empty content for spans...still have the issue with difference between 0 and NULL Edited May 17, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
jdelaney Posted May 17, 2012 Author Posted May 17, 2012 (edited) fixed the issue, by creating my own IE UDF, and changed the function to include this, when writing the array: For $td In $tds If IsString ( $td.textcontent ) Then $sCellVal = $td.textcontent Else $sCellVal = "" EndIf $a_TableCells[$col][$row] = $sCellVal $col = $col + $td.colSpan Next results: [0]|Task|Rule Name|Age From|Age To|Gender|Problem|Medication|Lab Test|Result From|Result To|Status [1]|Loading...|||||||||| [2]||9|||||||||Active [3]||Test1|Test2|Test3|Male|30781 - Tension headache|DiaBeta|HDL - HDL-cholesterol|Test4|Test5|Active [4]||Default GFR Rule, Do Not Delete||||||GFR - Glomerular filtration rate (GFR)|0|30|Active Edited May 17, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
ileandros Posted May 17, 2012 Posted May 17, 2012 This already exists. If its a usefull UDF though provide a funct to help ppl.. I feel nothing.It feels great.
jdelaney Posted May 17, 2012 Author Posted May 17, 2012 I'm sorry, it's not a 'new' UDF...It's the default one, that i saved in a seperate file, so i can modify it...the full function is: *disclaimer*...this works on our tables, may not work on all expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _IETableWriteToArray ; Description ...: Reads the contents of a Table into an array ; Parameters ....: $o_object - Object variable of an InternetExplorer.Application, Table object ; $f_transpose- Boolean value. If True, swap rows and columns in output array ; Return values .: On Success - Returns a 2-dimensional array containing the contents of the Table ; On Failure - Returns 0 and sets @ERROR ; @ERROR - 0 ($_IEStatus_Success) = No Error ; - 3 ($_IEStatus_InvalidDataType) = Invalid Data Type ; - 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type ; @Extended - Contains invalid parameter number ; Author ........: Dale Hohm ; =============================================================================================================================== Func _IETableWriteToArray(ByRef $o_object, $f_transpose = True) If Not IsObj($o_object) Then __IEErrorNotify("Error", "_IETableWriteToArray", "$_IEStatus_InvalidDataType") Return SetError($_IEStatus_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($o_object, "table") Then __IEErrorNotify("Error", "_IETableWriteToArray", "$_IEStatus_InvalidObjectType") Return SetError($_IEStatus_InvalidObjectType, 1, 0) EndIf ; Local $i_cols = 0, $tds, $i_col Local $trs = $o_object.rows For $tr In $trs $tds = $tr.cells $i_col = 0 For $td In $tds $i_col = $i_col + $td.colSpan Next If $i_col > $i_cols Then $i_cols = $i_col Next Local $i_rows = $trs.length Local $a_TableCells[$i_cols][$i_rows] Local $col, $row = 0 For $tr In $trs $tds = $tr.cells $col = 0 For $td In $tds If IsString ( $td.textcontent ) Then $sCellVal = $td.textcontent Else $sCellVal = "" EndIf $a_TableCells[$col][$row] = $sCellVal $col = $col + $td.colSpan Next $row = $row + 1 Next If $f_transpose Then Local $i_d1 = UBound($a_TableCells, 1), $i_d2 = UBound($a_TableCells, 2), $aTmp[$i_d2][$i_d1] For $i = 0 To $i_d2 - 1 For $j = 0 To $i_d1 - 1 $aTmp[$i][$j] = $a_TableCells[$j][$i] Next Next $a_TableCells = $aTmp EndIf Return SetError($_IEStatus_Success, 0, $a_TableCells) EndFunc ;==>_IETableWriteToArray IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now