package com.zky.manager; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; import java.text.ParseException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.jspsmart.upload.SmartFile; import com.jspsmart.upload.SmartUpload; import com.jspsmart.upload.SmartUploadException; import com.zky.pojo.PropertyInfo; import com.zky.zhyw.smtj.wltj.StatWltjManageServlet; import com.zky.zhyw.smtj.zctj.StatZctjManageServlet; public class ImportPropertywlExcelServlet extends HttpServlet { String excelFile=""; String path=""; Connection conn=null; /** * */ private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); } protected void doPost(HttpServletRequest request, HttpServletResponse response) { Login employee=(Login)request.getSession().getAttribute("login"); String operate=""; try { SmartUpload upload=new SmartUpload(); upload.initialize(this.getServletConfig(),request,response); upload.upload("UTF-8"); SmartFile smartFile=upload.getFiles().getFile(0); if(smartFile.getFileExt()!=null&&!smartFile.getFileExt().equals("")) { excelFile=upload.getFiles().getFile(0).getFilePathName(); List fileData=StatWltjManageServlet.importPropertyNetInfoData(excelFile); if(fileData.size()==0) { response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); out.print(""); out.close(); } else { StatWltjManageServlet.insertPropertyNetData(fileData, request, response); response.setContentType("text/html;charset=utf-8"); PrintWriter out=response.getWriter(); out.print(""); out.close(); } } } catch (ServletException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SmartUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }