Dlgsave: = Tsavedialog.Create(Nil); Dlgsave.filter:='csv file |*. CSV'; Dlgsave.defaultext:='*. CSV'; Dlgsave.filename:='service. CSV'; ifDlgsave.execute Then begin ifFileExists (Dlgsave.filename) Then Try ifMessagedlg ('the file already exists, do you want to overwrite it? ', Mtinformation, [Mbyes, Mbno],0) =Idyes ThenDeleteFile (PChar (dlgsave.filename))Else beginExit; End; exceptExit; End; FileName:=Dlgsave.filename; Savecurpage (filename); End; SList:= Tstringlist.Create; Slist.add ('id,***,***,***,***,***,***,***'); forI: =0 toGrdvehiclelist.rowcount-1 Do beginSlist.add (grdvehiclelist.cell[0, I]. Asstring+','+Grdvehiclelist.cell[comno_index,i]. Asstring+','+Grdvehiclelist.cell[vno_index, I]. Asstring+','+Grdvehiclelist.cell[regcolor_index, I]. Asstring+','+Grdvehiclelist.cell[groupid_index, I]. Asstring+','+Grdvehiclelist.cell[terminal_type_index, I]. Asstring+','+Grdvehiclelist.cell[service_end_date_index, I]. Asstring+','+Grdvehiclelist.cell[remind_index, I]. asstring); End; Slist.savetofile (path);
Save the CSV file via Tstringlist, just loop. Each row in the Add table is recorded and saved