prawdopodobnie chodzi o to ze excel nie rozpoznaje tego:
FloatToStr(Excel.Cells[i,1].Value) <> ''
pliik dfm
object Form1: TForm1
Left = 19
Top = 48
Width = 1006
Height = 660
Caption = 'Analizator'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
Position = poDesktopCenter
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 73
Width = 241
Height = 533
Align = alLeft
Caption = 'Panel1'
TabOrder = 0
object ListView1: TListView
Left = 1
Top = 1
Width = 239
Height = 463
Align = alClient
Columns = <
item
Caption = 'Lp'
end
item
Caption = 'alpha'
end
item
Caption = 'alpha2'
end
item
Caption = 'intensywnosc'
Width = 75
end>
GridLines = True
TabOrder = 0
ViewStyle = vsReport
end
object Panel4: TPanel
Left = 1
Top = 464
Width = 239
Height = 68
Align = alBottom
TabOrder = 1
object Label_max: TLabel
Left = 8
Top = 32
Width = 117
Height = 13
Caption = 'Najwi'#281'ksza wartosc piku'
Visible = False
end
object ProgressBar1: TProgressBar
Left = 8
Top = 8
Width = 225
Height = 17
TabOrder = 0
Visible = False
end
end
end
object Panel2: TPanel
Left = 241
Top = 73
Width = 757
Height = 533
Align = alClient
TabOrder = 1
object Chart1: TChart
Left = 0
Top = 8
Width = 497
Height = 465
AnimatedZoom = True
BackWall.Brush.Color = clWhite
BackWall.Brush.Style = bsClear
Title.Text.Strings = (
'Wykres przedstawiaj'#261'cy dane pomiarowe')
View3DWalls = False
BorderStyle = bsSingle
TabOrder = 0
end
end
object Panel3: TPanel
Left = 0
Top = 0
Width = 998
Height = 73
Align = alTop
TabOrder = 2
DesignSize = (
998
73)
object Label1: TLabel
Left = 805
Top = 44
Width = 53
Height = 13
Caption = 'Tolerancja:'
end
object Label2: TLabel
Left = 806
Top = 16
Width = 18
Height = 13
Caption = 'Tlo:'
end
object Label_plik_pomiar: TLabel
Left = 8
Top = 32
Width = 3
Height = 13
end
object Edit_tolerancja: TEdit
Left = 864
Top = 40
Width = 121
Height = 21
Anchors = [akTop, akRight]
TabOrder = 0
Text = '0,01'
end
object Edit_tlo: TEdit
Left = 864
Top = 8
Width = 121
Height = 21
Anchors = [akTop, akRight]
Enabled = False
TabOrder = 1
end
object Edit_plik_pomiar: TEdit
Left = 8
Top = 48
Width = 345
Height = 21
Enabled = False
TabOrder = 2
Visible = False
end
object Btn_rysuj_wykres: TButton
Left = 359
Top = 45
Width = 75
Height = 25
Caption = 'Rysuj wykres'
TabOrder = 3
Visible = False
OnClick = Btn_rysuj_wykresClick
end
object Btn_wzorcowa: TButton
Left = 438
Top = 45
Width = 153
Height = 25
Caption = 'Poka'#380' dane bazy wzorcowej'
TabOrder = 4
Visible = False
OnClick = Btn_wzorcowaClick
end
end
object XPManifest1: TXPManifest
Left = 777
Top = 545
end
object MainMenu1: TMainMenu
Left = 168
Top = 8
object Plik1: TMenuItem
Caption = 'Plik'
object Otwrzplikzbazdanych1: TMenuItem
Caption = 'Otw'#243'rz plik z baz'#261' wzorcow'#261
ShortCut = 16463
OnClick = Otwrzplikzbazdanych1Click
end
object Otwrzplikzpomiarami1: TMenuItem
Caption = 'Otw'#243'rz plik z pomiarami'
ShortCut = 16464
OnClick = Otwrzplikzpomiarami1Click
end
end
object Dane1: TMenuItem
Caption = 'Dane'
object Pokadanebazywzorcowej1: TMenuItem
Caption = 'Poka'#380' dane bazy wzorcowej'
end
object Pokadaneplikupomiarowego1: TMenuItem
Caption = 'Poka'#380' dane pliku pomiarowego'
end
object Importujbazwzorcowzexcela1: TMenuItem
Caption = 'Importuj baz'#281' wzorcow'#261' z excela'
ShortCut = 32837
end
end
end
object OpenDialog_baza: TOpenDialog
Filter = 'Pliki excel|*.xls'
Left = 200
Top = 8
end
object OpenDialog1: TOpenDialog
Filter = 'Pliki tekstowe|*.txt'
Left = 232
Top = 8
end
end
plik pas
unit analizator;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, XPMan, StdCtrls, ComOBJ, Menus, ShellApi,
ToolWin, ImgList, TeEngine, Series, TeeProcs, Chart, StrUtils;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
ListView1: TListView;
XPManifest1: TXPManifest;
Edit_tolerancja: TEdit;
Edit_tlo: TEdit;
Label1: TLabel;
Label2: TLabel;
MainMenu1: TMainMenu;
Plik1: TMenuItem;
Otwrzplikzbazdanych1: TMenuItem;
Otwrzplikzpomiarami1: TMenuItem;
Dane1: TMenuItem;
Pokadanebazywzorcowej1: TMenuItem;
Pokadaneplikupomiarowego1: TMenuItem;
OpenDialog_baza: TOpenDialog;
OpenDialog1: TOpenDialog;
Edit_plik_pomiar: TEdit;
Label_plik_pomiar: TLabel;
ProgressBar1: TProgressBar;
Btn_rysuj_wykres: TButton;
Chart1: TChart;
Importujbazwzorcowzexcela1: TMenuItem;
Btn_wzorcowa: TButton;
Panel4: TPanel;
Label_max: TLabel;
procedure Otwrzplikzbazdanych1Click(Sender: TObject);
procedure Otwrzplikzpomiarami1Click(Sender: TObject);
procedure Btn_rysuj_wykresClick(Sender: TObject);
procedure Btn_wzorcowaClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TDane = packed record
alpha : double;
alpha2 : double;
intensywnosc : double;
end;
TDaneFile = file of TDane;
var
Form1: TForm1;
implementation
uses Form_wzorcowa, wczytywanie;
{$R *.dfm}
procedure TForm1.Otwrzplikzbazdanych1Click(Sender: TObject);
var
Excel : OLEVariant;
i : integer;
ListItem : TListItem;
begin
Frm_wzorcowa.ListView1.Clear;
OpenDialog_baza.Execute;
Excel := CreateOleObject('Excel.Application');
Excel.Workbooks.Open(OpenDialog_baza.Filename);
try
i:=1;
while FloatToStr(Excel.Cells[i,1].Value) <> NULL do
//for i:=1 to StrToInt(InputBox('Importowanie z MS Excel', 'Podaj ilość importowanych rekordów','')) do
begin
i:=i+1;
//w petli utworz kolejne rekordy
if (FloatToStr(Excel.Cells[i,1].Value) = '') then break;
ListItem := Frm_wzorcowa.ListView1.Items.Add;
ListItem.Caption := IntToStr(i-1);//FloatToStr(Excel.Cells[i+1,1].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,1].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,2].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,3].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,4].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,5].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,6].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,7].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,8].Value);
ListItem.SubItems.Add(Excel.Cells[i-1,9].Value);
end;
finally
Btn_wzorcowa.Visible := True;
Frm_wzorcowa.ShowModal;
Excel.Application.Visible := False;
Excel.Quit;// CloseFile(Baza);
end;
end;
procedure TForm1.Otwrzplikzpomiarami1Click(Sender: TObject);
var
Plik : TextFile;
S, M : String;
List, L : TStringList;
ListItem : TListItem;
i : integer;
wartosc1, wartosc_ostatnia, pomiar : double;
tlo, tlo_procent, srednia, intensywnosc, max : double;
begin
ListView1.Clear;
OpenDialog1.Execute;
AssignFile(Plik, OpenDialog1.FileName);
try
Reset(Plik);
ProgressBar1.Max:= FileSize(Plik);
M:='';
i:=0;
max := 0;
while (not EOF(Plik)) and (M<>'[DATASEC]') do begin
ReadLn(Plik, M);
end;
while not EOF(Plik) do
begin
i:= i+1;
L := TStringList.Create;
Readln(Plik, M);
M := AnsiReplaceStr(M, '.', ',');
ExtractStrings([' '],[],PChar(M), L); //odczytywanie kolumn i umieszczanie w tablicy
if (StrToFloat(L[5]) > max) then max:= StrToFloat(L[5]);
if(i=1) then wartosc1 := StrToFloat(L[5]);
wartosc_ostatnia := StrToFloat(L[5]);
end;
CloseFile(Plik);
srednia := (wartosc1+wartosc_ostatnia) /2;
Reset(Plik);
S:='';
while (not EOF(Plik)) and (S<>'[DATASEC]') do
begin
ReadLn(Plik, S);
end;
i:=0;
while not EOF(Plik) do
begin
i := i+1;
List := TStringList.Create;
Readln(Plik, S);
S := AnsiReplaceStr(S, '.', ','); //zamiana kropek na przecinki
ExtractStrings([' '],[],PChar(S), List); //odczytywanie kolumn i umieszczanie w tablicy
ListItem := ListView1.Items.Add;
ListItem.Caption := IntToStr(i);
intensywnosc := StrToFloat(List[5]) - srednia;
if intensywnosc < 0 then intensywnosc := 0;
ListItem.SubItems.Add(List[0]);
ListItem.SubItems.Add(List[1]);
ListItem.SubItems.Add(FloatToStr(intensywnosc));
end;
finally
ProgressBar1.Position := FileSize(Plik);
ProgressBar1.Visible := False;
CloseFile(Plik);
Edit_tlo.Text := FloatToStr(tlo_procent)+ '%';
Btn_rysuj_wykres.Visible := True;
Edit_Plik_pomiar.Visible := True;
Edit_Plik_pomiar.Text := OpenDialog1.FileName;
Label_plik_pomiar.Caption := 'Nazwa pliku pomiarowego:';
Label_max.Visible := True;
Label_max.Caption := 'Największa intensywnosc: ' + FloatToStr(max);
end;
end;
procedure TForm1.Btn_rysuj_wykresClick(Sender: TObject);
var
ListItem : TListItem;
i : integer;
s : TLineSeries;
begin
s:=TLineSeries.Create(Self);
s.ParentChart:=Chart1;
s.Clear;
s.XLabelsSource := '';
for i:=1 to ListView1.Items.Count -1 do
begin
s.AddXY(StrToFloat(ListView1.Items[i].Subitems[0]), StrToFloat(ListView1.Items[i].Subitems[2]));
end;
end;
procedure TForm1.Btn_wzorcowaClick(Sender: TObject);
begin
Frm_wzorcowa.ShowModal;
end;
end.
plik dpr
program Project1;
uses
Forms,
analizator in 'analizator.pas' {Form1},
wczytywanie in 'wczytywanie.pas' {Frm_wczytywanie},
Form_wzorcowa in 'Form_wzorcowa.pas' {Frm_wzorcowa};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TFrm_wczytywanie, Frm_wczytywanie);
Application.CreateForm(TFrm_wzorcowa, Frm_wzorcowa);
Application.Run;
end.
</delphi>