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

📄 unmakereportdetail.pas

📁 本产品是开发LISTVIEW相关功能的可定制产品
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                  QSD8.Height:=30;
                  QRDBT8.Top:=10;

                  QSU8.Left:=QSU7.Left+QSU7.width;
                  QSU8.width:=Items[i].Size;
                  if ReportDataSet.FieldDefs.Count=9 then
                      QSU8.width:=ChildBand1.Width-QSU8.Left;

                  QSD8.Left:=QSU8.Left;
                  QSD8.width:=QSU8.width;
                  QRLb8.Left:=QSU8.Left+6;
                  QRLb8.Caption:=ColumnDefine[i].PrintCaption;
                  QRDBT8.Left:=QSD8.Left+6;
                  QRDBT8.DataField := Items[i].Name;
                  QRDBT8.DataSet := ReportDataSet;
              end;
          9://第十列定义
              begin
                  QSU9.Top:=0;
                  QSU9.Height:=33;
                  QRLb9.Top:=10;
                  QSD9.Top:=0;
                  QSD9.Height:=30;
                  QRDBT9.Top:=10;

                  QSU9.Left:=QSU8.Left+QSU8.width;
                  QSU9.width:=Items[i].Size;
                  if ReportDataSet.FieldDefs.Count=10 then
                      QSU9.width:=ChildBand1.Width-QSU9.Left;

                  QSD9.Left:=QSU9.Left;
                  QSD9.width:=QSU9.width;
                  QRLb9.Left:=QSU9.Left+6;
                  QRLb9.Caption:=ColumnDefine[i].PrintCaption;
                  QRDBT9.Left:=QSD9.Left+6;
                  QRDBT9.DataField := Items[i].Name;
                  QRDBT9.DataSet := ReportDataSet;
              end;
          end;
          i:=i+1; //下一列
      end;
  end;
end;

//按用户要求的字段内容和顺序打印报表
//使用方法:在调用该函数前需要让用户选择打印哪些列,并将操作人员选中的列和顺序依次存入一个列表或数组中;
// sgNormal:为需要打印的stringGrid
//使用条件:只能打印存储在stringGrid中的数据,且最多打印6行11列
procedure TMakeReportDetail.MakeTotalBand(sgNormal:TstringGrid);
var ColumnWidth:array [0..10] of integer;
    i,j:Integer;
begin
  if (FrmUniversalReport=nil) then
      FrmUniversalReport := TFrmReport.Create(nil);
  with FrmUniversalReport do
  begin
    i:=0;
    j:=0;
    while((i<=10) and (i<sgNormal.ColCount)) do//每列打印宽度的设置
    begin
        ColumnWidth[i]:=sgNormal.Width div sgNormal.ColCount+36;
        j:=j+ColumnWidth[i];
        i:=i+1;
    end;
    if PrintModal=3 then i:=-1;
    if PrintModal=0then
    begin
        if j>718 then
        begin
           PrintModal:=1;
           if i>-1 then
              Application.MessageBox('    报表需要打印的宽度超过了设置宽度,将会有部分打印越界!请与系统管理员联系,将纸张改为横打方式。','系统提示',MB_ok);
        end;
    end
    else
        if j>1047 then
        begin
           Application.MessageBox('    报表需要打印的宽度超过了设置宽度,将会有部分打印越界!请与系统管理员联系。','系统提示',MB_ok);
        end;
    begin
    end;
    QRShape1.width:=j-32;

