首页 > 代码库 > 导出数据为Excel文件---Controller
导出数据为Excel文件---Controller
@Controller @RequestMapping("/vehmileage") public class VehMileageController extends BaseController{ private static final Logger LOG=Logger.getLogger(VehMileageController.class); private static final String FILE_NAME="里程导出"; private static final String FILE_TAIL=".csv"; private static final String SHEET_NAME="里程数据"; private static final String HEADER_NAME="车牌号,所属机构,总里程,阶段里程"; private static final String DATE_TYPE="DAY"; @RequestMapping(value="/index",method=RequestMethod.GET) public @ResponseBody ModelAndView index(){ LOG.info("Inside mileageManagement Page"); ModelAndView mv=new ModelAndView("Transportation/mileageManagement"); return mv; } @RequestMapping(value="/export",method=RequestMethod.GET,produces="text/html;charset=UTF-8") public void exportVehMileage(HttpServletRequest request,HttpServletResponse response){ LOG.info("Inside mileageManagement"); ExportVehMileageModel EVMModel =new ExportVehMileageModel(); EVMModel.setUser(getCurrentUser()); EVMModel.setVehiclePlate(request.getParameter("vehiclePlate")); EVMModel.setInstatutionId(request.getParameter("instatutionId")); EVMModel.setTimeLowBound(request.getParameter("timeLowBound")); EVMModel.setTimeUpBound(request.getParameter("timeUpBound")); EVMModel.setFileName(request.getParameter("fileName")); EVMModel.setSheetName(request.getParameter("sheetName")); EVMModel.setLicensePlate(request.getParameter("licensePlate")); EVMModel.setOrganition(request.getParameter("organition")); EVMModel.setTotalmileage(request.getParameter("totalmileage")); EVMModel.setPhasemileage(request.getParameter("phasemileage")); try{ ExportVehMileageClient client=(ExportVehMileageClient)getWSClient(GET_EXPORTVEHMILEAGE_CLIENT); List<String> data=http://www.mamicode.com/client.export(EVMModel); ExportVehMileagesClient client2=(ExportVehMileagesClient)getWSClient(GET_EXPORTVEHMILEAGES_CLIENT); List<VehicleModel> vehicles=client2.export(EVMModel); String vehiclePlate=request.getParameter("vehiclePlate") String instatutionId=request.getParameter("instatutionId") String timeLowBound=request.getParameter("timeLowBound") String timeUpBound=request.getParameter("timeUpBound") SimpleDateFormat sdf=new SimpleDateFormat(EtruckContants.DATE_FORMAT_Y); SimpleDateFormat ddf=new SimpleDateFormat(EtruckContants.DATE_FORMAT_Y); if(instatutionId==null || "".equals(instatutionId)){ instatutionId=getCurrentUser().getInstatutionId().toString(); } StringTokenizer st=new StringTokenizer(vehiclePlate,","); ArrayList<String> vehiclePlates=new ArrayList<>(); while(st.hasMoreElements()){ String vpn=(String)st.nextElement(); } }catch (Exception e) { // TODO: handle exception } } }
导出数据为Excel文件---Controller
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。