procedure TForm1.Button1Click(Sender: TObject );
var
Exc, Workbook: oleVariant;
i: integer;
checkM, checkS: integer;
wb : olevariant;
savechanges: olevariant;
x,y:integer;
begin
Exc := CreateOleObject('Excel.Application');
Exc.visible := true;
wb:= Exc.Workbooks.Open[fname, 0, true];
i:=2;
checkM:=1;
checkS:=1;
while Exc.activesheet.cells.item[i, 1].value <> StartP2.Date do
i:=i+1;
while Exc.activesheet.cells.item[i, 1].value <> EndP2.Date do
begin
case checkM of
1: Exc.activesheet.cells.item[i, 4].value := Exc.activesheet.cells.item[i, 4].value + '0';
2: Exc.activesheet.cells.item[i, 4].value :=Exc.activesheet.cells.item[i, 4].value + '360';
3: Exc.activesheet.cells.item[i, 4].value :=Exc.activesheet.cells.item[i, 4].value+ '720';
4: Exc.activesheet.cells.item[i, 4].value :=Exc.activesheet.cells.item[i, 4].value+ '1080';
5: Exc.activesheet.cells.item[i, 4].value :=Exc.activesheet.cells.item[i, 4].value+ '1440';
6: Exc.activesheet.cells.item[i, 4].value :=Exc.activesheet.cells.item[i, 4].value+ '1800';
end;
x:=StrToInt(Exc.activesheet.cells.item[i, 4].value);
y:=StrToInt(Exc.activesheet.cells.item[i, 1].value);
Grafik.SeriesList[0].AddXY(x,y);
If ((Exc.activesheet.cells.item[i, 4].value > '359') and (Exc.activesheet.cells.item[i, 4].value < '360' ))
and ((Exc.activesheet.cells.item[i+1, 4].value > '0') and (Exc.activesheet.cells.item[i+1, 4].value < '1'))
then
checkM:= checkM+1
else
If ((Exc.activesheet.cells.item[i+1, 4].value > '359')and (Exc.activesheet.cells.item[i+1, 4].value < '360' ))
and ((Exc.activesheet.cells.item[i, 4].value > '0') and (Exc.activesheet.cells.item[i, 4].value < '1'))
then
checkM:=checkM-1;
case checkS of
1: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value+0;
2: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value;
3: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value;
4: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value;
5: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value;
6: Exc.activesheet.cells.item[i, 2].value :=Exc.activesheet.cells.item[i, 2].value;
end;
Grafik.SeriesList[1].AddXY(Exc.activesheet.cells.item[i, 2].value,Exc.activesheet.cells.item[i, 1].value);
If ((Exc.activesheet.cells.item[i, 2].value > 359) and (Exc.activesheet.cells.item[i, 2].value < 360 ))
and ((Exc.activesheet.cells.item[i+1, 2].value > 0) and (Exc.activesheet.cells.item[i+1, 2].value < 1))
then
checkS:= checkS+1
else
If ((Exc.activesheet.cells.item[i+1, 2].value > 359)and (Exc.activesheet.cells.item[i+1, 2].value < 360 ))
and ((Exc.activesheet.cells.item[i, 2].value > 0) and (Exc.activesheet.cells.item[i, 2].value < 1))
then
checkS:=checkS-1;
i:=i+1;
end;
//wb.close(savechanges := true);
//exc.quit;
//Exc.ActiveWorkbook.Close;
//Exc.Application.Quit;
end;