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

📄 pub_rep.pas

📁 工程预算系统
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      strtemp :=copy(str,npos+1,nlen);
      ndown:=pos('x',strtemp);
      if ndown<>0 then
      begin
        strtmp:=copy(strtemp,ndown+1,1);
        try
          ntemp:=strtoint(strtmp);
        except
          ntemp:=0;
        end;
      end
      else
        ntemp:=0;
      end;
  end
  else
    ntemp:=0;
  Result:=ntemp;
end;

{取得报表标题向左的宽度系数}
function getwidthl(str:string):integer;
var
  npos:integer;
  nlen:integer;
  nleft:integer;
  ntemp:integer;
  strtemp:string;
  strtmp:string;
begin
  ntemp:=0;
  nlen:=Length(Trim(str));
  if nlen>0 then
  begin
    npos :=pos('^',str);
    if npos<>0 then
    begin
      strtemp :=copy(str,npos+1,nlen);
      nleft:=pos('z',strtemp);
      if nleft<>0 then
      begin
        strtmp:=copy(strtemp,nleft+1,1);
        try
          ntemp:=strtoint(strtmp);
        except
          ntemp:=0;
        end;
      end
      else
        ntemp:=0;
      end;
  end
  else
    ntemp:=0;
   Result:=ntemp;
end;

{取得报表标题向右的宽度系数 }
function getwidthr(str:string):integer;
var
  npos:integer;
  nlen:integer;
  nright:integer;
  ntemp:integer;
  strtemp:string;
  strtmp:string;
begin
  ntemp:=0;
  nlen:=Length(str);
  if nlen>0 then
  begin
    npos :=pos('^',str);
    if npos<>0 then
    begin
      strtemp :=copy(str,npos+1,nlen);
      nright:=pos('y',strtemp);
      if nright<>0 then
      begin
        strtmp:=copy(strtemp,nright+1,1);
        try
          ntemp:=strtoint(strtmp);
        except
          ntemp:=0;
        end;
      end
      else
        ntemp:=0;
      end;
  end
  else
    ntemp:=0;
  Result:=ntemp;
end;

{取得报表行的左边距}
function getdisl(mygrid:TStringGrid;nc,nr:integer;nleft:integer;b_xh:boolean):integer;
var
  i,j:integer;
  nl:integer;            //截取字符串后所的长度
  nwidth:integer;     //宽度
begin
  nwidth:=0;
  //nleft:=nleft*3;
   //b_xh 是否有序号
  if b_xh then
    j:=0
  else
    j:=1;

  if mygrid.Cells[nc,nr]<>'' then
  begin
    nl:=getwidthl(mygrid.Cells[nc,nr]);

    if nl>=nc then
      nwidth:=0
    else if (nl>0) and (nl<nc) then
    begin
      for i:=j to nc-nl-1 do
        nwidth:=nwidth+mygrid.ColWidths[i];
    end
    else if nl=0 then
    begin
      for i:=j to nc-1 do
        nwidth:=nwidth+mygrid.ColWidths[i];
    end;
  end;

  result:=nwidth+nleft;
end;

{取得报表的标题行的高度                              行高                   }
function getheight(mygrid:TStringGrid;nc,nr:integer;ntmp:integer):integer;
var
  nup,ndown:integer;            //截取字符串后所的长度
  nheight,nupheight,ndownheight:integer;  //高度
  ncount:integer;                     //总行数
