List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet createRow
@Override public HSSFRow createRow(int rownum)
From source file:com.dayuan.action.BusinessLoanAction.java
/** * excel/*from w ww. j a v a 2 s.co m*/ * * */ @RequestMapping("/exportExcel") public void exportExcel(Integer id, HttpServletRequest request, HttpServletResponse response) throws Exception { if (id == null || id.equals("")) { log.error("?"); return; } BusLoanInfo busLoanInfo = this.busLoanInfoService.queryById(id); if (busLoanInfo == null) { log.error("busLoanInfo?"); return; } Integer bid = busLoanInfo.getId(); if (bid == null) { log.error("busLoanInfo?"); return; } BusLoanInfoLegal busLoanInfoLegal = this.busLoanInfoLegalService.getBusLoanInfoLegal(bid); BusLoanInfoShop busLoanInfoShop = this.busLoanInfoShopService.getBusLoanInfoShop(bid); // webbookExcel 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("??"); //applicationName cell.setCellStyle(style); cell = row.createCell((short) 2); cell.setCellValue("?");//urgentCont cell.setCellStyle(style); cell = row.createCell((short) 3); cell.setCellValue(""); // relationship cell.setCellStyle(style); cell = row.createCell((short) 4); cell.setCellValue("?"); //legalPhone cell.setCellStyle(style); cell = row.createCell((short) 5); cell.setCellValue("?"); //houseAddress cell.setCellStyle(style); cell = row.createCell((short) 6); cell.setCellValue("?"); //companyName cell.setCellStyle(style); cell = row.createCell((short) 7); cell.setCellValue("?");// ?platformName cell.setCellStyle(style); cell = row.createCell((short) 8); cell.setCellValue(""); //?shopName cell.setCellStyle(style); cell = row.createCell((short) 9); cell.setCellValue("???"); //?,subAccount cell.setCellStyle(style); cell = row.createCell((short) 10); cell.setCellValue("?"); //?,sbuPassword cell.setCellStyle(style); // ? ?? try { row = sheet.createRow((int) 0 + 1); row.createCell((short) 0).setCellValue(1); row.createCell((short) 1).setCellValue(StringUtil.getNotNullStr(busLoanInfo.getApplicationName())); row.createCell((short) 2).setCellValue(StringUtil.getNotNullStr(busLoanInfo.getUrgentCont())); row.createCell((short) 3).setCellValue(StringUtil.getNotNullStr(busLoanInfo.getRelationship())); if (busLoanInfoLegal != null) { row.createCell((short) 4).setCellValue(StringUtil.getNotNullStr(busLoanInfoLegal.getLegalPhone())); row.createCell((short) 5) .setCellValue(StringUtil.getNotNullStr(busLoanInfoLegal.getHouseAddress())); row.createCell((short) 6).setCellValue(StringUtil.getNotNullStr(busLoanInfoLegal.getCompanyName())); } else { row.createCell((short) 4).setCellValue(""); row.createCell((short) 5).setCellValue(""); row.createCell((short) 6).setCellValue(""); } if (busLoanInfoShop != null) { row.createCell((short) 7).setCellValue(StringUtil.getNotNullStr(busLoanInfoShop.getPlatformName())); row.createCell((short) 8).setCellValue(StringUtil.getNotNullStr(busLoanInfoShop.getShopName())); row.createCell((short) 9).setCellValue(StringUtil.getNotNullStr(busLoanInfoShop.getSubAccount())); row.createCell((short) 10).setCellValue(StringUtil.getNotNullStr(busLoanInfoShop.getSbuPassword())); } else { row.createCell((short) 7).setCellValue(""); row.createCell((short) 8).setCellValue(""); row.createCell((short) 9).setCellValue(""); row.createCell((short) 10).setCellValue(""); } // Student stu = (Student) list.get(i); // ? // cell = row.createCell((short) 3); // cell.setCellValue(new SimpleDateFormat("yyyy-mm-dd").format(stu.getBirth())); // row.createCell((short) 10).setCellValue(busLoanInfoShop.getSbuPassword());? String savePath = request.getSession().getServletContext().getRealPath( File.separator + "WEB-INF" + File.separator + "downloads" + File.separator + "excelfiles");//??,?? savePath = savePath + File.separator + UUID.randomUUID();//? File fileSavePath = new File(savePath); /**??*/ if (fileSavePath.exists()) { if (fileSavePath.isDirectory()) { File[] files = fileSavePath.listFiles(); for (File file : files) { file.delete(); } fileSavePath.delete(); } else { fileSavePath.delete(); } fileSavePath.mkdirs(); } else { fileSavePath.mkdirs(); } String excel = "????" + DateUtil.getNowPlusTimeMill() + ".xls";//eccel?? BufferedOutputStream fout = new BufferedOutputStream( new FileOutputStream(savePath + File.separator + excel)); // wb.write(fout); //excel? fout.flush(); fout.close(); //MIME response.setContentType(request.getSession().getServletContext().getMimeType(excel)); //Content-Disposition response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(excel, "UTF-8")); //,io? BufferedInputStream in = new BufferedInputStream( new FileInputStream(savePath + File.separator + excel)); OutputStream out = new BufferedOutputStream(response.getOutputStream()); byte buffer[] = new byte[1024]; int len = 0; while ((len = in.read(buffer)) > 0) { out.write(buffer, 0, len);//?response? } in.close(); out.flush(); out.close(); /***/ File file = new File(savePath + File.separator + excel); if (file != null) { if (file.exists()) { file.delete();// } file = null; } /***/ if (fileSavePath != null) { if (fileSavePath.exists()) { fileSavePath.delete(); } fileSavePath = null; } log.info("???excel?"); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.dp2345.ExcelView.java
License:Open Source License
/** * ?Excel//w w w . j a v a 2s . c o m * * @param model * ? * @param workbook * workbook * @param request * request * @param response * response */ public void buildExcelDocument(Map<String, Object> model, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { Assert.notEmpty(properties); HSSFSheet sheet; if (StringUtils.isNotEmpty(sheetName)) { sheet = workbook.createSheet(sheetName); } else { sheet = workbook.createSheet(); } int rowNumber = 0; if (titles != null && titles.length > 0) { HSSFRow header = sheet.createRow(rowNumber); header.setHeight((short) 400); for (int i = 0; i < properties.length; i++) { HSSFCell cell = header.createCell(i); HSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setFillForegroundColor(HSSFColor.LIGHT_CORNFLOWER_BLUE.index); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); HSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 11); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); cellStyle.setFont(font); cell.setCellStyle(cellStyle); if (i == 0) { HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFComment comment = patriarch .createComment(new HSSFClientAnchor(0, 0, 0, 0, (short) 1, 1, (short) 4, 4)); comment.setString(new HSSFRichTextString("P" + "o" + "w" + "e" + "r" + "e" + "d" + " " + "B" + "y" + " " + "D" + "P" + "2" + "3" + "4" + "5")); cell.setCellComment(comment); } if (titles.length > i && titles[i] != null) { cell.setCellValue(titles[i]); } else { cell.setCellValue(properties[i]); } if (widths != null && widths.length > i && widths[i] != null) { sheet.setColumnWidth(i, widths[i]); } else { sheet.autoSizeColumn(i); } } rowNumber++; } if (data != null) { for (Object item : data) { HSSFRow row = sheet.createRow(rowNumber); for (int i = 0; i < properties.length; i++) { HSSFCell cell = row.createCell(i); if (converters != null && converters.length > i && converters[i] != null) { Class<?> clazz = PropertyUtils.getPropertyType(item, properties[i]); ConvertUtils.register(converters[i], clazz); cell.setCellValue(BeanUtils.getProperty(item, properties[i])); ConvertUtils.deregister(clazz); if (clazz.equals(Date.class)) { DateConverter dateConverter = new DateConverter(); dateConverter.setPattern(DEFAULT_DATE_PATTERN); ConvertUtils.register(dateConverter, Date.class); } } else { cell.setCellValue(BeanUtils.getProperty(item, properties[i])); } if (rowNumber == 0 || rowNumber == 1) { if (widths != null && widths.length > i && widths[i] != null) { sheet.setColumnWidth(i, widths[i]); } else { sheet.autoSizeColumn(i); } } } rowNumber++; } } if (contents != null && contents.length > 0) { rowNumber++; for (String content : contents) { HSSFRow row = sheet.createRow(rowNumber); HSSFCell cell = row.createCell(0); HSSFCellStyle cellStyle = workbook.createCellStyle(); HSSFFont font = workbook.createFont(); font.setColor(HSSFColor.GREY_50_PERCENT.index); cellStyle.setFont(font); cell.setCellStyle(cellStyle); cell.setCellValue(content); rowNumber++; } } response.setContentType("application/force-download"); if (StringUtils.isNotEmpty(filename)) { response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8")); } else { response.setHeader("Content-disposition", "attachment"); } }
From source file:com.dv.util.DVExcelIO.java
License:Open Source License
public static boolean exportIntoExcel(String fullExcelFileName, String sheetName, Vector cols, Vector rows) { boolean isExportFine = true; HSSFWorkbook hsswb = null;/*from w ww . j a va 2 s . c o m*/ HSSFSheet hsssh = null; HSSFRow row = null; try { File excel = new File(fullExcelFileName); if (!excel.exists()) { hsswb = new HSSFWorkbook(); hsssh = hsswb.createSheet(sheetName); hsssh.setDefaultRowHeight((short) 10); hsssh.setDefaultColumnWidth(20); } else { hsswb = new HSSFWorkbook(new FileInputStream(excel)); hsssh = hsswb.createSheet(sheetName); hsssh.setDefaultRowHeight((short) 10); hsssh.setDefaultColumnWidth(20); } row = hsssh.createRow((short) 2); HSSFCellStyle style = hsswb.createCellStyle(); style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBottomBorderColor(HSSFColor.BLACK.index); style.setLeftBorderColor(HSSFColor.BLACK.index); style.setTopBorderColor(HSSFColor.BLACK.index); style.setRightBorderColor(HSSFColor.BLACK.index); for (int i = 0; i < cols.size(); i++) { HSSFCell cell = row.createCell(i); cell.setCellValue(cols.get(i).toString()); cell.setCellStyle(style); } HSSFCellStyle style1 = hsswb.createCellStyle(); style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); style1.setBorderLeft(HSSFCellStyle.BORDER_THIN); style1.setBorderRight(HSSFCellStyle.BORDER_THIN); style1.setBorderTop(HSSFCellStyle.BORDER_THIN); style1.setBottomBorderColor(HSSFColor.BLACK.index); style1.setLeftBorderColor(HSSFColor.BLACK.index); style1.setTopBorderColor(HSSFColor.BLACK.index); style1.setRightBorderColor(HSSFColor.BLACK.index); for (int i = 3; i <= rows.size() + 2; i++) { row = hsssh.createRow((short) i); for (int j = 0; j < cols.size(); j++) { HSSFCell cell = row.createCell(j); cell.setCellValue(((Vector) rows.elementAt(i - 3)).get(j).toString()); cell.setCellStyle(style1); } } FileOutputStream fOut = new FileOutputStream(excel); hsswb.write(fOut); fOut.flush(); fOut.close(); } catch (IOException e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } catch (IllegalArgumentException e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } catch (Exception e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } return isExportFine; }
From source file:com.dv.util.DVExcelIO.java
License:Open Source License
public static boolean exportBatchResultIntoExcel(String fullExcelFileName, String sheetName, HashMap<String, Vector> colsMap, HashMap<String, Vector> rowsMap) { HSSFWorkbook hsswb = null;//from w w w. j a v a 2 s. co m HSSFSheet hsssh = null; HSSFRow row = null; Vector cols = new Vector(); Vector rows = new Vector(); try { File excel = new File(fullExcelFileName); if (!excel.exists()) { hsswb = new HSSFWorkbook(); hsssh = hsswb.createSheet(sheetName); hsssh.setDefaultRowHeight((short) 10); hsssh.setDefaultColumnWidth(20); } else { hsswb = new HSSFWorkbook(new FileInputStream(excel)); hsssh = hsswb.createSheet(sheetName); hsssh.setDefaultRowHeight((short) 10); hsssh.setDefaultColumnWidth(20); } int rowCount = 1; for (int k = 0; k < colsMap.size(); k++) { cols = colsMap.get(String.valueOf(k)); rows = rowsMap.get(String.valueOf(k)); rowCount = rowCount + 1; row = hsssh.createRow((short) (rowCount)); HSSFCellStyle style = hsswb.createCellStyle(); style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBottomBorderColor(HSSFColor.BLACK.index); style.setLeftBorderColor(HSSFColor.BLACK.index); style.setTopBorderColor(HSSFColor.BLACK.index); style.setRightBorderColor(HSSFColor.BLACK.index); for (int i = 0; i < cols.size(); i++) { HSSFCell cell = row.createCell(i); cell.setCellValue(cols.get(i).toString()); cell.setCellStyle(style); } HSSFCellStyle style1 = hsswb.createCellStyle(); style1.setBorderBottom(HSSFCellStyle.BORDER_THIN); style1.setBorderLeft(HSSFCellStyle.BORDER_THIN); style1.setBorderRight(HSSFCellStyle.BORDER_THIN); style1.setBorderTop(HSSFCellStyle.BORDER_THIN); style1.setBottomBorderColor(HSSFColor.BLACK.index); style1.setLeftBorderColor(HSSFColor.BLACK.index); style1.setTopBorderColor(HSSFColor.BLACK.index); style1.setRightBorderColor(HSSFColor.BLACK.index); int loop = rowCount; for (int i = 1 + loop; i <= rows.size() + loop; i++) { row = hsssh.createRow((short) i); for (int j = 0; j < cols.size(); j++) { HSSFCell cell = row.createCell(j); cell.setCellValue(((Vector) rows.elementAt(i - (1 + loop))).get(j).toString()); cell.setCellStyle(style1); } rowCount++; } } FileOutputStream fOut = new FileOutputStream(excel); hsswb.write(fOut); fOut.flush(); fOut.close(); } catch (IOException e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } catch (IllegalArgumentException e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } catch (Exception e) { DVLOG.setErrorLog(DVExcelIO.class.getName(), e); return false; } return true; }
From source file:com.eastsoft.ui.MainUI.java
License:Open Source License
void savePrintInfoToExcel(recordInfo recordinfor, int printFormat) { if (printFormat != 0) { HSSFWorkbook wb = null;//from w ww . j a v a 2 s. c om File printRecord = new File("?.xls"); if (!printRecord.exists()) { wb = new HSSFWorkbook(); HSSFSheet sheet1 = wb.createSheet("sheet1"); HSSFRow row = sheet1.createRow(0); row.createCell((short) 0).setCellValue("? "); row.createCell((short) 1).setCellValue(" "); row.createCell((short) 2).setCellValue("?? "); row.createCell((short) 3).setCellValue("?? "); row.createCell((short) 4).setCellValue("Aid "); row.createCell((short) 5).setCellValue("? "); HSSFRow row1 = sheet1.createRow(sheet1.getLastRowNum() + 1); row1.createCell((short) 0).setCellValue(recordinfor.getDate()); row1.createCell((short) 1).setCellValue(recordinfor.getProductSerialNO()); row1.createCell((short) 2).setCellValue(recordinfor.getDevice()); row1.createCell((short) 3).setCellValue(recordinfor.getProduct()); row1.createCell((short) 4).setCellValue(recordinfor.getAid()); row1.createCell((short) 5).setCellValue(recordinfor.getPasswd()); } else { FileInputStream fs = null; try { fs = new FileInputStream(printRecord); } catch (FileNotFoundException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } POIFSFileSystem ps = null; try { ps = new POIFSFileSystem(fs); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { wb = new HSSFWorkbook(ps); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } HSSFSheet sheet = wb.getSheetAt(0); // ?cell,Rows 0(Create a row and put some cells // in // it. Rows are 0 based.) HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1); row.createCell((short) 0).setCellValue(recordinfor.getDate()); row.createCell((short) 1).setCellValue(recordinfor.getProductSerialNO()); row.createCell((short) 2).setCellValue(recordinfor.getDevice()); row.createCell((short) 3).setCellValue(recordinfor.getProduct()); row.createCell((short) 4).setCellValue(recordinfor.getAid()); row.createCell((short) 5).setCellValue(recordinfor.getPasswd()); } FileOutputStream fileOut = null; try { fileOut = new FileOutputStream(printRecord); } catch (FileNotFoundException e) { // TODO Auto-generated catch block appendTextareaText(jTextArea_status, "\n?.xls ??"); JOptionPane.showMessageDialog(getParent(), "?.xls ??", "?.xls", JOptionPane.WARNING_MESSAGE); e.printStackTrace(); } try { wb.write(fileOut); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { fileOut.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelExportStudyServiceImpl.java
License:Open Source License
private void writeDescriptionSheet(HSSFWorkbook xlsBook, Workbook workbook) { Locale locale = LocaleContextHolder.getLocale(); HSSFSheet xlsSheet = xlsBook .createSheet(messageSource.getMessage("export.study.sheet.description", null, locale)); int currentRowNum = 0; currentRowNum = writeStudyDetails(currentRowNum, xlsBook, xlsSheet, workbook.getStudyDetails()); xlsSheet.createRow(currentRowNum++); currentRowNum = writeConditions(currentRowNum, xlsBook, xlsSheet, workbook.getConditions()); xlsSheet.createRow(currentRowNum++); currentRowNum = writeFactors(currentRowNum, xlsBook, xlsSheet, workbook.getFactors()); xlsSheet.createRow(currentRowNum++); currentRowNum = writeConstants(currentRowNum, xlsBook, xlsSheet, workbook.getConstants()); xlsSheet.createRow(currentRowNum++); currentRowNum = writeVariates(currentRowNum, xlsBook, xlsSheet, workbook.getVariates()); for (int i = 0; i < 8; i++) { xlsSheet.autoSizeColumn(i);//w w w . ja v a 2s. c om } }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelExportStudyServiceImpl.java
License:Open Source License
private void writeStudyDetailRow(HSSFWorkbook xlsBook, HSSFSheet xlsSheet, int currentRowNum, String label, String value) {//from w w w. jav a2s . c om Locale locale = LocaleContextHolder.getLocale(); HSSFRow row = xlsSheet.createRow(currentRowNum); HSSFCell cell = row.createCell(0, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, 153, 51, 0)); cell.setCellValue(messageSource.getMessage(label, null, locale)); cell = row.createCell(1, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(value); }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelExportStudyServiceImpl.java
License:Open Source License
private void writeSectionHeader(HSSFWorkbook xlsBook, HSSFSheet xlsSheet, int currentRowNum, String typeLabel, int c1, int c2, int c3) { Locale locale = LocaleContextHolder.getLocale(); HSSFRow row = xlsSheet.createRow(currentRowNum); HSSFCell cell = row.createCell(0, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage(typeLabel, null, locale)); cell = row.createCell(1, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.description", null, locale)); cell = row.createCell(2, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.property", null, locale)); cell = row.createCell(3, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.scale", null, locale)); cell = row.createCell(4, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.method", null, locale)); cell = row.createCell(5, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.datatype", null, locale)); cell = row.createCell(6, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.value", null, locale)); cell = row.createCell(7, HSSFCell.CELL_TYPE_STRING); cell.setCellStyle(getHeaderStyle(xlsBook, c1, c2, c3)); cell.setCellValue(messageSource.getMessage("export.study.description.column.label", null, locale)); }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelExportStudyServiceImpl.java
License:Open Source License
private void writeSectionRow(int currentRowNum, HSSFSheet xlsSheet, MeasurementVariable variable) { HSSFRow row = xlsSheet.createRow(currentRowNum); HSSFCell cell = row.createCell(0, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getName()); cell = row.createCell(1, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getDescription()); cell = row.createCell(2, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getProperty()); cell = row.createCell(3, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getScale()); cell = row.createCell(4, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getMethod()); cell = row.createCell(5, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getDataType()); cell = row.createCell(6, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getValue()); cell = row.createCell(7, HSSFCell.CELL_TYPE_STRING); cell.setCellValue(variable.getLabel()); }
From source file:com.efficio.fieldbook.web.nursery.service.impl.ExcelExportStudyServiceImpl.java
License:Open Source License
private void writeObservationHeader(int currentRowNum, HSSFWorkbook xlsBook, HSSFSheet xlsSheet, List<MeasurementVariable> variables) { if (variables != null && !variables.isEmpty()) { int currentColNum = 0; HSSFRow row = xlsSheet.createRow(currentRowNum++); for (MeasurementVariable variable : variables) { HSSFCell cell = row.createCell(currentColNum++); if (variable.isFactor()) { cell.setCellStyle(getHeaderStyle(xlsBook, 51, 153, 102)); } else { cell.setCellStyle(getHeaderStyle(xlsBook, 51, 51, 153)); }/*www . j a va 2 s .com*/ cell.setCellValue(variable.getName()); } } }