我要做个报表,现在想实现pos('??',s);想查找S中是否有??  再在这列对应的下的数字输入进去,现在是不知道怎么把excel中的整行内同赋值给s。   比如excel A1 B1 C1 D1的内容赋值给s,在从s中寻找有没有??,B1里有,那pos(‘??’,s)=B1这行(2,1),那我要在他下面加内容只要(2,1+1)就好了。

解决方案 »

  1.   

    额那应该怎么实现呢????这是我写的for n := 1 to 80 do
            begin
              s := EjunDataGrid1.Cells[n,1].AsString;{这边就是循环提取,现在我要这边一次全赋值给S}
              index := Pos(node2.Attributes['CH'],s);
              if index <> 0 then
              begin
               EjunDataGrid1.Cells[n,m+1].Value := node2.Attributes['Result1'];
               EjunDataGrid1.Cells[n+1,m+1].value := node2.attributes['Result2'];
               EjunDataGrid1.Cells[n+2,m+1].Value := node2.Attributes['Point'];
               EjunDataGrid1.Cells[n+3,m+1].Value := node2.Attributes['Value'];
    //           Break;
              end;
            end;
      

  2.   

    你可以参考下:    empty := EmptyParam;
        ExcelApplication1.Workbooks.Add(empty,0);
        ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks.Item[
                                             ExcelApplication1.Workbooks.Count]);
        ExcelWorkBook1.Activate ;
        ExcelWorksheet1.ConnectTo((ExcelWorkbook1.Worksheets[1] as _WorkSheet));
        for  j:=1 to ADOQuery1.RecordCount do
        begin
          for i:=1 to ADOQuery1.fields.Count  do
          begin
            excelworksheet1.Cells.Item[j,i]:=trim(ADOQuery1.fields[i-1].AsString)+#9;//
          end;
          ADOQuery1.Next;
        end;
      except
        ExcelWorkBook1.Close(xlDoNotSaveChanges);
        ExcelApplication1.Disconnect;
      end;
     end else showmessage('无数据可保存!');