⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdataresult.pas

📁 用于建筑的测斜数据处理!把测试设备的数据下载电脑,通过本系统进行分析,然后生成所需要的数据!
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit frmdataresult;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, ExtCtrls, TeeProcs, TeEngine, Chart,Series,comobj,excel2000;

type
  Tdataresult = class(TForm)
    rdpfx: TRadioGroup;
    rdpnr: TRadioGroup;
    chart: TChart;
    StringGrid1: TStringGrid;
    Button3: TButton;
    function getmax(a,b:real):real;
    function getmin(a,b:real):real;
    procedure FormActivate(Sender: TObject);
    procedure rdpfxClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button3Click(Sender: TObject);
    function openexceldir(filename:string):boolean;
  private
    { Private declarations }
    Sheet1:Variant;
  public
    { Public declarations }
    openflag2:boolean;
  end;

var
  dataresult: Tdataresult;
  max,min:real;
  fvexcel:Variant;

implementation

uses frmmain;

{$R *.dfm}
function Tdataresult.openexceldir(filename:string):boolean;
begin
        Result := True;
        try
                FvExcel := CreateOleObject('Excel.Application');
        except
                Application.MessageBox('打开Excel失败',PChar(Application.Title),MB_ICONERROR);
                Result := False;
        end;
        FvExcel.Caption := '';
        FvExcel.visible:=true;
        FvExcel.WorkBooks.Open(FileName); //打开工作簿
        FvExcel.WorkSheets[1].Activate;  //设置第1个工作表为活动工作表
end;

function Tdataresult.getmax(a,b:real):real;
begin
        if a>=b then result:=a
        else result:=b;
end;
function Tdataresult.getmin(a,b:real):real;
begin
        if a<=b then result:=a
        else result:=b;
end;

procedure Tdataresult.FormActivate(Sender: TObject);
var i,j:integer;
begin
        openflag2:=false;
        stringgrid1.ColCount:=datenum+2;
        stringgrid1.RowCount:=depthnum+1;
        for i:=1 to datenum do
                for j:=1 to depthnum do
                        stringgrid1.Cells[j,i]:=''; 
        stringgrid1.Cols[1].Text:='深度';
        for i:=1 to datenum do
        begin
                stringgrid1.Cols[i+1].Text:=datestr[i];
                TLineSeries.Create(self).Name:='series'+inttostr(i);
                chart.AddSeries(TLineSeries(findcomponent('series'+inttostr(i))));
                for j:=1 to depthnum do
                begin
                        stringgrid1.Cells[i+1,j]:=formatfloat('0.0',datapmca[i,j]);
                        stringgrid1.Cells[1,j]:=formatfloat('0.0',datadepth[i,j]);
                        if (j=1) and (i=1) then
                        begin
                                max:=datapmca[i,j];
                                min:=datapmca[i,j];
                        end
                        else
                        begin
                                max:=getmax(max,datapmca[i,j]);
                                min:=getmin(min,datapmca[i,j]);
                        end;
                end;
        end;          
        chart.LeftAxis.Maximum:=max;
        chart.LeftAxis.Minimum:=min;
        //加设置最大值和最小值 -或者自行设定
        rdpfx.OnClick(self);
        if chart.Width=1000 then chart.Width:=812;
        if chart.Height=400 then chart.Height:=233;
end;


procedure Tdataresult.rdpfxClick(Sender: TObject);
var i,j:integer;
flag:boolean;
begin
for i:=1 to datenum do
                for j:=1 to depthnum do
                        stringgrid1.Cells[i,j]:='';
if (rdpfx.ItemIndex=0) and (rdpnr.ItemIndex=0) then
begin
        chart.LeftAxis.Title.Caption:='平面差';
        for i:=1 to datenum do
        begin
                for j:=1 to depthnum do
                begin
                        stringgrid1.Cells[i+1,j]:=formatfloat('0.0',datapmca[i,j]);
                        stringgrid1.Cells[1,j]:=formatfloat('0.0',datadepth[i,j]);
                        if (j=1) and (i=1) then
                        begin
                                max:=datapmca[i,j];
                                min:=datapmca[i,j];
                        end
                        else
                        begin
                                max:=getmax(max,datapmca[i,j]);
                                min:=getmin(min,datapmca[i,j]);
                        end;
                end;
        end;
end;

if (rdpfx.ItemIndex=0) and (rdpnr.ItemIndex=1) then
begin
        chart.LeftAxis.Title.Caption:='平均差';
        for i:=1 to datenum do
        begin
                for j:=1 to depthnum do
                begin
                        stringgrid1.Cells[i+1,j]:=formatfloat('0.0',datapjca[i,j]);
                        stringgrid1.Cells[1,j]:=formatfloat('0.0',datadepth[i,j]);
                        if (j=1) and (i=1) then
                        begin
                                max:=datapjca[i,j];
                                min:=datapjca[i,j];
                        end
                        else
                        begin
                                max:=getmax(max,datapjca[i,j]);
                                min:=getmin(min,datapjca[i,j]);
                        end;
                end;
        end;
end;
if (rdpfx.ItemIndex=0) and (rdpnr.ItemIndex=2) then
begin
        chart.LeftAxis.Title.Caption:='累积差';
        for i:=1 to datenum do
        begin
                for j:=1 to depthnum do
                begin
                        stringgrid1.Cells[i+1,j]:=formatfloat('0.0',dataljca[i,j]);
                        stringgrid1.Cells[1,j]:=formatfloat('0.0',datadepth[i,j]);
                        if (j=1) and (i=1) then
                        begin
                                max:=dataljca[i,j];
                                min:=dataljca[i,j];
                        end
                        else
                        begin
                                max:=getmax(max,dataljca[i,j]);
                                min:=getmin(min,dataljca[i,j]);
                        end;
                end;
        end;
end;
if (rdpfx.ItemIndex=0) and (rdpnr.ItemIndex=3) then
begin
        chart.LeftAxis.Title.Caption:='比较差';
        for i:=1 to datenum do
        begin
                for j:=1 to depthnum do
                begin
                        stringgrid1.Cells[i+1,j]:=formatfloat('0.0',datazza[i,j]);
                        stringgrid1.Cells[1,j]:=formatfloat('0.0',datadepth[i,j]);
                        if (j=1) and (i=1) then
                        begin
                                max:=datazza[i,j];
                                min:=datazza[i,j];
                        end
                        else
                        begin
                                max:=getmax(max,datazza[i,j]);
                                min:=getmin(min,datazza[i,j]);
                        end;
                end;
        end;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -