额那应该怎么实现呢????这是我写的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;
你可以参考下: 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('无数据可保存!');
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;
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('无数据可保存!');