List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook write
private void write(POIFSFileSystem fs) throws IOException
From source file:com.work.fileHandle.fileHandleServlet.java
public HSSFWorkbook createExcel() { HSSFWorkbook webbook = new HSSFWorkbook(); HSSFSheet sheet = webbook.createSheet("?"); HSSFRow row = sheet.createRow((int) 0); HSSFCellStyle style = webbook.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style);/*from w ww. ja va2 s . c om*/ cell = row.createCell((short) 1); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell((short) 2); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell((short) 3); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell((short) 4); cell.setCellValue("?"); cell.setCellStyle(style); List students = query(); for (int i = 0; i < students.size(); i++) { row = sheet.createRow((int) i + 1); Student student = (Student) students.get(i); row.createCell((short) 0).setCellValue(student.getStudentId().toString()); row.createCell((short) 1).setCellValue(student.getStudentCode()); row.createCell((short) 2).setCellValue(student.getEnName()); row.createCell((short) 3).setCellValue(student.getCnName()); row.createCell((short) 4).setCellValue(student.getGrade()); } try { String savePath = this.getServletContext().getRealPath("/WEB-INF/uploads"); String filename = "students-grade.xls"; File file = new File(savePath); if (!file.exists() && !file.isDirectory()) { System.out.println(savePath + "??"); file.mkdir(); } FileOutputStream fout = new FileOutputStream(savePath + "/" + filename); webbook.write(fout); fout.close(); } catch (Exception e) { e.printStackTrace(); } return webbook; }
From source file:com.xnradmin.core.test.TestJson.java
private static void processYsmcExcel(String res) throws JSONException, org.json.JSONException { JSONObject jo = new JSONObject(res); Iterator it = jo.keys();//from w w w . j a va 2 s. c om HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("ysmc"); HSSFRow row = sheet.createRow((int) 0); HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell(0); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell(1); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell(2); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell(3); cell.setCellValue("??"); cell.setCellStyle(style); cell = row.createCell(4); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell(5); cell.setCellValue("?2"); cell.setCellStyle(style); cell = row.createCell(6); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell(7); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell(8); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell(9); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell(10); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell(11); int flag = 0; while (it.hasNext()) { String k = it.next().toString(); // System.out.println(jo.get(k)); flag = processYsmcSubLevel1(k, jo.get(k).toString(), wb, sheet, row, flag); } FileOutputStream fout; try { fout = new FileOutputStream("/Users/liubin/temp/ysmc" + StringHelper.getSystime("yyyyMMdd") + ".xls"); wb.write(fout); fout.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeZhjyqqExcel(List<Map> zhjyqqList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet = wk.createSheet("zhjyqq"); // /* w w w .j a v a2 s.c o m*/ HSSFRow firstRow = sheet.createRow(0); int totalColNum = 27; //? HSSFCell[] firstCell = new HSSFCell[totalColNum]; //??string String[] colNames = new String[totalColNum]; colNames[0] = "?"; colNames[1] = "?"; colNames[2] = "???"; colNames[3] = "??"; colNames[4] = "?"; colNames[5] = ""; colNames[6] = ""; colNames[7] = ""; colNames[8] = "?"; colNames[9] = "??"; colNames[10] = "??"; colNames[11] = "?/?"; colNames[12] = ""; colNames[13] = "?"; colNames[14] = "?"; colNames[15] = ""; colNames[16] = ""; colNames[17] = ""; colNames[18] = "?"; colNames[19] = "??"; colNames[20] = "??"; colNames[21] = "???"; colNames[22] = "???"; colNames[23] = "??"; colNames[24] = "???"; colNames[25] = "????"; colNames[26] = "????"; //?? for (int i = 0; i < totalColNum; i++) { //? firstCell[i] = firstRow.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell[i].setCellValue(new HSSFRichTextString(colNames[i])); } //???excel //j1 ?rs int j = 1; //? DataValidation data_validation = null; for (Map m : zhjyqqList) { // HSSFRow row = sheet.createRow(j); for (int i = 0; i < totalColNum; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m.get("TXCODE"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m.get("MESSAGEFROM"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m.get("TRANSSERIALNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASENUMBER"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASETYPE"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString( "02".equals(((String) m.get("EMERGENCYLEVEL"))) ? "" : "")); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m.get("SUBJECTTYPE"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKID"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKNAME"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTNAME"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m.get("CARDNUMBER"))); } if (i == 12) { String str = (String) m.get("INQUIRYMODE"); String INQUIRYMODE = ""; if ("01".equals(str)) { INQUIRYMODE = "?"; } else if ("02".equals(str)) { INQUIRYMODE = ""; } else if ("03".equals(str)) { INQUIRYMODE = "?+"; } else { INQUIRYMODE = ""; } cell.setCellValue(new HSSFRichTextString(INQUIRYMODE)); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m.get("INQUIRYPERIODSTART"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m.get("INQUIRYPERIODEND"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m.get("REASON"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m.get("REMARK"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONTIME"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGID"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGNAME"))); } if (i == 20) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDTYPE"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDNUMBER"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORNAME"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORPHONENUMBER"))); } if (i == 24) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDTYPE"))); } if (i == 25) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDNUMBER"))); } if (i == 26) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORNAME"))); } } // j++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeZhjyjgExcel(List<Map> zhxxList, List<Map> jymxList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet1 = wk.createSheet("zhxx"); HSSFSheet sheet2 = wk.createSheet("jymx"); // //from w w w . java 2 s .c o m HSSFRow firstRow1 = sheet1.createRow(0); HSSFRow firstRow2 = sheet2.createRow(0); int totalColNum1 = 40; int totalColNum2 = 31; //? HSSFCell[] firstCell1 = new HSSFCell[totalColNum1]; HSSFCell[] firstCell2 = new HSSFCell[totalColNum2]; //??string String[] colNames1 = new String[totalColNum1]; colNames1[0] = "?"; colNames1[1] = "ID"; colNames1[2] = "?"; colNames1[3] = "??"; colNames1[4] = "??"; colNames1[5] = ""; colNames1[6] = ""; colNames1[7] = "?"; colNames1[8] = ""; colNames1[9] = ""; colNames1[10] = ""; colNames1[11] = ""; colNames1[12] = "??"; colNames1[13] = "(?)??"; colNames1[14] = "(?)"; colNames1[15] = "?"; colNames1[16] = "??"; colNames1[17] = ""; colNames1[18] = "?"; colNames1[19] = "??"; colNames1[20] = "?"; colNames1[21] = "??"; colNames1[22] = "???"; colNames1[23] = "??"; colNames1[24] = "?"; colNames1[25] = "?/???"; colNames1[26] = "?/??"; colNames1[27] = "?/????"; colNames1[28] = "??"; colNames1[29] = "??"; colNames1[30] = "??"; colNames1[31] = "???"; colNames1[32] = "???"; colNames1[33] = "?"; colNames1[34] = ""; colNames1[35] = "?"; colNames1[36] = "???"; colNames1[37] = "??"; colNames1[38] = "?"; colNames1[39] = "?"; String[] colNames2 = new String[totalColNum2]; colNames2[0] = "?"; colNames2[1] = ""; colNames2[2] = "??"; colNames2[3] = ""; colNames2[4] = ""; colNames2[5] = "?"; colNames2[6] = "??"; colNames2[7] = ""; colNames2[8] = "?"; colNames2[9] = "??"; colNames2[10] = "??"; colNames2[11] = "???"; colNames2[12] = "??"; colNames2[13] = "?"; colNames2[14] = "?"; colNames2[15] = "?"; colNames2[16] = "??"; colNames2[17] = "?"; colNames2[18] = "?"; colNames2[19] = "??"; colNames2[20] = "??"; colNames2[21] = "?"; colNames2[22] = ""; colNames2[23] = "?"; colNames2[24] = "??"; colNames2[25] = "?"; colNames2[26] = "??"; colNames2[27] = "MAC?"; colNames2[28] = "IP?"; colNames2[29] = ""; colNames2[30] = "?"; //?? for (int i = 0; i < totalColNum1; i++) { //? firstCell1[i] = firstRow1.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell1[i].setCellValue(new HSSFRichTextString(colNames1[i])); } //?? for (int i = 0; i < totalColNum2; i++) { //? firstCell2[i] = firstRow2.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell2[i].setCellValue(new HSSFRichTextString(colNames2[i])); } //???excel //j1 ?rs int j = 1; for (Map m1 : zhxxList) { // HSSFRow row = sheet1.createRow(j); for (int i = 0; i < totalColNum1; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m1.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m1.get("JSJG"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m1.get("TXCODE"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m1.get("TRANSSERIALNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTNAME"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CARDNUMBER"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString((String) m1.get("DEPOSITBANKBRANCH"))); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m1.get("DEPOSITBANKBRANCHCODE"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTOPENTIME"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCANCELLATIONTIME"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCANCELLATIONBRANCH"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m1.get("REMARK"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTNUMBER"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTSERIAL"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTTYPE"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTSTATUS"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CURRENCY"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CASHREMIT"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTBALANCE"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m1.get("AVAILABLEBALANCE"))); } if (i == 20) { cell.setCellValue(new HSSFRichTextString((String) m1.get("LASTTRANSACTIONTIME"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCREDENTIALTYPE"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCREDENTIALNUMBER"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTSUBJECTNAME"))); } if (i == 24) { cell.setCellValue(new HSSFRichTextString((String) m1.get("TELNUMBER"))); } if (i == 25) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CARDOPERATORNAME"))); } if (i == 26) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CARDOPERATORCREDENTIALTYPE"))); } if (i == 27) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CARDOPERATORCREDENTIALNUMBER"))); } if (i == 28) { cell.setCellValue(new HSSFRichTextString((String) m1.get("RESIDENTADDRESS"))); } if (i == 29) { cell.setCellValue(new HSSFRichTextString((String) m1.get("RESIDENTTELNUMBER"))); } if (i == 30) { cell.setCellValue(new HSSFRichTextString((String) m1.get("WORKCOMPANYNAME"))); } if (i == 31) { cell.setCellValue(new HSSFRichTextString((String) m1.get("WORKADDRESS"))); } if (i == 32) { cell.setCellValue(new HSSFRichTextString((String) m1.get("WORKTELNUMBER"))); } if (i == 33) { cell.setCellValue(new HSSFRichTextString((String) m1.get("EMAILADDRESS"))); } if (i == 34) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ARTIFICIALPERSONREP"))); } if (i == 35) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ARTIFICIALPERSONREPCREDENTIALTYPE"))); } if (i == 36) { cell.setCellValue( new HSSFRichTextString((String) m1.get("ARTIFICIALPERSONREPCREDENTIALNUMBER"))); } if (i == 37) { cell.setCellValue(new HSSFRichTextString((String) m1.get("BUSINESSLICENSENUMBER"))); } if (i == 38) { cell.setCellValue(new HSSFRichTextString((String) m1.get("STATETAXSERIAL"))); } if (i == 39) { cell.setCellValue(new HSSFRichTextString((String) m1.get("LOCALTAXSERIAL"))); } } // j++; } int k = 1; for (Map m2 : jymxList) { // HSSFRow row = sheet2.createRow(k); for (int i = 0; i < totalColNum2; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m2.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m2.get("CARDNUMBER"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSSERIALNUMBER"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m2.get("BORROWINGSIGNS"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONTYPE"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONAMOUNT"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString((String) m2.get("CURRENCY"))); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONTIME"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m2.get("ACCOUNTBALANCE"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m2.get("OPPONENTNAME"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONSERIAL"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m2.get("OPPONENTCREDENTIALNUMBER"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m2.get("OPPONENTACCOUNTNUMBER"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONREMARK"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m2.get("OPPONENTDEPOSITBANKID"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONBRANCHCODE"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONBRANCHNAME"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m2.get("SUMMONSNUMBER"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m2.get("LOGNUMBER"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m2.get("VOUCHERCODE"))); } if (i == 20) { cell.setCellValue(new HSSFRichTextString((String) m2.get("VOUCHERTYPE"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TERMINALNUMBER"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m2.get("CASHMARK"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONADDRESS"))); } if (i == 24) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TRANSACTIONSTATUS"))); } if (i == 25) { cell.setCellValue(new HSSFRichTextString((String) m2.get("MERCHANTCODE"))); } if (i == 26) { cell.setCellValue(new HSSFRichTextString((String) m2.get("MERCHANTNAME"))); } if (i == 27) { cell.setCellValue(new HSSFRichTextString((String) m2.get("MAC"))); } if (i == 28) { cell.setCellValue(new HSSFRichTextString((String) m2.get("IPADDRESS"))); } if (i == 29) { cell.setCellValue(new HSSFRichTextString((String) m2.get("REMARK"))); } if (i == 30) { cell.setCellValue(new HSSFRichTextString((String) m2.get("TELLERCODE"))); } } // k++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeCkztqqExcel(List<Map> ckztqqList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet = wk.createSheet("ckztqq"); // //w w w. j a va 2s.c om HSSFRow firstRow = sheet.createRow(0); int totalColNum = 24; //? HSSFCell[] firstCell = new HSSFCell[totalColNum]; //??string String[] colNames = new String[totalColNum]; colNames[0] = "?"; colNames[1] = "?"; colNames[2] = "???"; colNames[3] = "??"; colNames[4] = "?"; colNames[5] = ""; colNames[6] = ""; colNames[7] = ""; colNames[8] = "?"; colNames[9] = "??"; colNames[10] = "??"; colNames[11] = "?/?"; colNames[12] = ""; colNames[13] = ""; colNames[14] = ""; colNames[15] = "?"; colNames[16] = "??"; colNames[17] = "??"; colNames[18] = "???"; colNames[19] = "???"; colNames[20] = "??"; colNames[21] = "???"; colNames[22] = "????"; colNames[23] = "????"; //?? for (int i = 0; i < totalColNum; i++) { //? firstCell[i] = firstRow.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell[i].setCellValue(new HSSFRichTextString(colNames[i])); } //???excel //j1 ?rs int j = 1; for (Map m : ckztqqList) { // HSSFRow row = sheet.createRow(j); for (int i = 0; i < totalColNum; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m.get("TXCODE"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m.get("MESSAGEFROM"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m.get("TRANSSERIALNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASENUMBER"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASETYPE"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString( "02".equals(((String) m.get("EMERGENCYLEVEL"))) ? "" : "")); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m.get("SUBJECTTYPE"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKID"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKNAME"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTNAME"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m.get("CARDNUMBER"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m.get("REMARK"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m.get("REASON"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONTIME"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGID"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGNAME"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDTYPE"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDNUMBER"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORNAME"))); } if (i == 20) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORPHONENUMBER"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDTYPE"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDNUMBER"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORNAME"))); } } // j++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeCkztjgExcel(List<Map> ckztjgList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet = wk.createSheet("ckztjg"); // // w ww . j a v a2 s .com HSSFRow firstRow = sheet.createRow(0); int totalColNum = 24; //? HSSFCell[] firstCell = new HSSFCell[totalColNum]; //??string String[] colNames = new String[totalColNum]; colNames[0] = "??"; colNames[1] = "????"; colNames[2] = "ID"; colNames[3] = "?"; colNames[4] = "???"; colNames[5] = "?"; colNames[6] = "?"; colNames[7] = "??"; colNames[8] = "?/??"; colNames[9] = "??"; colNames[10] = "??"; colNames[11] = "?/???"; colNames[12] = "??"; colNames[13] = "?/????"; colNames[14] = "???"; colNames[15] = "??"; colNames[16] = "?"; colNames[17] = "???"; colNames[18] = ""; colNames[19] = "?"; colNames[20] = "???"; colNames[21] = "??"; colNames[22] = "?"; colNames[23] = "?"; //?? for (int i = 0; i < totalColNum; i++) { //? firstCell[i] = firstRow.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell[i].setCellValue(new HSSFRichTextString(colNames[i])); } //???excel //j1 ?rs int j = 1; for (Map m : ckztjgList) { // HSSFRow row = sheet.createRow(j); for (int i = 0; i < totalColNum; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m.get("TRANSSERIALNUMBER"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m.get("NEWTRANSSERIALNUMBER"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m.get("JSJG"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m.get("TXCODE"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTCREDENTIALNUMBER"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONID"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString((String) m.get("TELNUMBER"))); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTCREDENTIALTYPE"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m.get("CARDOPERATORCREDENTIALTYPE"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTSUBJECTNAME"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m.get("RESIDENTADDRESS"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m.get("CARDOPERATORNAME"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m.get("WORKCOMPANYNAME"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m.get("CARDOPERATORCREDENTIALNUMBER"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m.get("WORKTELNUMBER"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m.get("RESIDENTTELNUMBER"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m.get("EMAILADDRESS"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m.get("WORKADDRESS"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m.get("ARTIFICIALPERSONREP"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m.get("ARTIFICIALPERSONREPCREDENTIALTYPE"))); } if (i == 20) { cell.setCellValue( new HSSFRichTextString((String) m.get("ARTIFICIALPERSONREPCREDENTIALNUMBER"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m.get("BUSINESSLICENSENUMBER"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m.get("STATETAXSERIAL"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m.get("LOCALTAXSERIAL"))); } } // j++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeQzhqqExcel(List<Map> qzhqqList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet = wk.createSheet("qzhqq"); // /*ww w . j ava 2s . co m*/ HSSFRow firstRow = sheet.createRow(0); int totalColNum = 27; //? HSSFCell[] firstCell = new HSSFCell[totalColNum]; //??string String[] colNames = new String[totalColNum]; colNames[0] = "?"; colNames[1] = "?"; colNames[2] = "???"; colNames[3] = "??"; colNames[4] = "?"; colNames[5] = ""; colNames[6] = ""; colNames[7] = "??"; colNames[8] = "?"; colNames[9] = ""; colNames[10] = "??"; colNames[11] = "???"; colNames[12] = "??"; colNames[13] = ""; colNames[14] = ""; colNames[15] = ""; colNames[16] = ""; colNames[17] = "?"; colNames[18] = "??"; colNames[19] = "??"; colNames[20] = "???"; colNames[21] = "???"; colNames[22] = "??"; colNames[23] = "???"; colNames[24] = "????"; colNames[25] = "????"; //?? for (int i = 0; i < totalColNum; i++) { //? firstCell[i] = firstRow.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell[i].setCellValue(new HSSFRichTextString(colNames[i])); } //???excel //j1 ?rs int j = 1; for (Map m : qzhqqList) { // HSSFRow row = sheet.createRow(j); for (int i = 0; i < totalColNum; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m.get("TXCODE"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m.get("MESSAGEFROM"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m.get("TRANSSERIALNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASENUMBER"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m.get("CASETYPE"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString( "02".equals(((String) m.get("EMERGENCYLEVEL"))) ? "" : "")); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKNAME"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m.get("BANKID"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString( "2".equals(((String) m.get("SUBJECTTYPE"))) ? "" : "")); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTCREDENTIALTYPE"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTCREDENTIALNUMBER"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m.get("ACCOUNTSUBJECTNAME"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString( "02".equals(((String) m.get("INQUIRYMODE"))) ? "?" : "?")); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m.get("REASON"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m.get("REMARK"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONTIME"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGID"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m.get("APPLICATIONORGNAME"))); } if (i == 19) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDTYPE"))); } if (i == 20) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORIDNUMBER"))); } if (i == 21) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORNAME"))); } if (i == 22) { cell.setCellValue(new HSSFRichTextString((String) m.get("OPERATORPHONENUMBER"))); } if (i == 23) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDTYPE"))); } if (i == 24) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORNAME"))); } if (i == 25) { cell.setCellValue(new HSSFRichTextString((String) m.get("INVESTIGATORIDNUMBER"))); } } // j++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yitong.app.service.judicial.dxzpjymx.JymxService.java
public File makeQzhjgExcel(List<Map> qzhzhxxList, List<Map> qzhdjList, String filePath) throws IOException { HSSFWorkbook wk = new HSSFWorkbook(); HSSFSheet sheet1 = wk.createSheet("zhxx"); HSSFSheet sheet2 = wk.createSheet("djxx"); // /*from w w w . j a v a2 s . c om*/ HSSFRow firstRow1 = sheet1.createRow(0); HSSFRow firstRow2 = sheet2.createRow(0); int totalColNum1 = 40; int totalColNum2 = 31; //? HSSFCell[] firstCell1 = new HSSFCell[totalColNum1]; HSSFCell[] firstCell2 = new HSSFCell[totalColNum2]; //??string String[] colNames1 = new String[totalColNum1]; colNames1[0] = "??"; colNames1[1] = "????"; colNames1[2] = "??"; colNames1[3] = ""; colNames1[4] = ""; colNames1[5] = "?"; colNames1[6] = ""; colNames1[7] = ""; colNames1[8] = ""; colNames1[9] = ""; colNames1[10] = "??"; colNames1[11] = "(?)??"; colNames1[12] = "(?)"; colNames1[13] = "?"; colNames1[14] = "??"; colNames1[15] = ""; colNames1[16] = "?"; colNames1[17] = "??"; colNames1[18] = "?"; String[] colNames2 = new String[totalColNum2]; colNames2[0] = "?"; colNames2[1] = "???? "; colNames2[2] = "??"; colNames2[3] = "?"; colNames2[4] = "??"; colNames2[5] = ""; colNames2[6] = ""; colNames2[7] = "??"; colNames2[8] = "??"; colNames2[9] = "?"; colNames2[10] = ""; //?? for (int i = 0; i < totalColNum1; i++) { //? firstCell1[i] = firstRow1.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell1[i].setCellValue(new HSSFRichTextString(colNames1[i])); } //?? for (int i = 0; i < totalColNum2; i++) { //? firstCell2[i] = firstRow2.createCell(i); //? ?? new HSSFRichTextString(colNames[i]) ? firstCell2[i].setCellValue(new HSSFRichTextString(colNames2[i])); } //???excel //j1 ?rs int j = 1; for (Map m1 : qzhzhxxList) { // HSSFRow row = sheet1.createRow(j); for (int i = 0; i < totalColNum1; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m1.get("TRANSSERIALNUMBER"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m1.get("NEWTRANSSERIALNUMBER"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTNAME"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CARDNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m1.get("DEPOSITBANKBRANCH"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m1.get("DEPOSITBANKBRANCHCODE"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTOPENTIME"))); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCANCELLATIONTIME"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTCANCELLATIONBRANCH"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m1.get("REMARK"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTNUMBER"))); } if (i == 11) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTSERIAL"))); } if (i == 12) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTTYPE"))); } if (i == 13) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTSTATUS"))); } if (i == 14) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CURRENCY"))); } if (i == 15) { cell.setCellValue(new HSSFRichTextString((String) m1.get("CASHREMIT"))); } if (i == 16) { cell.setCellValue(new HSSFRichTextString((String) m1.get("ACCOUNTBALANCE"))); } if (i == 17) { cell.setCellValue(new HSSFRichTextString((String) m1.get("AVAILABLEBALANCE"))); } if (i == 18) { cell.setCellValue(new HSSFRichTextString((String) m1.get("LASTTRANSACTIONTIME"))); } } // j++; } int k = 1; for (Map m2 : qzhdjList) { // HSSFRow row = sheet2.createRow(k); for (int i = 0; i < totalColNum2; i++) { //?? HSSFCell cell = row.createCell(i); //? ?new HSSFRichTextString()?? //rs.getString(i+1)1?? if (i == 0) { cell.setCellValue(new HSSFRichTextString((String) m2.get("APPLICATIONID"))); } if (i == 1) { cell.setCellValue(new HSSFRichTextString((String) m2.get("NEWTRANSSERIALNUMBER"))); } if (i == 2) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZESERIAL"))); } if (i == 3) { cell.setCellValue(new HSSFRichTextString((String) m2.get("ACCOUNTNUMBER"))); } if (i == 4) { cell.setCellValue(new HSSFRichTextString((String) m2.get("CARDNUMBER"))); } if (i == 5) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZESTARTTIME"))); } if (i == 6) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZEENDTIME"))); } if (i == 7) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZEDEPTNAME"))); } if (i == 8) { cell.setCellValue(new HSSFRichTextString((String) m2.get("CURRENCY"))); } if (i == 9) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZEBALANCE"))); } if (i == 10) { cell.setCellValue(new HSSFRichTextString((String) m2.get("FREEZETYPE"))); } } // k++; } //? OutputStream out = new FileOutputStream(filePath); //?excel? wk.write(out); //? out.close(); return new File(filePath); }
From source file:com.yyl.common.utils.excel.ExcelTools.java
public static void writeToXLS(ExcelRow heads, ExcelData data, String sheetName, ByteArrayOutputStream out) throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet1 = wb.createSheet(sheetName); HSSFRow row = sheet1.createRow(0);//from www . jav a2s.co m HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCell cell; for (int i = 0; i < heads.size(); i++) { cell = row.createCell(i); cell.setCellValue(heads.get(i)); cell.setCellStyle(style); } if (data != null && data.size() != 0) { for (int n = 0; n < data.size(); n++) { row = sheet1.createRow(n + 1); ExcelRow datarow = data.get(n); for (int m = 0; m < datarow.size(); m++) { cell = row.createCell(m); cell.setCellValue(datarow.get(m)); cell.setCellStyle(style); } } } wb.write(out); }
From source file:com.zb.app.common.interceptor.ExportFileAnnotationInterceptor.java
License:Open Source License
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if (handler == null || response == null) { return;/* w ww.j a v a2 s . c o m*/ } HandlerMethod hm = (HandlerMethod) handler; ExportWordFile exportWordFile = hm.getMethodAnnotation(ExportWordFile.class); // word, if (exportWordFile != null) { String wordName = exportWordFile.value(); if (StringUtils.isEmpty(wordName)) { return; } wordName = new String(wordName.getBytes(), "ISO8859-1"); String contentDis = "attachment;filename=" + wordName + ".doc"; response.setHeader("content-disposition", contentDis); response.setContentType("application/msword;"); response.setCharacterEncoding("UTF-8"); } ExportExcelFile exportExcelFile = hm.getMethodAnnotation(ExportExcelFile.class); // excel, if (exportExcelFile != null) { String xlsName = exportExcelFile.value(); if (StringUtils.isEmpty(xlsName)) { return; } xlsName = new String(xlsName.getBytes(), "UTF-8"); List<?> list = (List<?>) modelAndView.getModel().get("list"); String[] head = (String[]) modelAndView.getModel().get("head"); modelAndView.clear(); HSSFWorkbook workbook = ExcelUtils.defBuildExcel(list, xlsName, head); if (workbook == null) { try { response.getOutputStream().print("Not conform to the requirements of data"); } catch (IOException e) { logger.error(e.getMessage(), e); } return; } response.setHeader("content-disposition", "attachment;filename=" + xlsName + ".xls"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("UTF-8"); // response OutputStream os = response.getOutputStream(); workbook.write(os); os.flush(); os.close(); } }