![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
twebbrowser, ihtmldocument, таблица большого размера [D7, WinXP]
just © (2005-07-19 08:06:00)Считываю таблицу таким образом:
var
i,j,k: integer;
Table: OleVariant;
TableCount:integer;
IsTableFound:boolean;
Array_Connections:array of array[0..10] of string;
HTMLDocument:IHTMLDocument2;
begin
WebBrowser1.Navigate(OpenDialog1.FileName);
IsTableFound := false;
Tablecount:=WebBrowser1.OleObject.Document.all.tags('TABLE').Length;
for k:=0 to Tablecount-1 do
begin
Table := WebBrowser1.OleObject.Document.all.tags('TABLE').item(k);
if (Table.Rows.Item(0).Cells.Length = 11) then
begin
IsTableFound :=true;
StrinGrid1.ColCount:=Table.Rows.Item(0).Cells.Length;
StrinGrid1.RowCount:=Table.Rows.Length - 1;
setLength(Array_Connections,StrinGrid1.RowCount);
//HTMLDocument:=WebBrowser1.Document as IHTMLDocument2;
for i := 0 to (Table.Rows.Length - 1) do
begin
for j := 0 to (Table.Rows.Item(i).Cells.Length - 1) do
begin
StrinGrid1.Cells[j,i]:=Table.Rows.Item(i).Cells.Item(j).InnerText;
end;
end;
end;
if IsTableFound then exit;
end;
end;
Дело в том, что строк в этой таблице очень много, примерно от 4000 до 10000. И занесение данных в стрингрид происходит очень долго, комп даже зависает. Может как-то можно оптимизировать код? А Ihtmldocument как-то поможет тут? Вообще задача такая: считать таблицу из html-файла, затем занести в БД.
just (2005-07-20 14:31:00) [1]помогло, спасибо
DiamondShark (2005-07-19 17:03:00) [2]
> Может как-то можно оптимизировать код?
Например, вынести из тела цикла инварианты.
TableRows := Table.Rows;
for i := 0 to (TableRows.Length - 1) do
begin
RowCells := TableRows.Item(i).Cells;
for j := 0 to (RowCells.Length - 1) do
begin
StrinGrid1.Cells[j,i]:=RowCells.Item(j).InnerText;
end;
end;
Переменные TableRows и RowCells, естественно, OleVariant.
Потом можно заменить dispatch-вызовы на прямое обращение к интерфейсам.