begin
TT.Active := true;
TT.First;
M := TStringList.Create;
Line := TT.Fields[0].DisplayName;
For i := 1 to TT.FieldCount -1 do
Line := Line + Delimiter + TT.Fields[i].DisplayLabel;
M.Add(Line);
while not TT.Eof do
begin
Line := TT.Fields[0].AsString;
For i := 1 to TT.FieldCount -1 do
Line := Line + Delimiter + StringReplace(StringReplace(TT.Fields[i].AsString,
#13#10,' ',[rfReplaceAll]),#9,' ',[rfReplaceAll]) ;
M.Add(Line);
TT.Next;
end;
M.SaveToFile('newfile');end;
TT.Active := true;
TT.First;
M := TStringList.Create;
Line := TT.Fields[0].DisplayName;
For i := 1 to TT.FieldCount -1 do
Line := Line + Delimiter + TT.Fields[i].DisplayLabel;
M.Add(Line);
while not TT.Eof do
begin
Line := TT.Fields[0].AsString;
For i := 1 to TT.FieldCount -1 do
Line := Line + Delimiter + StringReplace(StringReplace(TT.Fields[i].AsString,
#13#10,' ',[rfReplaceAll]),#9,' ',[rfReplaceAll]) ;
M.Add(Line);
TT.Next;
end;
M.SaveToFile('newfile');end;
再网上找找怎样控制Excel的方法
TABLE中数据-->EXCEL?
ExcelApp.ActiveWorkBook.Saved 本人 测试过,可用.
利用函數
SaveDBGridEhToExportFile(TDBGridEhExportAsXLS,dbgrideh2,'flename.xls',true);