Уважаемые форумчане, помогите разрешить проблему.
В динамический массив (объявлен глобальным) считываются значения из Ексель:
Код:
procedure Load_values (var str: string; a: Tarray);
var
Excel: variant;
i, j, counter: word;
begin
Excel := CreateOleObject('Excel.Application');
Excel.Workbooks.Open(str);
// Excel.Visible:=True;
i:=1;
counter:=0;
while Excel.Sheets[1].Cells[i,1].Text <> '' do
begin
inc(i);
inc(counter);
end;
for i:=0 to 2 do
SetLength(arr_view[i], counter);
for i:=0 to counter-1 do
begin
arr_view[0, i]:=StrToInt(Excel.Sheets[1].Cells[i+1,1].Text);
arr_view[1, i]:=StrToInt(Excel.Sheets[1].Cells[i+1,2].Text);
arr_view[2, i]:=StrToInt(Excel.Sheets[1].Cells[i+1,3].Text);
end;
Excel.Quit;
end;
И отображаются в StingGrid:
Код:
begin
with View_Examples do
begin
RowCount:=length(arr_view[0])+1;
ColCount:=4;
for i:=0 to RowCount do
Rows[i].Clear;
Cells[1,0]:='X1';
Cells[2,0]:='X2';
Cells[3,0]:='Y';
for i:=1 to RowCount-1 do
Cells[0,i]:=IntToStr(i);
for i:=1 to 3 do
for j:=1 to RowCount do
Cells[i,j]:=IntToStr(arr_view[i-1, j-1]);
end;
end
Если выбрать другой экселевсий файл (через диалоги), StringGrid все равно отображает первоначальную выборку
![Печаль](images/smilies/frown.gif)
Как обновить содержимое? Заранее спасибо!