begin
  nheight:=0;
  nupheight:=0;
  ndownheight:=0;

  ncount:=mygrid.RowCount;
  if mygrid.Cells[nc,nr]<>'' then
  begin
    nup:=getheightup(mygrid.Cells[nc,nr]);
    ndown:=getheightdown(mygrid.Cells[nc,nr]);
    if ncount=6 then
      nheight:=ntmp
    else if ncount>6 then
    begin
      if nr=5 then
      begin
        if ndown>=4 then
          nheight:=ntmp*5
        else if ndown=3 then
          nheight:=ntmp*4
        else if ndown=2 then
          nheight:=ntmp*3
        else if ndown=1 then
          nheight:=ntmp*2
        else if ndown=0 then
          nheight:=ntmp;
      end;

      if nr=6 then
      begin
        if nup>=1 then
          nupheight:=1
        else if nup=0 then
          nupheight:=0;

        if ndown>=3 then
          ndownheight:=3
        else if (ndown>=0) and (ndown<3) then
          ndownheight:=ndown;

        nheight:=(nupheight+ndownheight+1)*ntmp;
      end;

      if nr=7 then
      begin
        if nup>=2 then
          nupheight:=2
        else if (nup=1) or (nup=0) then
          nupheight:=nup;

        if ndown>=2 then
           ndownheight:=2
        else if (ndown=1) or (ndown=0) then
           ndownheight:=ndown;

         nheight:=(nupheight+ndownheight+1)*ntmp;
      end;

      if nr=8 then
      begin
        if nup>=3 then
          nupheight:=3
        else if (nup>=0) and (nup<3) then
          nupheight:=nup;

        if ndown>=1 then
           ndownheight:=1
        else if ndown=0 then
          ndownheight:=0;

        nheight:=(nupheight+ndownheight+1)*ntmp;
      end;

      if nr=9 then
      begin
        if nup>=4 then
          nupheight:=4
        else if (nup>=0) and (nup<4) then
          nupheight:=nup;

        nheight:=(nupheight+1)*ntmp;
      end;
    end;
  end;
  Result:=nheight;
end;

{取得报表向上离纸的高度}
function gettopdis(mygrid:TStringGrid;nc,nr:integer;ntmp:integer;ntop:integer):integer;
var
  nup:integer;            //截取字符串后所的长度
  ncount:integer;
  i_tmp:integer;
begin
  i_tmp:=0;
  ncount:=mygrid.RowCount;

  if mygrid.Cells[nc,nr]<>'' then
  begin
    nup:=getheightup(mygrid.Cells[nc,nr]);

    if ncount=6 then
    begin
      i_tmp:=ntop;
    end;

    if ncount=7 then
    begin
      if nr=5 then
        i_tmp:=ntop;

      if nr=6 then
      begin
        if nup>=1 then
          i_tmp:=ntop
        else if nup=0 then
          i_tmp:=ntop+ntmp;
      end;
    end;

    if ncount=8 then
    begin
      if nr=5 then
      begin
        i_tmp:=ntop;
      end;

      if nr=6 then
      begin
        if nup>=1 then
          i_tmp:=ntop
        else if nup=0 then
          i_tmp:=ntop+ntmp;
      end;

      if nr=7 then
      begin
        if nup>=2 then
          i_tmp:=ntop
        else if nup=1 then
          i_tmp:=ntop+ntmp
        else if nup=0 then
          i_tmp:=ntop+ntmp*2;
      end;
    end;

    if ncount=9 then
    begin
      if nr=5 then
        i_tmp:=ntop;

      if nr=6 then
      begin
        if nup>=1 then
          i_tmp:=ntop
        else if nup=0 then
          i_tmp:=ntop+ntmp;
      end;

      if nr=7 then
      begin
        if nup>=2 then
          i_tmp:=ntop
        else if nup=1 then
          i_tmp:=ntop+ntmp
        else if nup=0 then
          i_tmp:=ntop+ntmp*2;
      end;

      if nr=8 then
      begin
        if nup>=3 then
          i_tmp:=ntop
        else if nup=2 then
          i_tmp:=ntop+ntmp
        else if nup=1 then
          i_tmp:=ntop+ntmp*2
        else if nup=0 then
          i_tmp:=ntop+ntmp*3;
      end;
    end;

    if ncount=10 then
    begin
      if nr=5 then
        i_tmp:=ntop;

      if nr=6 then
      begin
        if nup>=1 then
          i_tmp:=ntop
        else if nup=0 then
          i_tmp:=ntop+ntmp;
      end;

      if nr=7 then
      begin
        if nup>=2 then
          i_tmp:=ntop
        else if nup=1 then
          i_tmp:=ntop+ntmp
        else if nup=0 then
          i_tmp:=ntop+ntmp*2;
      end;

      if nr=8 then
      begin
        if nup>=3 then
          i_tmp:=ntop
        else if nup=2 then
          i_tmp:=ntop+ntmp

⌨️ 快捷键说明

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