IDS export.jsp

  1. <%@pagecontentType="text/html;charset=GBK"errorPage="/error.jsp"%>
  2. <jsp:useBeanid="idmServer"scope="application"class="com.***.idm.IdentityServer"/>
  3. <%--//checks.jsp包括登录校验、idmServer/loginUrl/checkUserName变量声明、服务器是否启动、登录用户是否有超级管理员权限--%>
  4. <%@pageimport="java.util.List"%>
  5. <%@pageimport="com.***.idm.model.service.UIService"%>
  6. <%@pageimport="com.***.idm.data.bo.User"%>
  7. <%@pageimport="org.apache.poi.hssf.usermodel.*"%>
  8. <%@pageimport="com.***.idm.data.service.SearchFilter"%>
  9. <%@pageimport="java.io.*"%>
  10. <%@pageimport="java.util.Date"%>
  11. <%
  12. String_total=request.getParameter("total");//取得记录总数
  13. intint_total=Integer.parseInt(_total);
  14. try{
  15. HSSFWorkbookhssfworkbook=newHSSFWorkbook();
  16. HSSFSheethssfsheet=hssfworkbook.createSheet();//创建sheet页
  17. hssfworkbook.setSheetName(0,"用户列表",HSSFWorkbook.ENCODING_UTF_16);//sheet名称乱码处理
  18. HSSFRowhssfrow=hssfsheet.createRow(0);//创建表头
  19. HSSFCellhssfcell_title_0=hssfrow.createCell((short)0);//创建第一个单元格
  20. hssfcell_title_0.setEncoding(HSSFWorkbook.ENCODING_UTF_16);//处理乱码
  21. hssfcell_title_0.setCellValue("用户名");//对第一个单元格赋值
  22. HSSFCellhssfcell_title_1=hssfrow.createCell((short)1);//创建第二个单元格子
  23. hssfcell_title_1.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  24. hssfcell_title_1.setCellValue("昵称");
  25. HSSFCellhssfcell_title_2=hssfrow.createCell((short)2);
  26. hssfcell_title_2.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  27. hssfcell_title_2.setCellValue("真名");
  28. HSSFCellhssfcell_title_3=hssfrow.createCell((short)3);
  29. hssfcell_title_3.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  30. hssfcell_title_3.setCellValue("电子邮件");
  31. HSSFCellhssfcell_title_4=hssfrow.createCell((short)4);
  32. hssfcell_title_4.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  33. hssfcell_title_4.setCellValue("身份证号");
  34. HSSFCellhssfcell_title_5=hssfrow.createCell((short)5);
  35. hssfcell_title_5.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  36. hssfcell_title_5.setCellValue("所属组织");
  37. HSSFCellhssfcell_title_6=hssfrow.createCell((short)6);
  38. hssfcell_title_6.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  39. hssfcell_title_6.setCellValue("是否开通");
  40. HSSFCellhssfcell_title_7=hssfrow.createCell((short)7);
  41. hssfcell_title_7.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  42. hssfcell_title_7.setCellValue("电话");
  43. HSSFCellhssfcell_title_8=hssfrow.createCell((short)8);
  44. hssfcell_title_8.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  45. hssfcell_title_8.setCellValue("手机");
  46. HSSFCellhssfcell_title_9=hssfrow.createCell((short)9);
  47. hssfcell_title_9.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  48. hssfcell_title_9.setCellValue("说明");
  49. booleancdn=false;
  50. SearchFiltersf=newSearchFilter();
  51. if(true){
  52. sf.addCondition("''","''","''");//查询条件(全部查出)
  53. cdn=true;
  54. }
  55. Listusers=null;
  56. if(cdn==true){
  57. try{
  58. users=idmServer.getModelService().getUserManager().findByFilter(sf);//取得全部记录
  59. }catch(Exceptione){
  60. e.printStackTrace();
  61. }
  62. }
  63. System.out.println("已导出数据"+users.size()+"条!");
  64. //if(users!=null&&users.size()>0){
  65. //out.print("true");
  66. //}else{
  67. //out.print("false");
  68. //}
  69. for(inti=1;i<=int_total;i++){
  70. Useruser=(User)users.get(i-1);
  71. //创建sheet新行
  72. HSSFRowhssfrow_Name=hssfsheet.createRow(i);
  73. //依次创建单元格,写入数据
  74. HSSFCellhssfcell_0=hssfrow_Name.createCell((short)0);
  75. hssfcell_0.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  76. hssfcell_0.setCellValue(user.getUserName());
  77. HSSFCellhssfcell_1=hssfrow_Name.createCell((short)1);
  78. hssfcell_1.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  79. hssfcell_1.setCellValue(user.getNickName());
  80. HSSFCellhssfcell_2=hssfrow_Name.createCell((short)2);
  81. hssfcell_2.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  82. hssfcell_2.setCellValue(user.getTrueName());
  83. HSSFCellhssfcell_3=hssfrow_Name.createCell((short)3);
  84. hssfcell_3.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  85. hssfcell_3.setCellValue(user.getEmail());
  86. HSSFCellhssfcell_4=hssfrow_Name.createCell((short)4);
  87. hssfcell_4.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  88. hssfcell_4.setCellValue(user.getCreditID());
  89. HSSFCellhssfcell_5=hssfrow_Name.createCell((short)5);
  90. hssfcell_5.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  91. hssfcell_5.setCellValue(user.getGroupName());
  92. HSSFCellhssfcell_6=hssfrow_Name.createCell((short)6);
  93. hssfcell_6.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  94. hssfcell_6.setCellValue(user.isActived());
  95. HSSFCellhssfcell_7=hssfrow_Name.createCell((short)7);
  96. hssfcell_7.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  97. hssfcell_7.setCellValue(user.getTel());
  98. HSSFCellhssfcell_8=hssfrow_Name.createCell((short)8);
  99. hssfcell_8.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  100. hssfcell_8.setCellValue(user.getMobile());
  101. HSSFCellhssfcell_9=hssfrow_Name.createCell((short)9);
  102. hssfcell_9.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
  103. hssfcell_9.setCellValue(user.getDesc());
  104. }
  105. //HSSFCellStylehssfcellstyle=hssfworkbook.createCellStyle();//日期单元格格式处理
  106. //hssfcellstyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"));//m/d/yyh:mm
  107. FileOutputStreamfileoutputstream=newFileOutputStream("D:\\用户数据\\用户列表.xls");
  108. hssfworkbook.write(fileoutputstream);
  109. fileoutputstream.close();
  110. }catch(IOExceptione){
  111. e.printStackTrace();
  112. }catch(Exceptione){
  113. e.printStackTrace();
  114. }
  115. %>
  116. <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
  117. <html>
  118. <head>
  119. <title>***身份服务器***IDS</title>
  120. <linkhref="../style/style.css"type="text/css"rel=stylesheet>
  121. <linkhref="../style/listStyle.css"type="text/css"rel=stylesheet>
  122. <styletype=text/css>body{
  123. margin:5px
  124. }
  125. </style>
  126. <metahttp-equiv="pragma"content="no-cache">
  127. <metahttp-equiv="cache-control"content="no-cache">
  128. <metahttp-equiv="expires"content="0">
  129. <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
  130. <metahttp-equiv="description"content="Thisismypage">
  131. <!--
  132. <linkrel="stylesheet"type="text/css"href="styles.css">
  133. -->
  134. </head>
  135. <body>
  136. <br>
  137. 数据已全部导出!<br>
  138. 存放路径:D:\用户数据\用户列表.xls<br>
  139. <inputtype="button"value="返回"onClick="history.go(-1);">
  140. </body>
  141. </html>

你可能感兴趣的:(apache,html,jsp,css,cache)