我有一个10行的Webtable,Excel表格中有类似的表,有100行数据。
我需要检查excel中是否存在10行webtable数据,还需要打印它匹配的exc enter image description here中的哪一行。
答案 0 :(得分:0)
您还没有提供有关您的网表的任何详细信息,因此我假设它只有多行的列。如果它有多个启动数组然后进行比较。如果excel中的所有值都与webtable匹配,它将返回true。
begin
if exists (select distinct id from test where id in (select distinct NUMBER from table1))
begin
update test set
T1 =
(
case
when TYPE='ABC' then DATE end as T1
) ,
T2 =
(
case
when TYPE='XYZ' then DATE end as T2
)
where TA = table1.NUMBER
end
else
begin
insert into test (
T1,
T2
)
select (
case when TYPE='ABC' then DATE end as T1,
case when TYPE='XYZ' then DATE end as T2
)
from table1 where NUMBER=test.id
end
end
下一步
结束功能
答案 1 :(得分:0)
首先,从WebTable中读取数据行
Dim Table, CheckArray
Set Table = Browser("YourBrowser").Page("YourPage").WebTable("YourTable")
ReDim CheckArray(Table.RowCount - 1) ' Arrays index from 0, table rows from 1
For iLoop = 1 to Table.RowCount
CheckArray(iLoop-1) = Table.GetCellData(iLoop, 1)
Next
拥有此数组后,您可以遍历每个值并检查Excel表。有几种方法可以实现这一目标。
其中最不复杂的是1,所以我将详细说明这种方法:
Datatable.Import("YourExcelFilePathHere.xls", Global)
iRowsToCheck = DataTable.GetRowCount
For iLoop = 0 to Ubound(CheckArray)
bFound = False
For iSubLoop = 1 to iRowsToCheck
DataTable.SetCurrentRow(iSubLoop)
If CheckArray(iLoop) = Datatable.Value("ColumnName") Then
bFound = True
Exit For
End If
Next
If bFound Then
CheckArray(iLoop) = CheckArray(iLoop) & " was found"
Else
CheckArray(iLoop) = CheckArray(iLoop) & " was not found"
End If
Next
这会导入您的excel文件,并且对于webtable数组中的每个元素,都会在excel表中检查它。如果找到,它将退出并将数组项标记为已找到。如果在没有将bFound
设置为True的情况下完成,则找不到并相应地更新。
然后,您可以根据需要输出阵列的内容以获得结果。