// 导入sql文件到数据库 public String dbImport() { if (!myFile.exists()) { return ERROR; } manageDataService.dbImport(myFile); return SUCCESS; }
// 产品成本表导入 public String proImport() throws Exception { if (!myFile.exists()) { return ERROR; } String result = manageDataService.proImport(myFile); return result; }
// 数据库导出为sql文件 public String dbExport() throws Exception { Calendar now = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); String fileName = "backup--" + format.format(now.getTime()); response.setContentType("text/x-sql"); response.addHeader("Content-Disposition", "attachment; filename=" + fileName + ".sql"); OutputStream os = response.getOutputStream(); manageDataService.dbEport(os); return null; }
// 表格导出为excel文件 public String tableExport() throws Exception { request.setCharacterEncoding("GBK"); title = request.getParameter("title"); content = request.getParameter("content"); if (content.isEmpty()) { return ERROR; } response.setContentType("application/ms-excel"); response.addHeader( "Content-Disposition", "attachment; filename=" + new String(title.getBytes("gb2312"), "ISO8859-1") + ".xls"); OutputStream os = response.getOutputStream(); manageDataService.tableExport(os, title, content); System.out.println("end"); return null; }