Hi, i hope someone is able to guide me in the right direction.
I am currently trying to export a SQL list and a HTML Table list into excel, then run a comparison on the results.
I can export the SQL list into excel and the data shows correctly, but when i try to do the same on the HTML list, it is only showing 1 item.
Here is the code that i am using below with the HTML code at the top, and the working SQL code below (have masked some parts with ????)
Many thanks in advance!
01.
IList<HtmlTableCell> myList = ActiveBrowser.Find.AllByTagName<HtmlTableCell>(
"td"
);
02.
03.
foreach
(HtmlTableCell item
in
myList)
04.
{
05.
string
csv2 = item.InnerText.ToString().Trim();
06.
string
[] parts2 = csv2.Split(
','
);
07.
List<
string
> cellList =
new
List<
string
>(parts2);
08.
cellList.Add(csv2);
09.
10.
foreach
(var tableitems
in
cellList)
11.
{
12.
// WRITE EXCEL CODE HERE
13.
Log.WriteLine(
"SHOW CSV2: "
+ csv2);
14.
int
row = 2;
15.
int
col = 2;
16.
excelApp.Cells[row, col] = tableitems;
17.
row++;
18.
if
(cellList.IndexOf(tableitems) == cellList.Count - 1)
19.
20.
col = 2;
21.
}
22.
}
23.
24.
25.
// ********** SQL DATA CODE START **********
26.
List<
string
>LicenseeList=
new
List<
string
>();
27.
using
(SqlConnection Conn =
new
SqlConnection(@
""
+ myVar2))
28.
{
29.
string
qry = @
"SELECT Name FROM ?????? WHERE ?????? = '????'"
;
30.
var cmd =
new
SqlCommand(qry,Conn);
31.
cmd.CommandType = dt.CommandType.Text;
32.
Conn.Open();
33.
using
(SqlDataReader reader = cmd.ExecuteReader())
34.
{
35.
if
(reader.HasRows)
36.
{
37.
while
(reader.Read())
38.
{
39.
string
item = reader.GetString(reader.GetOrdinal(
"?????"
));
40.
LicenseeList.Add(item);
41.
42.
}
43.
44.
// DO THE EXCEL STUFF HERE
45.
Log.WriteLine(
"THIS MANY IN LIST(SQL DATA): "
+ LicenseeList.Count.ToString());
46.
int
row = 2;
47.
int
col = 1;
48.
foreach
(var LicenseeItem
in
LicenseeList)
49.
{
50.
51.
excelApp.Cells[row, col] = LicenseeItem;
52.
row++;
53.
if
(LicenseeList.IndexOf(LicenseeItem) == LicenseeList.Count - 1)
54.
55.
col = 1;
56.
}
57.
}
58.
// Close the Reader
59.
reader.Close();
60.
}
61.
// Close the connection
62.
Conn.Close();
63.
}
64.
// ******** SQL DATA CODE END *******