标签:
dlgSave := TSaveDialog.Create(nil); dlgSave.filter := ‘CSV文件|*.CSV‘; dlgSave.DefaultExt := ‘*.CSV‘; dlgSave.filename := ‘服务.CSV‘; if dlgSave.Execute then begin if FileExists(dlgSave.filename) then try if MessageDlg(‘该文件已经存在,要覆盖吗?‘, mtInformation, [mbYes, mbNo], 0) = IDYES then DeleteFile(PChar(dlgSave.filename)) else begin Exit; end; except Exit; end; filename := dlgSave.filename; SaveCurPage(filename); end; sList := TStringList.Create; sList.Add(‘ID,***,***,***,***,***,***,***‘); for i := 0 to grdVehicleList.RowCount - 1 do begin sList.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);
通过TStringList保存csv文件,只要循环.Add表格里面的每行记录进去,保存即可
标签:
原文地址:http://www.cnblogs.com/rogge7/p/4973652.html