List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet createRow
@Override public HSSFRow createRow(int rownum)
From source file:citibob.reports.PoiXlsWriter.java
License:Open Source License
/** @param row0 example row to copy when inserting... Don't do fixup between xrow0 and xrow1, non-inclusive. */ public void insertRowsFixup(HSSFSheet sheet, int rowIx, int n, int row0Ix, int xcol0, int xcol1, int xrow0, int xrow1) { sheet.shiftRows(rowIx, sheet.getLastRowNum(), n, true, true); HSSFRow row0 = sheet.getRow(row0Ix + n); if (row0 != null) { for (int r = rowIx; r < rowIx + n; ++r) { HSSFRow row1 = sheet.createRow(r); copyRow(row0, row1, xcol0, xcol1); }/*from www. j ava2 s . co m*/ } fixupFormulas(sheet, rowIx, n, xrow0, xrow1); }
From source file:citibob.reports.PoiXlsWriter.java
License:Open Source License
/** @returns net number of rows inserted */ int replaceOneHolder(HSSFSheet sheet, int row, int col, TableModel mod) { int n = mod.getRowCount(); // Set up proper number of rows insertRowsFixup(sheet, row, n, row, col, col + mod.getColumnCount(), row, row + mod.getRowCount()); HSSFRow r0 = sheet.getRow(row + n); // Our model row // Fill in the data, iterating through the model... for (int r = 0; r < mod.getRowCount(); ++r) { //System.out.println("r=" + r); HSSFRow r2 = sheet.getRow(row + r); if (r2 == null) r2 = sheet.createRow(row + r); for (int c = 0; c < mod.getColumnCount(); ++c) { //System.out.println(" c=" + c); HSSFCell c2 = r2.getCell((short) (col + c)); if (c2 == null) c2 = r2.createCell((short) (col + c)); Object val = mod.getValueAt(r, c); setValue(c2, val); }// w w w . j a v a 2s.c o m } deleteRowsFixup(sheet, row + n, 1, 0, 0); return n - 1; }
From source file:Clavis.Windows.WShedule.java
public void createXLSDocument(String nome, String[][] valores) { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(nome); HSSFRow row;//w w w. j a va 2 s . co m HSSFCell cell; for (int i = 0; i < valores.length; i++) { row = sheet.createRow(i); for (int j = 0; j < valores[i].length; j++) { cell = row.createCell(j); cell.setCellValue(valores[i][j]); if (valores[i][j] != null) { sheet.setColumnWidth(j, 255 * valores[i][j].length() + 4); CellUtil.setAlignment(cell, wb, CellStyle.ALIGN_CENTER); } } } wb.setPrintArea(0, 0, valores[0].length, 0, valores.length); sheet.getPrintSetup().setPaperSize(XSSFPrintSetup.A4_PAPERSIZE); FileOutputStream out; String sfile = new File("").getAbsolutePath() + System.getProperty("file.separator") + nome; File file = new File(sfile); if (!file.exists()) { try { file.createNewFile(); } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } if (file.canWrite()) { try { out = new FileOutputStream(file); } catch (FileNotFoundException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); out = null; } if (out != null) { try { wb.write(out); out.close(); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(file); } else { Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, painelcor, lingua.translate("Nota"), 400, 200, lingua.translate("O documento \"doc.xls\" foi criado na pasta raiz do programa") + ".", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); } } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:cn.edu.henu.rjxy.lms.controller.Acdemic.java
@RequestMapping("daochuxuesheng") public void daochuxuesheng(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); session.setAttribute("state", null); // ???? // ww w . j ava 2 s. c o m response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "student_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue("qq"); cell.setCellStyle(style); List allstudent = StudentDao.getAllStudent(); for (int i = 0; i < allstudent.size(); i++) { StudentWithoutPwd tmp = (StudentWithoutPwd) allstudent.get(i); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(tmp.getStudentSn()); row.createCell((short) 1).setCellValue(tmp.getStudentName()); row.createCell((short) 2).setCellValue(tmp.getStudentIdcard()); row.createCell((short) 3).setCellValue(tmp.getStudentGrade()); row.createCell((short) 4).setCellValue((tmp.isStudentSex()) ? ("") : ("")); row.createCell((short) 5).setCellValue(tmp.getStudentCollege()); row.createCell((short) 6).setCellValue(tmp.getStudentTel()); row.createCell((short) 7).setCellValue(tmp.getStudentQq()); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); }
From source file:cn.edu.henu.rjxy.lms.controller.Acdemic.java
@RequestMapping("daochualltoxls") public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); System.out.println("1..."); session.setAttribute("state", null); // ???? // www .j ava 2 s. c o m response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "teacher_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue("qq"); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue(""); cell.setCellStyle(style); List allteacher = TeacherDao.getAllTeacher(); for (int i = 0; i < allteacher.size(); i++) { TempTeacherWithoutPwd tmp = (TempTeacherWithoutPwd) allteacher.get(i); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(tmp.getTeacherSn()); row.createCell((short) 1).setCellValue(tmp.getTeacherName()); row.createCell((short) 2).setCellValue(tmp.getTeacherIdcard()); row.createCell((short) 3).setCellValue(tmp.getTeacherPosition()); row.createCell((short) 4).setCellValue(tmp.getTeacherCollege()); row.createCell((short) 5).setCellValue(tmp.getTeacherQq()); row.createCell((short) 6).setCellValue(tmp.getTeacherTel()); row.createCell((short) 7).setCellValue((tmp.getTeacherSex()) ? ("") : ("")); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); }
From source file:cn.edu.henu.rjxy.lms.controller.DeanController.java
@RequestMapping("dean/daochuxuesheng") public void daochuxuesheng(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); session.setAttribute("state", null); // ???? /*from w ww . ja va 2s . com*/ response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "student_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue("qq"); cell.setCellStyle(style); List allstudent = StudentDao.getAllStudent(); for (int i = 0; i < allstudent.size(); i++) { StudentWithoutPwd tmp = (StudentWithoutPwd) allstudent.get(i); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(tmp.getStudentSn()); row.createCell((short) 1).setCellValue(tmp.getStudentName()); row.createCell((short) 2).setCellValue(tmp.getStudentIdcard()); row.createCell((short) 3).setCellValue(tmp.getStudentGrade()); row.createCell((short) 4).setCellValue((tmp.isStudentSex()) ? ("") : ("")); row.createCell((short) 5).setCellValue(tmp.getStudentCollege()); row.createCell((short) 6).setCellValue(tmp.getStudentTel()); row.createCell((short) 7).setCellValue(tmp.getStudentQq()); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); }
From source file:cn.edu.henu.rjxy.lms.controller.DeanController.java
@RequestMapping("dean/daochualltoxls") public void exportExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(); System.out.println("1..."); session.setAttribute("state", null); // ???? /*w ww . j av a 2 s . c om*/ response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "teacher_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue("qq"); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue(""); cell.setCellStyle(style); List allteacher = TeacherDao.getAllTeacher(); for (int i = 0; i < allteacher.size(); i++) { TempTeacherWithoutPwd tmp = (TempTeacherWithoutPwd) allteacher.get(i); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(tmp.getTeacherSn()); row.createCell((short) 1).setCellValue(tmp.getTeacherName()); row.createCell((short) 2).setCellValue(tmp.getTeacherIdcard()); row.createCell((short) 3).setCellValue(tmp.getTeacherPosition()); row.createCell((short) 4).setCellValue(tmp.getTeacherCollege()); row.createCell((short) 5).setCellValue(tmp.getTeacherQq()); row.createCell((short) 6).setCellValue(tmp.getTeacherTel()); row.createCell((short) 7).setCellValue((tmp.getTeacherSex()) ? ("") : ("")); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); }
From source file:cn.edu.henu.rjxy.lms.controller.TeaController.java
@RequestMapping("teacher/xz_xs_xx") public @ResponseBody String daochuxuesheng(HttpServletRequest request, HttpServletResponse response) throws IOException { int classid = Integer.parseInt(request.getParameter("zjd_id")); int course_id = Integer.parseInt(request.getParameter("fjd_id")); int term = Integer.parseInt(request.getParameter("term")); String sn = getCurrentUsername(); Teacher tec = TeacherDao.getTeacherBySn(sn); int tec_id = tec.getTeacherId(); int trem_courseid = TermCourseDao.getTermCourseId(term, course_id, classid, tec_id); System.out.println(trem_courseid + "trem_courseid"); PageBean<StuSelectResult> mystudent = TeacherDao.getStuSelectByTermCourseId(trem_courseid, 1, 300); HttpSession session = request.getSession(); session.setAttribute("state", null); // ???? /*from w w w .ja v a 2 s .com*/ response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "student_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue("qq"); cell.setCellStyle(style); for (int i = 0; i < mystudent.getBeanList().size(); i++) { StuSelectResult a = (StuSelectResult) mystudent.getBeanList().get(i); System.out.println(getStudentById(a.getStuid()).getStudentSn()); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(getStudentById(a.getStuid()).getStudentSn()); row.createCell((short) 1).setCellValue(getStudentById(a.getStuid()).getStudentName()); row.createCell((short) 2).setCellValue(getStudentById(a.getStuid()).getStudentIdcard()); row.createCell((short) 3).setCellValue(getStudentById(a.getStuid()).getStudentGrade()); row.createCell((short) 4) .setCellValue((getStudentById(a.getStuid()).getStudentSex()) ? ("") : ("")); row.createCell((short) 5).setCellValue(getStudentById(a.getStuid()).getStudentCollege()); row.createCell((short) 6).setCellValue(getStudentById(a.getStuid()).getStudentTel()); row.createCell((short) 7).setCellValue(getStudentById(a.getStuid()).getStudentQq()); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); return "1"; }
From source file:cn.edu.henu.rjxy.lms.controller.Tea_Controller.java
@RequestMapping("xz_xs_xx") public @ResponseBody String daochuxuesheng(HttpServletRequest request, HttpServletResponse response) throws IOException { int classid = Integer.parseInt(request.getParameter("zjd_id")); int course_id = Integer.parseInt(request.getParameter("fjd_id")); int term = Integer.parseInt(request.getParameter("term")); String sn = getCurrentUsername(); Teacher tec = TeacherDao.getTeacherBySn(sn); int tec_id = tec.getTeacherId(); int trem_courseid = TermCourseDao.getTermCourseId(term, course_id, classid, tec_id); System.out.println(trem_courseid + "trem_courseid"); PageBean<StuSelectResult> mystudent = TeacherDao.getStuSelectByTermCourseId(trem_courseid, 1, 300); HttpSession session = request.getSession(); session.setAttribute("state", null); // ???? /*from w w w . j a v a 2 s . c o m*/ response.setContentType("application/vnd.ms-excel"); String codedFileName; codedFileName = "??"; OutputStream fOut = null; try { // ???? codedFileName = java.net.URLEncoder.encode("", "UTF-8"); response.setHeader("content-disposition", "attachment;filename=" + "student_messsage" + ".xls"); HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet(""); // sheet0,??poiExcel?short HSSFRow row = sheet.createRow((int) 0); // ? HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // ? HSSFCell cell = row.createCell((short) 0); cell.setCellValue("?"); cell.setCellStyle(style); 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); cell = row.createCell((short) 5); cell.setCellValue(""); cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue("qq"); cell.setCellStyle(style); for (int i = 0; i < mystudent.getBeanList().size(); i++) { StuSelectResult a = (StuSelectResult) mystudent.getBeanList().get(i); System.out.println(getStudentById(a.getStuid()).getStudentSn()); row = sheet.createRow((int) i + 1); row.createCell((short) 0).setCellValue(getStudentById(a.getStuid()).getStudentSn()); row.createCell((short) 1).setCellValue(getStudentById(a.getStuid()).getStudentName()); row.createCell((short) 2).setCellValue(getStudentById(a.getStuid()).getStudentIdcard()); row.createCell((short) 3).setCellValue(getStudentById(a.getStuid()).getStudentGrade()); row.createCell((short) 4) .setCellValue((getStudentById(a.getStuid()).getStudentSex()) ? ("") : ("")); row.createCell((short) 5).setCellValue(getStudentById(a.getStuid()).getStudentCollege()); row.createCell((short) 6).setCellValue(getStudentById(a.getStuid()).getStudentTel()); row.createCell((short) 7).setCellValue(getStudentById(a.getStuid()).getStudentQq()); } fOut = response.getOutputStream(); wb.write(fOut); } catch (UnsupportedEncodingException e1) { } catch (Exception e) { } finally { fOut.flush(); fOut.close(); session.setAttribute("state", "open"); } System.out.println("?..."); return "1"; }
From source file:cn.edu.zju.acm.onlinejudge.action.ShowRankListAction.java
License:Open Source License
private byte[] exportToExcel(AbstractContest contest, List<Problem> problems, RankList ranklist) throws Exception { List<RankListEntry> entries = ranklist.getEntries(); long time = this.getTimeEscaped(contest); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(); HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell((short) 0); cell.setCellValue(contest.getTitle()); if (ranklist.getRole() != null) { row = sheet.createRow(1);//from w ww .j a va 2s . co m cell = row.createCell((short) 0); cell.setEncoding(HSSFCell.ENCODING_UTF_16); cell.setCellValue(ranklist.getRole().getDescription()); } row = sheet.createRow(2); cell = row.createCell((short) 0); cell.setCellValue("Length"); cell = row.createCell((short) 1); cell.setCellValue(Utility.toTime(contest.getLength() / 1000)); row = sheet.createRow(3); cell = row.createCell((short) 0); cell.setCellValue("Time Escaped"); cell = row.createCell((short) 1); cell.setCellValue(Utility.toTime(time / 1000)); row = sheet.createRow(5); row.createCell((short) 0).setCellValue("Rank"); row.createCell((short) 1).setCellValue("Handle"); row.createCell((short) 2).setCellValue("Nickname"); row.createCell((short) 3).setCellValue("Solved"); short columnIndex = 4; for (Problem problem2 : problems) { Problem problem = problem2; row.createCell(columnIndex).setCellValue(problem.getCode()); columnIndex++; } row.createCell(columnIndex).setCellValue("Penalty"); int rowIndex = 6; for (RankListEntry rankListEntry : entries) { RankListEntry entry = rankListEntry; row = sheet.createRow(rowIndex); row.createCell((short) 0).setCellValue(rowIndex - 5); row.createCell((short) 1).setCellValue(entry.getUserProfile().getHandle()); String nick = entry.getUserProfile().getHandle(); if (entry.getUserProfile().getNickName() != null) { nick = entry.getUserProfile().getNickName(); } cell = row.createCell((short) 2); cell.setEncoding(HSSFCell.ENCODING_UTF_16); cell.setCellValue(nick); row.createCell((short) 3).setCellValue(entry.getSolved()); for (short i = 0; i < problems.size(); ++i) { String score = entry.getAcceptTime(i) > 0 ? entry.getAcceptTime(i) + "(" + entry.getSubmitNumber(i) + ")" : "" + entry.getSubmitNumber(i); row.createCell((short) (4 + i)).setCellValue(score); } row.createCell((short) (4 + problems.size())).setCellValue(entry.getPenalty()); rowIndex++; } // output to stream ByteArrayOutputStream out = new ByteArrayOutputStream(); try { wb.write(out); return out.toByteArray(); } finally { out.close(); } }