Ver5.9 "TableToArray" behave differently: <br> no longer regarded as "vbNewLine", but ignored #136
Closed
GHRyunosuke
started this conversation in
General
Replies: 1 comment 1 reply
-
|
@GHRyunosuke, thanks for reporting (and nice explanation!). This issue is fixed in v6.0. And in fact, I think it also fixes your Stock Screener issue as well (table not honoring whitespace between stock symbol and description in cell). The new technique (v5.9 and v6.0) is very fast - on my system processing a 501x127 cells table takes about 1/2 sec. For v6.0, I added an optional argument to not honor cell formatting (see test below). Sub test_table_to_array_formatting()
Dim driver As WebDriver
Dim elem As WebElement
Dim table() As Variant
Set driver = New WebDriver
driver.StartEdge
driver.OpenBrowser
htmlStr = "<html><body><table border='l' id='mytable'><tr><td>12/14/2024<br>12/15/2024</td><td>Hi, this is <p>Mike</p></td></tr></table></body></html>"
driver.SaveStringToFile htmlStr, ".\snippet.html"
driver.NavigateToFile ".\snippet.html"
driver.Wait 1500
Set elem = driver.FindElementByCssSelector("#mytable")
table = elem.TableToArray(ignoreCellFormatting:=False) 'default setting
Debug.Print "----------------------------------------------"
Debug.Print table(1, 1) '-> 12/14/2024 \r\n 12/15/2024
Debug.Print "----------------------------------------------"
Debug.Print table(1, 2) '-> Hi, this is \r\n \r\n Mike
table = elem.TableToArray(ignoreCellFormatting:=True)
Debug.Print "----------------------------------------------"
Debug.Print table(1, 1) '-> 12/14/202412/15/2024
Debug.Print "----------------------------------------------"
Debug.Print table(1, 2) '-> Hi, this is Mike
driver.Wait 1000
driver.CloseBrowser
driver.Shutdown
End Sub |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My findings below (using the ver5.9 DLL solution):

Ver5.8 and before:
The content you get via TableToArray is "24/12/12 & vbNewLine & 24/12/16"
So that one could get the 1st part via "Split(str, vbNewLine)"
Ver5.9:
The content you get via TableToArray is "24/12/1224/12/16"
So that one could no longer get the 1st part via "Split(str, vbNewLine)". Can be tricky to distinguish the 1st part in some cases.
I prefer the old behavior, however, if it is difficult to reverse the behavior back like before, I could cope with this.
Beta Was this translation helpful? Give feedback.
All reactions