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

📄 usprep.pas

📁 在打沙场用的最简单
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    if  CDSselectsub['fpurstore']<>NULL then
    StringGrid1.Cells[1,i]:=CDSselectsub['fpurstore'];//searq.fieldbyname('fpurstore').asstring;//'仓库';
    if CDSselectsub['fpurer']<>NULL then
    StringGrid1.Cells[2,i]:=CDSselectsub['fpurer'];//searq.fieldbyname('fpurer').asstring;//'负责人';
    if  CDSselectsub['fprovider']<>null then
    StringGrid1.Cells[3,i]:=CDSselectsub['fprovider'];//searq.fieldbyname('fprovider').asstring;//'供应商';
    if  CDSselectsub['fnote']<>null then
    StringGrid1.Cells[4,i]:=CDSselectsub['fnote'];//searq.fieldbyname('fnote').asstring;//'备注';
    if CDSselectsub['fdelivdate']<>null then
    StringGrid1.Cells[5,i]:=CDSselectsub['fdelivdate'];//searq.fieldbyname('fdelivdate').asstring;//'交货日期';
    if  CDSselectsub['fcreauser']<>null then
    StringGrid1.Cells[6,i]:=CDSselectsub['fcreauser'];//searq.fieldbyname('fcreauser').asstring;//'创建人';
    if CDSselectsub['fcreadate'] <>null then
    StringGrid1.Cells[7,i]:=CDSselectsub['fcreadate'];//searq.fieldbyname('fcreadate').asstring;//'订货日期';
    end;
///////////////////////////////////////////以上是头
    GetsqlData(CDSselectsub,'Vitem','fcode','fcode='+vartosql(adoquery1.fieldbyname('fcode').asstring),1);
    if cdsselectsub.RecordCount>0 then
    begin
    StringGrid1.Cells[8,i]:=CDSselectsub['fcode'];//searq.fieldbyname('fcode').asstring;//'物料代码';
    if CDSselectsub['fname']<>null then
    StringGrid1.Cells[9,i]:=CDSselectsub['fname'];//searq.fieldbyname('fname').asstring;//'成分';
    if CDSselectsub['zs']<>null then
    StringGrid1.Cells[10,i]:=CDSselectsub['zs'];//searq.fieldbyname('zs').asstring;//'支数';
    if CDSselectsub['funit']<>null then
    StringGrid1.Cells[14,i]:=CDSselectsub['funit'];//searq.fieldbyname('funit').asstring;//'单位';
    if CDSselectsub['ftype']<>null then
    StringGrid1.Cells[15,i]:=CDSselectsub['ftype'];//searq.fieldbyname('ftype').asstring;//'类型';
    end;
    GetsqlData(CDSselectsub,'Vspsub','colorno','colorno='+vartosql(adoquery1.fieldbyname('colorno').asstring),1);
    if cdsselectsub.RecordCount>0 then
    begin
    StringGrid1.Cells[11,i]:=adoquery1.fieldbyname('colorno').asstring;//'色号';CDSselectsub['colorno'] ;
    if  CDSselectsub['color']<>NULL then
    StringGrid1.Cells[12,i]:=CDSselectsub['color'];//searq.fieldbyname('color').asstring;//'颜色';
    StringGrid1.Cells[13,i]:=adoquery1.fieldbyname('gno').asstring;//CDSselectsub['gno'];//'缸号';
    StringGrid1.Cells[16,i]:=CDSselectsub['fqty'];//searq.fieldbyname('fqty').asstring;//'重量';
    StringGrid1.Cells[17,i]:=adoquery1.fieldbyname('fnote').asstring;//CDSselectsub['fnote'];//'备注';
    StringGrid1.Cells[19,i]:=adoquery1.fieldbyname('s1').asstring;//CDSselectsub['s1'];//
    StringGrid1.Cells[20,i]:=adoquery1.fieldbyname('s2').asstring;//CDSselectsub['s2'];//
    StringGrid1.Cells[21,i]:=adoquery1.fieldbyname('s3').asstring;//CDSselectsub['s3'];//
    StringGrid1.Cells[22,i]:=adoquery1.fieldbyname('s4').asstring;//CDSselectsub['s4'];//
    StringGrid1.Cells[23,i]:=adoquery1.fieldbyname('s5').asstring;//CDSselectsub['s5'];//
    StringGrid1.Cells[24,i]:=adoquery1.fieldbyname('s6').asstring;//CDSselectsub['s6'];//
    StringGrid1.Cells[25,i]:=adoquery1.fieldbyname('s7').asstring;//CDSselectsub['s7'];//
    StringGrid1.Cells[26,i]:=adoquery1.fieldbyname('s8').asstring;//CDSselectsub['s8'];//
    StringGrid1.Cells[27,i]:=adoquery1.fieldbyname('s9').asstring;//CDSselectsub['s9'];//
    StringGrid1.Cells[28,i]:=adoquery1.fieldbyname('s10').asstring;//CDSselectsub['s10'];//
    StringGrid1.Cells[29,i]:=adoquery1.fieldbyname('s11').asstring;//CDSselectsub['s11'];//
    StringGrid1.Cells[30,i]:=adoquery1.fieldbyname('s12').asstring;//CDSselectsub['s12'];//
    StringGrid1.Cells[31,i]:=adoquery1.fieldbyname('fqty').asstring;//CDSselectsub['s12'];//
    StringGrid1.Cells[32,i]:=adoquery1.fieldbyname('total').asstring;//CDSselectsub['s12'];//
    end;
    end else
    begin
    StringGrid1.Cells[0,i]:=adoquery1.fieldbyname('pno').asstring;//'批号'

    GetsqlData(CDSselectsub,'Vsp','frefno','frefno='+vartosql(adoquery1.fieldbyname('frefno').asstring),1);
    if cdsselectsub.RecordCount>0 then
    begin
    if  CDSselectsub['frefno']<>NULL then
    StringGrid1.Cells[18,i]:=CDSselectsub['frefno'];//searq.fieldbyname('fpurstore').asstring;//'货编号';
    if  CDSselectsub['fpurstore']<>NULL then
    StringGrid1.Cells[1,i]:=CDSselectsub['fpurstore'];//searq.fieldbyname('fpurstore').asstring;//'仓库';
    if CDSselectsub['fpurer']<>NULL then
    StringGrid1.Cells[2,i]:=CDSselectsub['fpurer'];//searq.fieldbyname('fpurer').asstring;//'负责人';
    if  CDSselectsub['fprovider']<>null then
    StringGrid1.Cells[3,i]:=CDSselectsub['fprovider'];//searq.fieldbyname('fprovider').asstring;//'供应商';
    if  CDSselectsub['fnote']<>null then
    StringGrid1.Cells[4,i]:=CDSselectsub['fnote'];//searq.fieldbyname('fnote').asstring;//'备注';
    if CDSselectsub['fdelivdate']<>null then
    StringGrid1.Cells[5,i]:=CDSselectsub['fdelivdate'];//searq.fieldbyname('fdelivdate').asstring;//'交货日期';
    if  CDSselectsub['fcreauser']<>null then
    StringGrid1.Cells[6,i]:=CDSselectsub['fcreauser'];//searq.fieldbyname('fcreauser').asstring;//'创建人';
    if CDSselectsub['fcreadate'] <>null then
    StringGrid1.Cells[7,i]:=CDSselectsub['fcreadate'];//searq.fieldbyname('fcreadate').asstring;//'订货日期';
    end;
