I have a MS Word (docx) file with a table in it, 2 rows each with 3 cells.
What I am trying to figure out is how to log the text of each cell.
The table looks like this:
The code (below) found on examples on this forum in this form is logging just the first cell in the first row. I can get the value for the table number of rows but I fail to understand how to iterate.
Actually, I am not sure how to pass the parameter of the row needed to the method: getRow(row_number).
Any hint, please.
What I am trying to figure out is how to log the text of each cell.
The table looks like this:
The code (below) found on examples on this forum in this form is logging just the first cell in the first row. I can get the value for the table number of rows but I fail to understand how to iterate.
Actually, I am not sure how to pass the parameter of the row needed to the method: getRow(row_number).
Any hint, please.
B4X:
Dim doc As JavaObject = OpenDocx(File.DirAssets, "1.docx")
Dim tables As List = doc.RunMethod("getTables", Null)
For Each table As JavaObject In tables
'
Dim rowNumber As Int = table.RunMethod("getNumberOfRows", Null)
Log("rowNumber= " & rowNumber) ' get the number of rows
'
Dim row As JavaObject = table.RunMethod("getRow", Array(0))
Dim cell As JavaObject = row.RunMethod("getCell", Array(0))
Dim paragraphs As List = cell.RunMethod("getParagraphs", Null)
For Each p As JavaObject In paragraphs
Dim runs As List = p.RunMethod("getRuns", Null)
If runs.IsInitialized Then
For Each r As JavaObject In runs
Dim text As String = r.RunMethod("getText", Array(0))
If text <> Null Then
Log(text)
End If
Next
End If
Next
Next