From 2e321a2a7185f43c31642dc3459d07360bcf9d50 Mon Sep 17 00:00:00 2001 From: LiJun <LiJun@192.168.10.10> Date: 星期五, 19 十月 2018 17:09:36 +0800 Subject: [PATCH] 表格数据上传 --- gx_tieta/WebRoot/Test.jsp | 39 +++++++++ gx_tieta/.settings/org.jboss.tools.jst.web.xml | 120 +++++++++++++++--------------- gx_tieta/src/com/fgkj/servlets/ExportTableServlet.java | 80 ++++++++++++++++++++ 3 files changed, 179 insertions(+), 60 deletions(-) diff --git a/gx_tieta/.settings/org.jboss.tools.jst.web.xml b/gx_tieta/.settings/org.jboss.tools.jst.web.xml index 553e94e..ab7f92f 100644 --- a/gx_tieta/.settings/org.jboss.tools.jst.web.xml +++ b/gx_tieta/.settings/org.jboss.tools.jst.web.xml @@ -8,74 +8,74 @@ <file-system NAME="lib" location="%workspace.home%/lib" model-entity="FileSystemFolder"/> <file-system NAME="classes" location="%workspace.home%/classes" model-entity="FileSystemFolder"/> <file-system NAME="fuguang" location="%eclipse.project%" model-entity="FileSystemFolder"/> - <file-system NAME="lib-c3p0-0.9.5.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\lib\c3p0-0.9.5.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-c3p0-oracle-thin-extras-0.9.5.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\lib\c3p0-oracle-thin-extras-0.9.5.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-mchange-commons-java-0.2.9.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\lib\mchange-commons-java-0.2.9.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-beanutils-1.7.0.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-beanutils-1.7.0.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-codec-1.10.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-codec-1.10.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-collections-3.1.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-collections-3.1.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-dbcp-1.2.1.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-dbcp-1.2.1.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-fileupload-1.2.2.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-fileupload-1.2.2.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-io-2.0.1.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-io-2.0.1.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-lang-2.5.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-lang-2.5.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-commons-pool-1.2.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-pool-1.2.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-dom4j-1.6.1.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-ezmorph-1.0.3.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\ezmorph-1.0.3.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-freemarker-2.3.16.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\freemarker-2.3.16.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-gson-2.2.4.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\gson-2.2.4.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-javassist-3.11.0.GA.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\javassist-3.11.0.GA.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-json-lib-2.1-jdk15.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\json-lib-2.1-jdk15.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-mysql-connector-java-5.1.33-bin.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.33-bin.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-ognl-3.0.1.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\ognl-3.0.1.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-poi-3.10.1-20140818.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\poi-3.10.1-20140818.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-sqljdbc.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\sqljdbc.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-struts2-core-2.2.3.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-core-2.2.3.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-struts2-json-plugin-2.2.3.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-json-plugin-2.2.3.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-struts2-sunspoter-stream-1.0.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-sunspoter-stream-1.0.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-xwork-core-2.2.3.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\xwork-core-2.2.3.jar" model-entity="FileSystemJar"/> - <file-system NAME="lib-jacob.jar" - location="D:\GitWorkspace\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\jacob.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-javaee.jar" - location="D:\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\javaee.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\javaee.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-jsf-impl.jar" - location="D:\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jsf-impl.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jsf-impl.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-jsf-api.jar" - location="D:\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jsf-api.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jsf-api.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-jstl-1.2.jar" - location="D:\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jstl-1.2.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\plugins\com.genuitec.eclipse.j2eedt.core_10.0.0.me201110301321\data\libraryset\EE_5\jstl-1.2.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-c3p0-0.9.5.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\lib\c3p0-0.9.5.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-c3p0-oracle-thin-extras-0.9.5.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\lib\c3p0-oracle-thin-extras-0.9.5.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-mchange-commons-java-0.2.9.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\lib\mchange-commons-java-0.2.9.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-resources.jar" - location="D:\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\resources.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\resources.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-dnsns.jar" - location="D:\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\dnsns.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\dnsns.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-localedata.jar" - location="D:\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\localedata.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\localedata.jar" model-entity="FileSystemJar"/> <file-system NAME="lib-sunjce_provider.jar" - location="D:\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\sunjce_provider.jar" model-entity="FileSystemJar"/> + location="D:\Program Files\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\jre\lib\ext\sunjce_provider.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-beanutils-1.7.0.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-beanutils-1.7.0.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-codec-1.10.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-codec-1.10.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-collections-3.1.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-collections-3.1.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-dbcp-1.2.1.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-dbcp-1.2.1.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-fileupload-1.2.2.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-fileupload-1.2.2.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-io-2.0.1.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-io-2.0.1.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-lang-2.5.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-lang-2.5.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-commons-pool-1.2.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\commons-pool-1.2.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-dom4j-1.6.1.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-ezmorph-1.0.3.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\ezmorph-1.0.3.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-freemarker-2.3.16.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\freemarker-2.3.16.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-gson-2.2.4.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\gson-2.2.4.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-javassist-3.11.0.GA.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\javassist-3.11.0.GA.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-json-lib-2.1-jdk15.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\json-lib-2.1-jdk15.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-mysql-connector-java-5.1.33-bin.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.33-bin.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-ognl-3.0.1.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\ognl-3.0.1.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-poi-3.10.1-20140818.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\poi-3.10.1-20140818.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-sqljdbc.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\sqljdbc.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-struts2-core-2.2.3.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-core-2.2.3.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-struts2-json-plugin-2.2.3.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-json-plugin-2.2.3.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-struts2-sunspoter-stream-1.0.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\struts2-sunspoter-stream-1.0.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-xwork-core-2.2.3.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\xwork-core-2.2.3.jar" model-entity="FileSystemJar"/> + <file-system NAME="lib-jacob.jar" + location="C:\Users\LiJun\git\gx_tieta\gx_tieta\WebRoot\WEB-INF\lib\jacob.jar" model-entity="FileSystemJar"/> <web SERVLET_VERSION="2.4" model-entity="JstWeb" model-path="/web.xml"> <module URI="/WEB-INF/faces-config.xml" model-entity="WebJSFModule" model-path="/faces-config.xml" src="src" web-root="WEB-ROOT"/> diff --git a/gx_tieta/WebRoot/Test.jsp b/gx_tieta/WebRoot/Test.jsp index fd5245d..639e23c 100644 --- a/gx_tieta/WebRoot/Test.jsp +++ b/gx_tieta/WebRoot/Test.jsp @@ -48,6 +48,45 @@ //console.info(json); <% } %> + + + + var param = { + dev_id:910000001, + record_datetime:'2018-01-01 00:00:00', + record_datetime_end:'2018-03-30 23:59:59', + station_event_type:0, //1:鍩虹珯鍋滅數 2:鍩虹珯缁埅 3:鍩虹珯鍙戠數 4:鍩虹珯寮�闂� 5:鍩虹珯鎺夌珯 6:鍩虹珯娓╁害涓婇檺 7:鍩虹珯娓╁害涓嬮檺 8:鍩虹珯婀垮害涓婇檺 9:鍩虹珯婀垮害涓嬮檺 + page:{ + pageSize:10, //姣忛〉鐨勮鏁� + pageCurr:1 //褰撳墠椤电爜鏁� + } + }; + searchStationHistRecord(param); + + //鏌ヨ鍩虹珯璇︽儏 + function searchStationHistRecord(param){ + // 璇锋眰鑾峰彇褰撳墠鐪佷笅鐨勫競 + $.ajax({ + type: "post", + url: "Bts_station_eventAction!serchByInfo", + async:true, + dataType:'json', + data:"json = "+JSON.stringify(param), + success: function(data){ + var rs = JSON.parse(data.result); + console.info(rs); + if(rs.code == 1) { + + }else { + + } + } + }); + } + + + + //涓婁紶logo $('#up-file1').click(function(){ uploadlogo(); diff --git a/gx_tieta/src/com/fgkj/servlets/ExportTableServlet.java b/gx_tieta/src/com/fgkj/servlets/ExportTableServlet.java index 73862cf..c255d3b 100644 --- a/gx_tieta/src/com/fgkj/servlets/ExportTableServlet.java +++ b/gx_tieta/src/com/fgkj/servlets/ExportTableServlet.java @@ -33,6 +33,9 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String pageName=req.getParameter("PageName"); + + String exp_KeyWord = req.getParameter("exp_normal"); //閫氱敤鍒板琛ㄦ牸鏍囪瘑绗� + if(ServletUtils.isNotNull(pageName)){ if("ele_statistics.jsp".equals(pageName)){ excelTitle="鐢垫睜淇℃伅缁熻鏌ヨ"; @@ -121,9 +124,86 @@ excelTitle="璁惧鐘舵�佸彉鍖栬褰曡〃"; Exporttele_eleBrdwMaintTable(resp,req); } + }else if(ServletUtils.isNotNull(exp_KeyWord)){ + if("1".equals(exp_KeyWord)){ + ExportGeneralExcelTable(resp,req); //瀵煎嚭閫氱敤鐨勮〃鏍� + } } } + private void ExportGeneralExcelTable(HttpServletResponse resp, + HttpServletRequest req) { + String exp_thead_str = req.getParameter("exp_thead"); + String exp_tbody_str = req.getParameter("exp_tbody"); + + String exp_page_break = req.getParameter("exp_page_break"); + String exp_data_break = req.getParameter("exp_data_break"); + + String exp_page_names_str = req.getParameter("exp_page_names"); + + String[] exp_page_names = new String[]{}; + + + + + + + try { + //瀹氫箟涓�涓伐浣滅翱 + HSSFWorkbook workbook = new HSSFWorkbook(); + + + if(!ServletUtils.isNotNull(exp_page_names_str)){ + return; + //exp_page_names[0] = "sheet1"; + }else{ + exp_page_names = exp_page_names_str.split(exp_page_break); //鍒嗗壊宸ヤ綔绨跨殑鍚嶇О + + String[] exp_thead_sheets = exp_thead_str.split(exp_page_break); + String[] exp_tbody_sheets = exp_tbody_str.split(exp_page_break); + + for (int i = 0; i < exp_page_names.length && exp_page_names.length >= exp_thead_sheets.length; i++) { + HSSFSheet sheet = workbook.createSheet(excelTitle); + String[] exp_thead = exp_thead_sheets[i].split(exp_data_break); + String[] exp_tbody = exp_tbody_sheets[i].split(exp_data_break); + + int maxColNum = exp_thead.length; //鏈�澶у垪鏁� + int nowRowNum = 0; //褰撳墠琛� + int nowColNum = 0; //褰撳墠鍒� + for(int j=0;j <= exp_tbody.length;j++){ + HSSFRow row = null; + if(j == 0){ + row = sheet.createRow(nowRowNum++); + for(int k=0;k<exp_thead.length;k++){ + HSSFCell cell = row.createCell(k); + HSSFRichTextString text = new HSSFRichTextString(exp_thead[k]); + //System.out.print(text+"\t"); + cell.setCellValue(text); + } + continue; + }else if(j%maxColNum == 1){ + nowColNum = 0; + row = sheet.createRow(nowRowNum++); + } + HSSFCell cell = row.createCell(nowColNum++); + HSSFRichTextString text = new HSSFRichTextString(exp_tbody[j-1]); + //System.out.print(text+"\t"); + cell.setCellValue(text); + } + } + } + // 杞爜闃叉涔辩爜 + resp.addHeader("Content-Disposition", "attachment;filename=" + + new String(excelName.getBytes("gb2312"), "ISO8859-1") + + ".xls"); + OutputStream out = resp.getOutputStream(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + private void Exporttele_eleBrdwMaintTable(HttpServletResponse resp, HttpServletRequest req) { String[] th_arr=req.getParameter("table_th_arr").split(","); -- Gitblit v1.9.1