// 固定位置--标题行
    if(sgNormal.RowCount>0)then  //如果打印行数大于零
    begin
        Shape0.Left:=0;//该单元打印位置及宽度设置
        Shape0.Width:=ColumnWidth[0];
        QRLabel0.Left:=Shape0.Left+6;
        QRLabel0.Width:=ColumnWidth[0]-9;
        QRLabel0.Caption:= sgNormal.Cells[0,0];//该单元打印内容设置
        if(sgNormal.ColCount>1)then//如果打印行数大于1
        begin
            Shape1.Left:=Shape0.Left+ColumnWidth[0];//该单元打印位置及宽度设置
            Shape1.Width:=ColumnWidth[1];
            QRLabel1.Left:=Shape1.Left+6;
            QRLabel1.Width:=ColumnWidth[1]-9;
            QRLabel1.Caption:= sgNormal.Cells[1,0];
        end;
        if(sgNormal.ColCount>2)then//如果打印行数大于2
        begin
            Shape2.Left:=Shape1.Left+ColumnWidth[1];//该单元打印位置及宽度设置
            Shape2.Width:=ColumnWidth[2];
            QRLabel2.Left:=Shape2.Left+6;
            QRLabel2.Width:=ColumnWidth[2]-9;
            QRLabel2.Caption:= sgNormal.Cells[2,0];
        end;
        if(sgNormal.ColCount>3)then//如果打印行数大于3
        begin
            Shape3.Left:=Shape2.Left+ColumnWidth[2];//该单元打印位置及宽度设置
            Shape3.Width:=ColumnWidth[3];
            QRLabel3.Left:=Shape3.Left+6;
            QRLabel3.Width:=ColumnWidth[3]-9;
            QRLabel3.Caption:= sgNormal.Cells[3,0];
        end;
        if(sgNormal.ColCount>4)then//如果打印行数大于4
        begin
            Shape4.Left:=Shape3.Left+ColumnWidth[3];//该单元打印位置及宽度设置
            Shape4.Width:=ColumnWidth[4];
            QRLabel4.Left:=Shape4.Left+6;
            QRLabel4.Width:=ColumnWidth[4]-9;
            QRLabel4.Caption:= sgNormal.Cells[4,0];
        end;
        if(sgNormal.ColCount>5)then//如果打印行数大于5
        begin
            Shape5.Left:=Shape4.Left+ColumnWidth[4];//该单元打印位置及宽度设置
            Shape5.Width:=ColumnWidth[5];
            QRLabel5.Left:=Shape5.Left+6;
            QRLabel5.Width:=ColumnWidth[5]-9;
            QRLabel5.Caption:= sgNormal.Cells[5,0];
        end;
        if(sgNormal.ColCount>6)then//如果打印行数大于6
        begin
            Shape6.Left:=Shape5.Left+ColumnWidth[5];//该单元打印位置及宽度设置
            Shape6.Width:=ColumnWidth[6];
            QRLabel6.Left:=Shape6.Left+6;
            QRLabel6.Width:=ColumnWidth[6]-9;
            QRLabel6.Caption:= sgNormal.Cells[6,0];
        end;
        if(sgNormal.ColCount>7)then//如果打印行数大于7
        begin
            Shape7.Left:=Shape6.Left+ColumnWidth[6];//该单元打印位置及宽度设置
            Shape7.Width:=ColumnWidth[7];
            QRLabel7.Left:=Shape6.Left+6;
            QRLabel7.Width:=ColumnWidth[7]-9;
            QRLabel7.Caption:= sgNormal.Cells[7,0];
        end;
        if(sgNormal.ColCount>8)then//如果打印行数大于8
        begin
            Shape8.Left:=Shape7.Left+ColumnWidth[7];//该单元打印位置及宽度设置
            Shape8.Width:=ColumnWidth[8];
            QRLabel8.Left:=Shape8.Left+6;
            QRLabel8.Width:=ColumnWidth[8]-9;
            QRLabel8.Caption:= sgNormal.Cells[8,0];
        end;
        if(sgNormal.ColCount>9)then//如果打印行数大于9
        begin
            Shape9.Left:=Shape8.Left+ColumnWidth[8];//该单元打印位置及宽度设置
            Shape9.Width:=ColumnWidth[9];
            QRLabel9.Left:=Shape9.Left+6;
            QRLabel9.Width:=ColumnWidth[9]-9;
            QRLabel9.Caption:= sgNormal.Cells[9,0];
        end;
        if(sgNormal.ColCount>10)then//如果打印行数大于10
        begin
            Shape10.Left:=Shape9.Left+ColumnWidth[9];//该单元打印位置及宽度设置
            Shape10.Width:=ColumnWidth[10];
            QRLabel10.Left:=Shape10.Left+6;
            QRLabel10.Width:=ColumnWidth[10]-9;
            QRLabel10.Caption:= sgNormal.Cells[10,0];
        end;
    end;
// 位置--第二行
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>0))then//如果打印行数大于1,且打印列数大于0
    begin
        sShape0.Left:=0;//该单元打印位置及宽度设置
        sShape0.Width:=ColumnWidth[0];
        QRLabel0.Left:=sShape0.Left+6;
        sQRLabel0.Width:=ColumnWidth[0]-9;
        sQRLabel0.Caption:= sgNormal.Cells[0,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>1))then//如果打印行数大于1,且打印列数大于1
    begin
        sShape1.Left:=sShape0.Left+ColumnWidth[0];//该单元打印位置及宽度设置
        sShape1.Width:=ColumnWidth[1];
        sQRLabel1.Left:=sShape1.Left+6;
        sQRLabel1.Width:=ColumnWidth[1]-9;
        sQRLabel1.Caption:= sgNormal.Cells[1,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>2))then//如果打印行数大于1,且打印列数大于2
    begin
        sShape2.Left:=sShape1.Left+ColumnWidth[1];
        sShape2.Width:=ColumnWidth[2];
        sQRLabel2.Left:=sShape2.Left+6;
        sQRLabel2.Width:=ColumnWidth[2]-9;
        sQRLabel2.Caption:= sgNormal.Cells[2,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>3))then//如果打印行数大于1,且打印列数大于3
    begin
        sShape3.Left:=sShape2.Left+ColumnWidth[2];
        sShape3.Width:=ColumnWidth[3];
        sQRLabel3.Left:=sShape3.Left+6;
        sQRLabel3.Width:=ColumnWidth[3]-9;
        sQRLabel3.Caption:= sgNormal.Cells[3,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>4))then
    begin
        sShape4.Left:=sShape3.Left+ColumnWidth[3];
        sShape4.Width:=ColumnWidth[4];
        sQRLabel4.Left:=sShape4.Left+6;
        sQRLabel4.Width:=ColumnWidth[4]-9;
        sQRLabel4.Caption:= sgNormal.Cells[4,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>5))then
    begin
        sShape5.Left:=sShape4.Left+ColumnWidth[4];
        sShape5.Width:=ColumnWidth[5];
        sQRLabel5.Left:=sShape5.Left+6;
        sQRLabel5.Width:=ColumnWidth[5]-9;
        sQRLabel5.Caption:= sgNormal.Cells[5,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>6))then
    begin
        sShape6.Left:=sShape5.Left+ColumnWidth[5];
        sShape6.Width:=ColumnWidth[6];
        sQRLabel6.Left:=sShape6.Left+6;
        sQRLabel6.Width:=ColumnWidth[6]-9;
        sQRLabel6.Caption:= sgNormal.Cells[6,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>7))then
    begin
        sShape7.Left:=sShape6.Left+ColumnWidth[6];
        sShape7.Width:=ColumnWidth[7];
        sQRLabel7.Left:=sShape6.Left+6;
        sQRLabel7.Width:=ColumnWidth[7]-9;
        sQRLabel7.Caption:= sgNormal.Cells[7,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>8))then
    begin
        sShape8.Left:=sShape7.Left+ColumnWidth[7];
        sShape8.Width:=ColumnWidth[8];
        sQRLabel8.Left:=sShape8.Left+6;
        sQRLabel8.Width:=ColumnWidth[8]-9;
        sQRLabel8.Caption:= sgNormal.Cells[8,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>9))then
    begin
        sShape9.Left:=sShape8.Left+ColumnWidth[8];
        sShape9.Width:=ColumnWidth[9];
        sQRLabel9.Left:=sShape9.Left+6;
        sQRLabel9.Width:=ColumnWidth[9]-9;
        sQRLabel9.Caption:= sgNormal.Cells[9,1];
    end;
    if((sgNormal.RowCount>1) and (sgNormal.ColCount>10))then
    begin
        sShape10.Left:=sShape9.Left+ColumnWidth[9];
        sShape10.Width:=ColumnWidth[10];
        sQRLabel10.Left:=sShape10.Left+6;
        sQRLabel10.Width:=ColumnWidth[10]-9;
        sQRLabel10.Caption:= sgNormal.Cells[10,1];
    end;
// 位置--Third行
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>0))then//如果打印行数大于2,且打印列数大于0
    begin
        tShape0.Left:=0;
        tShape0.Width:=ColumnWidth[0];
        QRLabel0.Left:=tShape0.Left+6;
        rQRLabel0.Width:=ColumnWidth[0]-9;
        rQRLabel0.Caption:= sgNormal.Cells[0,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>1))then//如果打印行数大于2,且打印列数大于1
    begin
        tShape1.Left:=tShape0.Left+ColumnWidth[0];
        tShape1.Width:=ColumnWidth[1];
        rQRLabel1.Left:=tShape1.Left+6;
        rQRLabel1.Width:=ColumnWidth[1]-9;
        rQRLabel1.Caption:= sgNormal.Cells[1,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>2))then//如果打印行数大于2,且打印列数大于2
    begin
        tShape2.Left:=tShape1.Left+ColumnWidth[1];
        tShape2.Width:=ColumnWidth[2];
        rQRLabel2.Left:=tShape2.Left+6;
        rQRLabel2.Width:=ColumnWidth[2]-9;
        rQRLabel2.Caption:= sgNormal.Cells[2,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>3))then//如果打印行数大于2,且打印列数大于3
    begin
        tShape3.Left:=tShape2.Left+ColumnWidth[2];
        tShape3.Width:=ColumnWidth[3];
        rQRLabel3.Left:=tShape3.Left+6;
        rQRLabel3.Width:=ColumnWidth[3]-9;
        rQRLabel3.Caption:= sgNormal.Cells[3,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>4))then
    begin
        tShape4.Left:=tShape3.Left+ColumnWidth[3];
        tShape4.Width:=ColumnWidth[4];
        rQRLabel4.Left:=tShape4.Left+6;
        rQRLabel4.Width:=ColumnWidth[4]-9;
        rQRLabel4.Caption:= sgNormal.Cells[4,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>5))then
    begin
        tShape5.Left:=tShape4.Left+ColumnWidth[4];
        tShape5.Width:=ColumnWidth[5];
        rQRLabel5.Left:=tShape5.Left+6;
        rQRLabel5.Width:=ColumnWidth[5]-9;
        rQRLabel5.Caption:= sgNormal.Cells[5,2];
    end;
    if((sgNormal.RowCount>2) and (sgNormal.ColCount>6))then
    begin
        tShape6.Left:=tShape5.Left+ColumnWidth[5];
        tShape6.Width:=ColumnWidth[6];
        rQRLabel6.Left:=tShape6.Left+6;
        rQRLabel6.Width:=ColumnWidth[6]-9;
        rQRLabel6.Caption:= sgNormal.Cells[6,2];

⌨️ 快捷键说明

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