List of usage examples for org.apache.poi.ss.usermodel Row createCell
Cell createCell(int column);
From source file:com.kcs.action.report.ForwardContractAction.java
@Override public String export() throws Exception { setList(getService().findMaturitySummaryByCriteria(DateUtil.convertDateFromJsp(getDataSetDate()))); getLogger().debug("exportExcel : begin..."); getLogger().debug("exportExcel : list >>> " + getList()); DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Journal"); setFileName("Export Data Maturity (Summary) " + dateFormat.format(new Date()) + "excel".concat(".xls")); if (null != getList() && getList().size() > 0) { int rownum = 0; Row row = mySheet.createRow(rownum++); // mySheet.addMergedRegion(rowFrom,rowTo,colFrom,colTo); int cellnum = 0; row.createCell(cellnum++).setCellValue("MaturityGroup"); row.createCell(cellnum++).setCellValue("Ccy"); row.createCell(cellnum++).setCellValue("BuyAmt"); row.createCell(cellnum++).setCellValue("SellAmt"); row.createCell(cellnum++).setCellValue("TranType"); row.createCell(cellnum++).setCellValue("Proc Date"); for (Maturity obj : getList()) { Row rowData = mySheet.createRow(rownum++); cellnum = 0;//from ww w .j a v a2s . c o m rowData.createCell(cellnum++).setCellValue(obj.getMATURITY_GROUP() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCCY() + ""); rowData.createCell(cellnum++).setCellValue(obj.getBUY_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getSELL_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getTRANS_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getPROC_DATE() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); getLogger().debug("exportExcel : end..."); return "excel"; }
From source file:com.kcs.action.report.MaturityMediumAction.java
@Override public String export() throws Exception { setList(getService().findMaturityMediumByCriteria(DateUtil.convertDateFromJsp(getDataSetDate()))); getLogger().debug("exportExcel : begin..."); getLogger().debug("exportExcel : list >>> " + getList()); DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Journal"); setFileName("Export Data Maturity (Medium) " + dateFormat.format(new Date()) + "excel".concat(".xls")); if (null != getList() && getList().size() > 0) { int rownum = 0; Row row = mySheet.createRow(rownum++); int cellnum = 0; row.createCell(cellnum++).setCellValue("MaturityGroup"); row.createCell(cellnum++).setCellValue("Ccy"); row.createCell(cellnum++).setCellValue("BuyAmt"); row.createCell(cellnum++).setCellValue("SellAmt"); row.createCell(cellnum++).setCellValue("ReportType"); row.createCell(cellnum++).setCellValue("TranType"); row.createCell(cellnum++).setCellValue("IpType"); row.createCell(cellnum++).setCellValue("ClNmThai"); row.createCell(cellnum++).setCellValue("Proc Date"); for (Maturity obj : getList()) { Row rowData = mySheet.createRow(rownum++); cellnum = 0;// w ww. j a va2s. com rowData.createCell(cellnum++).setCellValue(obj.getMATURITY_GROUP() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCCY() + ""); rowData.createCell(cellnum++).setCellValue(obj.getBUY_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getSELL_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getREPORT_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getTRANS_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getIP_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCL_NM_THAI() + ""); rowData.createCell(cellnum++).setCellValue(obj.getPROC_DATE() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); getLogger().debug("exportExcel : end..."); return "excel"; }
From source file:com.kcs.action.report.MaturitySummaryAction.java
@Override public String export() throws Exception { setList(getService().findMaturitySummaryByCriteria(DateUtil.convertDateFromJsp(getDataSetDate()))); getLogger().debug("exportExcel : begin..."); getLogger().debug("exportExcel : list >>> " + getList()); DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Journal"); setFileName("Export Data Maturity (Summary) " + dateFormat.format(new Date()) + "excel".concat(".xls")); if (null != getList() && getList().size() > 0) { int rownum = 0; Row row = mySheet.createRow(rownum++); int cellnum = 0; row.createCell(cellnum++).setCellValue("MaturityGroup"); row.createCell(cellnum++).setCellValue("Ccy"); row.createCell(cellnum++).setCellValue("BuyAmt"); row.createCell(cellnum++).setCellValue("SellAmt"); row.createCell(cellnum++).setCellValue("TranType"); row.createCell(cellnum++).setCellValue("Proc Date"); for (Maturity obj : getList()) { Row rowData = mySheet.createRow(rownum++); cellnum = 0;// ww w . java2 s .c o m rowData.createCell(cellnum++).setCellValue(obj.getMATURITY_GROUP() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCCY() + ""); rowData.createCell(cellnum++).setCellValue(obj.getBUY_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getSELL_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getTRANS_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getPROC_DATE() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); getLogger().debug("exportExcel : end..."); return "excel"; }
From source file:com.kcs.action.report.ReportJournalAction.java
@Override public String export() throws Exception { list = service.findByCriteria(DateUtil.convertDateFromJsp(dataSetDate)); getLogger().debug("exportExcel : begin..."); getLogger().debug("exportExcel : list >>> " + list); DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Journal"); setFileName("Export Data Journal" + dateFormat.format(new Date()) + "excel".concat(".xls")); if (null != list && list.size() > 0) { int rownum = 0; Row row = mySheet.createRow(rownum++); int cellnum = 0; row.createCell(cellnum++).setCellValue("JournalGroup"); row.createCell(cellnum++).setCellValue("Ccy"); row.createCell(cellnum++).setCellValue("BuyAmt"); row.createCell(cellnum++).setCellValue("SellAmt"); row.createCell(cellnum++).setCellValue("ReportType"); row.createCell(cellnum++).setCellValue("TranType"); row.createCell(cellnum++).setCellValue("IpType"); row.createCell(cellnum++).setCellValue("ClNmThai"); for (Journal obj : list) { Row rowData = mySheet.createRow(rownum++); cellnum = 0;/*from www .j a va 2 s .c o m*/ rowData.createCell(cellnum++).setCellValue(obj.getJOURNAL_GROUP() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCCY() + ""); rowData.createCell(cellnum++).setCellValue(obj.getBUY_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getSELL_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getREPORT_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getTRANS_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getIP_TYPE() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCL_NM_THAI() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); getLogger().debug("exportExcel : end..."); return "excel"; }
From source file:com.kcs.action.report.ReportJournalSummaryAction.java
@Override public String export() throws Exception { list = service.findJournalSummaryByCriteria(DateUtil.convertDateFromJsp(dataSetDate)); getLogger().debug("exportExcel : begin..."); getLogger().debug("exportExcel : list >>> " + list); DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Journal"); setFileName("Export Data Journal (Summary)" + dateFormat.format(new Date()) + "excel".concat(".xls")); if (null != list && list.size() > 0) { int rownum = 0; Row row = mySheet.createRow(rownum++); int cellnum = 0; row.createCell(cellnum++).setCellValue("JournalGroup"); row.createCell(cellnum++).setCellValue("Ccy"); row.createCell(cellnum++).setCellValue("BuyAmt"); row.createCell(cellnum++).setCellValue("SellAmt"); row.createCell(cellnum++).setCellValue("TranType"); for (Journal obj : list) { Row rowData = mySheet.createRow(rownum++); cellnum = 0;/*w w w. j ava 2 s . com*/ rowData.createCell(cellnum++).setCellValue(obj.getJOURNAL_GROUP() + ""); rowData.createCell(cellnum++).setCellValue(obj.getCCY() + ""); rowData.createCell(cellnum++).setCellValue(obj.getBUY_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getSELL_AMT() + ""); rowData.createCell(cellnum++).setCellValue(obj.getTRANS_TYPE() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); getLogger().debug("exportExcel : end..."); return "excel"; }
From source file:com.kcs.action.ReportCompareUtilizeFwdAction.java
public String export() throws Exception { logger.debug("= = = = = EXPORT = = = = ="); logger.debug("PALM : processDate >>> " + DateUtil.convertDateFromJsp(processDate) + " reportType >>> " + reportType);/*w w w. j a va 2 s. com*/ list = reportCompareUtilizeFWDService.findWithCriteriaService(reportType, DateUtil.convertDateFromJsp(processDate)); fileType = "XLS"; HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet("Utilize_FWD"); if ("RPT_TYP1_41".equals(reportType)) { fileName = "Report_FWD_not_found_EES_(Trade_Finance)_CBS_(Remittance)_" + hidDate + ".xls"; Row rowHeader1 = mySheet.createRow(0); rowHeader1.createCell(0).setCellValue( "? FWD ? EES (Trade Finance) & CBS (Remittance)"); } else if ("RPT_TYP2_41".equals(reportType)) { fileName = "Report_EES_(Trade_Finance)_CBS_(Remittance)_not_found_FWD_" + hidDate + ".xls"; Row rowHeader1 = mySheet.createRow(0); rowHeader1.createCell(0).setCellValue( "? EES (Trade Finance) & CBS (Remittance)? FWD"); } // Cell cell1 = CellUtil.createCell(rowHeader1, 0,"? FWD ? EES (Trade Finance) & CBS (Remittance)"); // CellUtil.setAlignment(cell1, myWorkBook, CellStyle.ALIGN_CENTER); Row rowHeader2 = mySheet.createRow(1); rowHeader2.createCell(0).setCellValue(processDate); // Cell cell2 = CellUtil.createCell(rowHeader2, 1,processDate); // CellUtil.setAlignment(cell2, myWorkBook, CellStyle.ALIGN_CENTER); mySheet.addMergedRegion(new CellRangeAddress(0, //first row (0-based) 0, //last row (0-based) 0, //first column (0-based) 2 //last column (0-based) )); mySheet.addMergedRegion(new CellRangeAddress(1, //first row (0-based) 1, //last row (0-based) 0, //first column (0-based) 2 //last column (0-based) )); if (null != list && list.size() > 0) { int rownum = 2; Row row = mySheet.createRow(rownum++); int cellnum = 0; row.createCell(cellnum++).setCellValue("Curr"); row.createCell(cellnum++).setCellValue("Fi Arrg No"); row.createCell(cellnum++).setCellValue("Amount"); for (ReportCompareUtilizeFwd obj : list) { Row rowData = mySheet.createRow(rownum++); cellnum = 0; rowData.createCell(cellnum++).setCellValue(obj.getCURR() + ""); rowData.createCell(cellnum++).setCellValue(obj.getFI_ARRG_NO() + ""); rowData.createCell(cellnum++).setCellValue(obj.getAMT() + ""); } for (int j = 0; j < cellnum; j++) { mySheet.autoSizeColumn(j); } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); logger.debug("exportExcel : end..."); return "excel"; // return REPORT; }
From source file:com.kcs.core.actions.ExportDataAction.java
public String exportExcel() throws Exception { logger.debug("exportExcel : begin..."); list = manageService.findListDinamicSql(sql); logger.debug("exportExcel : list >>> " + list); Calendar calendar = Calendar.getInstance(); HSSFWorkbook myWorkBook = new HSSFWorkbook(); HSSFSheet mySheet = myWorkBook.createSheet(DateUtil.getCurrentDateString(DateUtil.DATE_FORMAT_YYYYMMDD)); setFileName(DateUtil.getCurrentDateString(DateUtil.DATE_FORMAT_YYYYMMDD).concat(".xls")); Row headerRow = mySheet.createRow(0); if (null != list && list.size() > 0) { /* create header excel */ int i = 0; Map mapHedder = (Map) list.get(0); Set h = mapHedder.keySet(); Iterator it = h.iterator(); while (it.hasNext()) { String its = (String) it.next(); Cell titleCell = headerRow.createCell(i++); titleCell.setCellValue(its); }//from w w w.j av a2s .c o m /* create content excel */ int rowNum = 1; HSSFRow myRow = null; for (Iterator iter = list.iterator(); iter.hasNext();) { Map map = (Map) iter.next(); Set s = map.keySet(); Iterator tmp = s.iterator(); myRow = mySheet.createRow(rowNum++); logger.debug("***************************************************"); int j = 0; while (tmp.hasNext()) { String its = (String) tmp.next(); String str = String.valueOf(map.get(its)); // logger.debug("str["+j+"] >>> "+str); Cell cell = myRow.createCell(j++); cell.setCellValue(str); } } } ByteArrayOutputStream boas = new ByteArrayOutputStream(); myWorkBook.write(boas); setExcelStream(new ByteArrayInputStream(boas.toByteArray())); logger.debug("exportExcel : end..."); return "excel"; }
From source file:com.khartec.waltz.web.endpoints.extracts.BaseDataExtractor.java
License:Open Source License
private void writeExcelBody(Select<?> qry, XSSFSheet sheet) { AtomicInteger rowNum = new AtomicInteger(1); qry.fetch().forEach(r -> {//from w ww . j a v a 2s .c om Row row = sheet.createRow(rowNum.getAndIncrement()); AtomicInteger colNum = new AtomicInteger(0); colNum.set(0); for (Field<?> field : r.fields()) { Cell cell = row.createCell(colNum.getAndIncrement()); cell.setCellValue(Optional.ofNullable(r.get(field)).map(Objects::toString).orElse("")); } }); }
From source file:com.khartec.waltz.web.endpoints.extracts.BaseDataExtractor.java
License:Open Source License
private void writeExcelHeader(Select<?> qry, XSSFSheet sheet) { Row headerRow = sheet.createRow(0); AtomicInteger colNum = new AtomicInteger(); qry.fieldStream().forEach(f -> {/* w w w . ja v a 2 s .com*/ Cell cell = headerRow.createCell(colNum.getAndIncrement()); cell.setCellValue(Objects.toString(f.getName())); }); }
From source file:com.kovtun.WorkTimeMap.UI.TimeReport.java
private Workbook generateData() { Workbook book = new HSSFWorkbook(); Sheet sheet = book.createSheet();// ww w . java 2s .c o m int rowCount = 1; //? Row projRow = sheet.createRow(0); Cell prjName = projRow.createCell(0); prjName.setCellValue(project.getName()); for (ReportUser user : users) { //? Row row = sheet.createRow(rowCount); Cell nullCell = row.createCell(0); nullCell.setCellValue(" "); Row nameRow = sheet.createRow(rowCount); Cell nameCell = nameRow.createCell(0); nameCell.setCellValue(user.getFio()); Cell userAllTimeCell = nameRow.createCell(1); userAllTimeCell.setCellValue((user.getAllTime() / (1000 * 60)) / 60 + " . " + (user.getAllTime() / (1000 * 60) % 60 + " .")); // rowCount++; Row aRow = sheet.createRow(rowCount); Cell aNumber = aRow.createCell(0); aNumber.setCellValue(""); Cell aName = aRow.createCell(1); aName.setCellValue("?"); Cell aDescription = aRow.createCell(2); aDescription.setCellValue("?"); Cell aComment = aRow.createCell(3); aComment.setCellValue(""); Cell aDate = aRow.createCell(4); aDate.setCellValue(" "); Cell aTime = aRow.createCell(5); aTime.setCellValue("? ?"); // List<Action> list = user.getActions(); int k = 1; for (Action action : list) { rowCount++; Row actionRow = sheet.createRow(rowCount); Cell actionNumber = actionRow.createCell(0); actionNumber.setCellValue(k); k++; Cell actionName = actionRow.createCell(1); actionName.setCellValue(action.getName()); Cell actionDescription = actionRow.createCell(2); actionDescription.setCellValue(action.getDescription()); Cell actionComment = actionRow.createCell(3); actionComment.setCellValue(action.getComment()); Cell actionDate = actionRow.createCell(4); actionDate.setCellValue(action.getStringDate()); Cell actionTime = actionRow.createCell(5); actionTime.setCellValue((action.getStopTime() == null ? "? !" : ((action.getStopTime().getTime() - action.getStartTime().getTime()) / (1000 * 60)) / 60 + " . " + ((action.getStopTime().getTime() - action.getStartTime().getTime()) / (1000 * 60) % 60 + " ."))); } rowCount++; } sheet.autoSizeColumn(0); sheet.autoSizeColumn(1); sheet.autoSizeColumn(2); sheet.autoSizeColumn(3); sheet.autoSizeColumn(4); sheet.autoSizeColumn(5); return book; }