///////////////////////////////////////////以上是头
    GetsqlData(CDSselectsub,'Vitem','fcode','fcode='+vartosql(adoquery1.fieldbyname('fcode').asstring),1);
    if cdsselectsub.RecordCount>0 then
    begin
    StringGrid1.Cells[8,i]:=CDSselectsub['fcode'];//searq.fieldbyname('fcode').asstring;//'物料代码';
    if CDSselectsub['fname']<>null then
    StringGrid1.Cells[9,i]:=CDSselectsub['fname'];//searq.fieldbyname('fname').asstring;//'成分';
    if CDSselectsub['zs']<>null then
    StringGrid1.Cells[10,i]:=CDSselectsub['zs'];//searq.fieldbyname('zs').asstring;//'支数';
    if CDSselectsub['funit']<>null then
    StringGrid1.Cells[14,i]:=CDSselectsub['funit'];//searq.fieldbyname('funit').asstring;//'单位';
    if CDSselectsub['ftype']<>null then
    StringGrid1.Cells[15,i]:=CDSselectsub['ftype'];//searq.fieldbyname('ftype').asstring;//'类型';
    end;
    GetsqlData(CDSselectsub,'Vspsub','colorno','colorno='+vartosql(adoquery1.fieldbyname('colorno').asstring),1);
    if cdsselectsub.RecordCount>0 then
    begin
    StringGrid1.Cells[11,i]:=adoquery1.fieldbyname('colorno').asstring;//'色号';CDSselectsub['colorno'] ;
    if  CDSselectsub['color']<>NULL then
    StringGrid1.Cells[12,i]:=CDSselectsub['color'];//searq.fieldbyname('color').asstring;//'颜色';
    StringGrid1.Cells[13,i]:=adoquery1.fieldbyname('gno').asstring;//CDSselectsub['gno'];//'缸号';
    StringGrid1.Cells[16,i]:=CDSselectsub['fqty'];//searq.fieldbyname('fqty').asstring;//'重量';
    StringGrid1.Cells[17,i]:=adoquery1.fieldbyname('fnote').asstring;//CDSselectsub['fnote'];//'备注';
    StringGrid1.Cells[19,i]:=adoquery1.fieldbyname('s1').asstring;//CDSselectsub['s1'];//
    StringGrid1.Cells[20,i]:=adoquery1.fieldbyname('s2').asstring;//CDSselectsub['s2'];//
    StringGrid1.Cells[21,i]:=adoquery1.fieldbyname('s3').asstring;//CDSselectsub['s3'];//
    StringGrid1.Cells[22,i]:=adoquery1.fieldbyname('s4').asstring;//CDSselectsub['s4'];//
    StringGrid1.Cells[23,i]:=adoquery1.fieldbyname('s5').asstring;//CDSselectsub['s5'];//
    StringGrid1.Cells[24,i]:=adoquery1.fieldbyname('s6').asstring;//CDSselectsub['s6'];//
    StringGrid1.Cells[25,i]:=adoquery1.fieldbyname('s7').asstring;//CDSselectsub['s7'];//
    StringGrid1.Cells[26,i]:=adoquery1.fieldbyname('s8').asstring;//CDSselectsub['s8'];//
    StringGrid1.Cells[27,i]:=adoquery1.fieldbyname('s9').asstring;//CDSselectsub['s9'];//
    StringGrid1.Cells[28,i]:=adoquery1.fieldbyname('s10').asstring;//CDSselectsub['s10'];//
    StringGrid1.Cells[29,i]:=adoquery1.fieldbyname('s11').asstring;//CDSselectsub['s11'];//
    StringGrid1.Cells[30,i]:=adoquery1.fieldbyname('s12').asstring;//CDSselectsub['s12'];//
    StringGrid1.Cells[31,i]:=adoquery1.fieldbyname('fqty').asstring;//CDSselectsub['s12'];//
    StringGrid1.Cells[32,i]:=adoquery1.fieldbyname('total').asstring;//CDSselectsub['s12'];//
    end;
   end;
   adoquery1.Next;
   i:=i+1;
  end;
 adoquery1.EnableControls;
end;

procedure Tfrmsprep.spbtnpriorClick(Sender: TObject);
var
  excelid, mybook: variant;
  row, col, i, j, colcount, frow: integer;
  excelflg: boolean;
  rpstr: string;
  per_count,  datasum, dsum1, dsum2: integer;
  datas1, datas2, datas3: string;
begin
  adoquery1.DisableControls;
  try
    excelid := createoleobject('excel.application');
    mybook := createoleobject('excel.sheet');
    mybook := excelid.workbooks.add;
    row := 1;
    col := 1;
    excelflg := true;
  except
    excelflg := false;
    application.MessageBox('请确定EXCEL是否正确安装!', '提示信息', mb_ok);
  end;
  if excelflg then
  begin
      colcount := adoquery1.fieldcount-1;
     // excelid.range['A' + inttostr(row), chr(64 + colcount) + inttostr(row)].merge();
      mybook.worksheets[1].cells.item[row, col] :=  '基本报表';
      mybook.worksheets[1].cells.item[row, col].font.size := 18;
      mybook.worksheets[1].cells.item[row, col].font.bold := true;
      mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
      row := row + 1;
      //excelid.range['A' + inttostr(row), chr(64 + colcount) +         inttostr(row)].merge();
      mybook.worksheets[1].cells.item[row, col] := '报表日期:' +
        datetostr(date);
      row := row + 1;
      frow := row;
      adoquery1.First;
      for i := 1 to colcount do
      begin
  ///      excelid.columns[i].ColumnWidth := stringgrid1.Columns[i - 1].Width /          8;
        excelid.columns[i].NumberFormatLocal := '@';
//        mybook.worksheets[1].cells.item[row, i] := stringgrid1[i-1,];
        mybook.worksheets[1].cells.item[row, i].HorizontalAlignment := xlcenter;
      end;
      row := row + 1;
      j:=1;
      for j:=1 to stringgrid1.RowCount do
      begin
        for i := 1 to colcount do
          mybook.worksheets[1].cells.item[row, i] := StringGrid1.Cells[i-1,j];//
        row := row + 1;
      end;
     // excelid.range['A' + inttostr(row), chr(64 + colcount) +          inttostr(row)].merge();
      mybook.worksheets[1].cells.item[row, col].font.size := 12;
      mybook.worksheets[1].cells.item[row, col].font.bold := true;
      mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
      mybook.worksheets[1].cells.item[row, col] := '总记录数:' +
       inttostr(adoquery1.RecordCount) + '条';
      row := row + 1;
      rpstr := '报表条件:';

    {  excelid.range['A' + inttostr(row), chr(64 + colcount) +
        inttostr(row)].merge();
      mybook.worksheets[1].cells.item[row, col] := rpstr;
      row := row + 1;
      excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
        - 1)].Borders[1].LineStyle := xlContinuous;
      excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
        - 1)].Borders[2].LineStyle := xlContinuous;
      excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
        - 1)].Borders[3].LineStyle := xlContinuous;
      excelid.range[chr(65) + inttostr(frow), chr(64 + colcount) + inttostr(row
        - 1)].Borders[4].LineStyle := xlContinuous; }
    excelid.visible := true;
  end;
  adoquery1.EnableControls;

end;

end.

⌨️ 快捷键说明

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