procedure TERP_CreateExcelForm.setdatatoexcel;
var
i,row,column,j,m:integer;
CanInsert:Boolean;
fieldname:string;
begin
//Astrings保存各字段的字段名
//Cstrings保存各字段显示时候的中文列名称
for i := 1 to Cstrings.Count do
begin
ExcelWorksheet1.Cells.Item[1,i] :=
Astrings.Names[strtoint(Cstrings.Strings[i-1])]
end;
row:=2;
for m := 1 to cdsshow.RecordCount do
begin
cdsshow.RecNo := m;
Column:=1;
if Cstrings.Count > 0 then
for j := 0 to Cstrings.Count-1 do
begin
FieldName:=
Astrings.ValueFromIndex[strtoint(Cstrings.Strings[j])];
if FieldName<>'' then
begin
ExcelWorksheet1.Cells.Item[row,column]:=cdsshow.fieldbyname(FieldName).AsString;
Column:=Column+1;
end
else
begin
ExcelWorksheet1.Cells.Item[row,column]:=IntToStr(cdsshow.RecNo);
Column:=Column+1;
end;
end;
row:=row+1;
end;
end;