List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle setBorderRight
@Override public void setBorderRight(BorderStyle border)
From source file:com.lushapp.common.excel.ExportExcel.java
License:Apache License
/** * excel?/* w w w .j a v a 2 s.c o m*/ * @param workbook * @return */ public static HSSFCellStyle getTitleStyle(HSSFWorkbook workbook) { // Excel HSSFCellStyle titleStyle = workbook.createCellStyle(); titleStyle.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE); //? titleStyle.setBorderLeft((short) 2); // titleStyle.setBorderRight((short) 2); //? titleStyle.setBorderTop((short) 2); // titleStyle.setBorderBottom((short) 2); //? titleStyle.setBorderTop(HSSFCellStyle.BORDER_DOUBLE); // titleStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); // titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); titleStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); // return titleStyle; }
From source file:com.lushapp.common.excel.ExportExcel.java
License:Apache License
public static HSSFCellStyle getTwoStyle(HSSFWorkbook workbook) { // Excel/*w w w . ja v a 2 s .c o m*/ HSSFCellStyle style = workbook.createCellStyle(); style.setBorderLeft((short) 1); // style.setBorderRight((short) 1); //? style.setBorderBottom((short) 1); style.setBorderTop((short) 1); style.setFillForegroundColor(HSSFColor.LIGHT_TURQUOISE.index); // style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); // return style; }
From source file:com.lushapp.common.excel.ExportExcel.java
License:Apache License
public static HSSFCellStyle getOneStyle(HSSFWorkbook workbook) { // Excel//w w w . j a va 2s . co m // Excel HSSFCellStyle style = workbook.createCellStyle(); style.setBorderLeft((short) 1); // style.setBorderRight((short) 1); //? style.setBorderBottom((short) 1); style.setBorderTop((short) 1); return style; }
From source file:com.modelmetrics.common.poi.ExcelSupport.java
License:Open Source License
public void decorateRowWithBoldCellBlueBackground(int cellId, HSSFRow row, Object value) { HSSFCellStyle boldStyleBlueBground = workbook.createCellStyle(); boldStyleBlueBground.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP); boldStyleBlueBground.setFont(boldFont); boldStyleBlueBground.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); boldStyleBlueBground.setFillForegroundColor(new HSSFColor.LIGHT_TURQUOISE().getIndex()); boldStyleBlueBground.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); boldStyleBlueBground.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM); boldStyleBlueBground.setBorderRight(HSSFCellStyle.BORDER_MEDIUM); boldStyleBlueBground.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); this.decorateRowWithCell((short) cellId, row, value, boldStyleBlueBground); }
From source file:com.nokia.s60tools.swmtanalyser.model.ExcelCreator.java
License:Open Source License
private HSSFCellStyle createBorderedStyle(HSSFWorkbook wb) { HSSFCellStyle style = wb.createCellStyle(); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setRightBorderColor(HSSFColor.BLACK.index); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setBottomBorderColor(HSSFColor.BLACK.index); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setLeftBorderColor(HSSFColor.BLACK.index); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setTopBorderColor(HSSFColor.BLACK.index); return style; }
From source file:com.objectfrontier.insta.neft.reports.bean.InstaNEFTReportBean.java
License:Open Source License
/** * Method used to export the bank wise summary report in to Excel for both Inward and Outward. *//w ww . j a v a2 s . com * @param out ServletOutputStream * */ public void generateNEFTInwBankSummaryReportToExcel(ServletOutputStream out) throws Exception { try { if (returnedList.contains(" ")) { throw new Exception("No Data Found! Cannot Export as Excel Sheet!!"); } HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(reportTitle); HSSFCellStyle titleStyle = wb.createCellStyle(); titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCellStyle fontStyle = wb.createCellStyle(); HSSFFont fontSize = wb.createFont(); fontSize.setFontHeightInPoints((short) 10); fontSize.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); fontStyle.setFont(fontSize); fontStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); sheet.setColumnWidth((short) 0, (short) 2000); sheet.setColumnWidth((short) 1, (short) 4000); sheet.setColumnWidth((short) 2, (short) 6000); sheet.setColumnWidth((short) 3, (short) 5000); sheet.setColumnWidth((short) 4, (short) 7000); sheet.setColumnWidth((short) 5, (short) 7000); sheet.setColumnWidth((short) 6, (short) 7000); sheet.setColumnWidth((short) 7, (short) 7000); HSSFCellStyle contentStyle = wb.createCellStyle(); contentStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); contentStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle stringStyle = wb.createCellStyle(); stringStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT); stringStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle stringRightStyle = wb.createCellStyle(); stringRightStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT); stringRightStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); stringRightStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); stringRightStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); stringRightStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFFont headingFont = wb.createFont(); headingFont.setFontHeightInPoints((short) 9); headingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle headingStyle = wb.createCellStyle(); headingStyle.setFont(headingFont); headingStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); headingStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index); headingStyle.setFillPattern(HSSFCellStyle.BIG_SPOTS); headingStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headingStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); headingStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle titleRightStyle = wb.createCellStyle(); titleRightStyle.setFont(headingFont); titleRightStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT); titleRightStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle titleLeftStyle = wb.createCellStyle(); titleLeftStyle.setFont(headingFont); titleLeftStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT); titleLeftStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); int rowCount = 2; String dateForm = currentReportPrintTime.substring(0, 11); String time = currentReportPrintTime.substring(11); HSSFRow reportTimeRow = sheet.createRow((short) rowCount); HSSFCell reportTimeRowCell = reportTimeRow.createCell((short) 0); reportTimeRowCell.setCellStyle(titleRightStyle); reportTimeRowCell.setCellValue( "Report Printed on " + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 7)); rowCount++; HSSFRow stTitle = sheet.createRow((short) rowCount); HSSFCell title = stTitle.createCell((short) 0); title.setCellStyle(fontStyle); title.setCellValue(reportTitle); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 7)); rowCount++; HSSFRow stTitleTwo = sheet.createRow((short) rowCount); HSSFCell stTitleCellOne = stTitleTwo.createCell((short) 0); stTitleCellOne.setCellStyle(fontStyle); stTitleCellOne.setCellValue("from " + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()) + " to " + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getToDate())); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 7)); rowCount = rowCount + 2; HSSFRow rowhead = sheet.createRow((short) rowCount); HSSFCell snoHead = rowhead.createCell((short) 0); snoHead.setCellStyle(headingStyle); snoHead.setCellValue("S. NO"); HSSFCell ifscHead = rowhead.createCell((short) 1); ifscHead.setCellStyle(headingStyle); ifscHead.setCellValue("Bank IFSC"); HSSFCell txnCountHead = rowhead.createCell((short) 2); txnCountHead.setCellStyle(headingStyle); txnCountHead.setCellValue("Txn Count"); HSSFCell amountHead = rowhead.createCell((short) 3); amountHead.setCellStyle(headingStyle); amountHead.setCellValue("Sum of Txn AMT (Rs)"); if (reportTitle.equals(inwSummaryReport)) { HSSFCell txnCompletedCountHead = rowhead.createCell((short) 4); txnCompletedCountHead.setCellStyle(headingStyle); txnCompletedCountHead.setCellValue("TXN count Completed/Credited "); HSSFCell txnCompletedCountAmtHead = rowhead.createCell((short) 5); txnCompletedCountAmtHead.setCellStyle(headingStyle); txnCompletedCountAmtHead.setCellValue("Sum of Completed/Credited AMT"); HSSFCell txnRtnCountHead = rowhead.createCell((short) 6); txnRtnCountHead.setCellStyle(headingStyle); txnRtnCountHead.setCellValue("TXN count Inward Returned"); HSSFCell txnRtnCountAmtHead = rowhead.createCell((short) 7); txnRtnCountAmtHead.setCellStyle(headingStyle); txnRtnCountAmtHead.setCellValue("Sum of Inward Returned AMT"); } else { HSSFCell txnCompletedCountHead = rowhead.createCell((short) 4); txnCompletedCountHead.setCellStyle(headingStyle); txnCompletedCountHead.setCellValue("TXN count Settled/Credited "); HSSFCell txnCompletedCountAmtHead = rowhead.createCell((short) 5); txnCompletedCountAmtHead.setCellStyle(headingStyle); txnCompletedCountAmtHead.setCellValue("Sum of Settled/Credited AMT"); HSSFCell txnRtnCountHead = rowhead.createCell((short) 6); txnRtnCountHead.setCellStyle(headingStyle); txnRtnCountHead.setCellValue("TXN count Outward Returned"); HSSFCell txnRtnCountAmtHead = rowhead.createCell((short) 7); txnRtnCountAmtHead.setCellStyle(headingStyle); txnRtnCountAmtHead.setCellValue("Sum of Outward Returned AMT"); } int rowIndex = 1; for (Iterator itr = returnedList.iterator(); itr.hasNext();) { ReportDTO reportDTO = (ReportDTO) itr.next(); HSSFRow row = null; rowCount++; row = sheet.createRow(rowCount); HSSFCell snoCell = row.createCell((short) 0); snoCell.setCellStyle(contentStyle); snoCell.setCellValue(rowIndex); rowIndex++; HSSFCell ifscCell = row.createCell((short) 1); ifscCell.setCellStyle(stringStyle); if (reportDTO.getSenderAddress() != null) { ifscCell.setCellValue(reportDTO.getSenderAddress()); } else { ifscCell.setCellValue(""); } HSSFCell txnCountCell = row.createCell((short) 2); txnCountCell.setCellStyle(stringRightStyle); if (reportDTO.getCount() != 0) { txnCountCell.setCellValue(reportDTO.getCount()); } else { txnCountCell.setCellValue(""); } HSSFCell txnAmountCell = row.createCell((short) 3); txnAmountCell.setCellStyle(stringRightStyle); if (reportDTO.getAmt() != null && !(reportDTO.getAmt().equals("0"))) { txnAmountCell.setCellValue(reportDTO.getAmt()); } else { txnAmountCell.setCellValue(""); } HSSFCell cmpTxnCountCell = row.createCell((short) 4); cmpTxnCountCell.setCellStyle(stringRightStyle); if (reportDTO.getCompletedTxnCount() != 0) { cmpTxnCountCell.setCellValue(reportDTO.getCompletedTxnCount()); } else { cmpTxnCountCell.setCellValue(""); } HSSFCell cmpTxnAmtCell = row.createCell((short) 5); cmpTxnAmtCell.setCellStyle(stringRightStyle); if (reportDTO.getCompletedTxnAmount() != null && !(reportDTO.getCompletedTxnAmount().equals("0"))) { cmpTxnAmtCell.setCellValue(reportDTO.getCompletedTxnAmount()); } else { cmpTxnAmtCell.setCellValue(""); } HSSFCell rtnTxnCountCell = row.createCell((short) 6); rtnTxnCountCell.setCellStyle(stringRightStyle); if (reportDTO.getRtnTxnCount() != 0) { rtnTxnCountCell.setCellValue(reportDTO.getRtnTxnCount()); } else { rtnTxnCountCell.setCellValue(""); } HSSFCell rtnTxnAmtCell = row.createCell((short) 7); rtnTxnAmtCell.setCellStyle(stringRightStyle); if (reportDTO.getRtnTxnAmount() != null && !(reportDTO.getRtnTxnAmount().equals("0"))) { rtnTxnAmtCell.setCellValue(reportDTO.getRtnTxnAmount()); } else { rtnTxnAmtCell.setCellValue(""); } } wb.write(out); out.flush(); out.close(); } catch (Exception e) { logger.error("Exception while creating Excel sheet file" + e.getMessage()); throw new Exception("Exception while creating Excel sheet file" + e); } }
From source file:com.objectfrontier.insta.neft.reports.bean.InstaNEFTReportBean.java
License:Open Source License
/** * Method used to export the bank wise detailed report in to Excel for both Inward and Outward. */* w w w . j a va2s . co m*/ * @param out ServletOutputStream * */ public void generateNEFTInwBankDetailedReportToExcel(ServletOutputStream out) throws Exception { try { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(reportTitle); HSSFCellStyle titleStyle = wb.createCellStyle(); titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); HSSFCellStyle fontStyle = wb.createCellStyle(); HSSFFont fontSize = wb.createFont(); fontSize.setFontHeightInPoints((short) 10); fontSize.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); fontStyle.setFont(fontSize); fontStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); sheet.setColumnWidth((short) 0, (short) 2000); sheet.setColumnWidth((short) 1, (short) 4000); sheet.setColumnWidth((short) 2, (short) 6000); sheet.setColumnWidth((short) 3, (short) 5000); sheet.setColumnWidth((short) 4, (short) 3000); sheet.setColumnWidth((short) 5, (short) 6000); sheet.setColumnWidth((short) 6, (short) 3000); sheet.setColumnWidth((short) 7, (short) 6000); sheet.setColumnWidth((short) 8, (short) 2500); sheet.setColumnWidth((short) 9, (short) 6000); sheet.setColumnWidth((short) 10, (short) 3000); sheet.setColumnWidth((short) 11, (short) 6000); sheet.setColumnWidth((short) 12, (short) 4500); HSSFCellStyle contentStyle = wb.createCellStyle(); contentStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); contentStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); contentStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle stringStyle = wb.createCellStyle(); stringStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT); stringStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); stringStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFFont headingFont = wb.createFont(); headingFont.setFontHeightInPoints((short) 9); headingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle headingStyle = wb.createCellStyle(); headingStyle.setFont(headingFont); headingStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); headingStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index); headingStyle.setFillPattern(HSSFCellStyle.BIG_SPOTS); headingStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headingStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); headingStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); headingStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle titleRightStyle = wb.createCellStyle(); titleRightStyle.setFont(headingFont); titleRightStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT); titleRightStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); titleRightStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); HSSFCellStyle titleLeftStyle = wb.createCellStyle(); titleLeftStyle.setFont(headingFont); titleLeftStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT); titleLeftStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); titleLeftStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); int rowCount = 2; String dateForm = currentReportPrintTime.substring(0, 11); String time = currentReportPrintTime.substring(11); HSSFRow reportTimeRow = sheet.createRow((short) rowCount); HSSFCell reportTimeRowCell = reportTimeRow.createCell((short) 0); reportTimeRowCell.setCellStyle(titleRightStyle); reportTimeRowCell.setCellValue( "Report Printed on " + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 12)); rowCount++; HSSFRow stTitle = sheet.createRow((short) rowCount); HSSFCell title = stTitle.createCell((short) 0); title.setCellStyle(fontStyle); title.setCellValue(reportTitle); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 12)); rowCount++; HSSFRow stTitleTwo = sheet.createRow((short) rowCount); HSSFCell stTitleCellOne = stTitleTwo.createCell((short) 0); stTitleCellOne.setCellStyle(fontStyle); stTitleCellOne.setCellValue("from " + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()) + " to " + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getToDate())); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 12)); rowCount = rowCount + 2; if (getReportMap().size() != 0) { Set set = getReportMap().entrySet(); for (Iterator z = set.iterator(); z.hasNext();) { Map.Entry<String, List<TransactionInfo>> entry = (Map.Entry<String, List<TransactionInfo>>) z .next(); List exportXLS = new ArrayList(1); exportXLS.addAll(entry.getValue()); String bankName = entry.getKey().substring(0, 4); String sumTxnAmount = entry.getKey().substring(5); HSSFRow titleRowOne = sheet.createRow((short) rowCount); HSSFCell bankNameCell = titleRowOne.createCell((short) 0); bankNameCell.setCellStyle(titleRightStyle); if (getTranType().equals("inward")) { bankNameCell.setCellValue("Sender Bank : "); } else { bankNameCell.setCellValue(" Receiver Bank : "); } sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 6)); HSSFCell bankNameValCell = titleRowOne.createCell((short) 7); bankNameValCell.setCellStyle(titleLeftStyle); bankNameValCell.setCellValue(bankName); sheet.addMergedRegion(new Region(rowCount, (short) 7, rowCount, (short) 12)); rowCount++; HSSFRow titleRowTwo = sheet.createRow((short) rowCount); HSSFCell txnCountCell = titleRowTwo.createCell((short) 0); txnCountCell.setCellStyle(titleRightStyle); txnCountCell.setCellValue("Txn Count : "); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 6)); HSSFCell txnCountValCell = titleRowTwo.createCell((short) 7); txnCountValCell.setCellStyle(titleLeftStyle); txnCountValCell.setCellValue(exportXLS.size()); sheet.addMergedRegion(new Region(rowCount, (short) 7, rowCount, (short) 12)); rowCount++; HSSFRow titleRowThree = sheet.createRow((short) rowCount); HSSFCell sumTxnAmountCell = titleRowThree.createCell((short) 0); sumTxnAmountCell.setCellStyle(titleRightStyle); sumTxnAmountCell.setCellValue("Sum of Txn Amount : "); sheet.addMergedRegion(new Region(rowCount, (short) 0, rowCount, (short) 6)); HSSFCell sumTxnAmountValCell = titleRowThree.createCell((short) 7); sumTxnAmountValCell.setCellStyle(titleLeftStyle); sumTxnAmountValCell.setCellValue(sumTxnAmount); sheet.addMergedRegion(new Region(rowCount, (short) 7, rowCount, (short) 12)); rowCount++; HSSFRow titleRow = sheet.createRow((short) rowCount); HSSFCell beneficiaryTitle = titleRow.createCell((short) 4); beneficiaryTitle.setCellStyle(headingStyle); beneficiaryTitle.setCellValue("Beneficiary Details"); sheet.addMergedRegion(new Region(rowCount, (short) 4, rowCount, (short) 7)); HSSFCell senderTitle = titleRow.createCell((short) 8); senderTitle.setCellStyle(headingStyle); senderTitle.setCellValue("Sender's Details"); sheet.addMergedRegion(new Region(rowCount, (short) 8, rowCount, (short) 11)); rowCount++; HSSFRow rowhead = sheet.createRow((short) rowCount); HSSFCell snoHead = rowhead.createCell((short) 0); snoHead.setCellStyle(headingStyle); snoHead.setCellValue("S .NO"); HSSFCell valueDateHead = rowhead.createCell((short) 1); valueDateHead.setCellStyle(headingStyle); valueDateHead.setCellValue("Value Date"); HSSFCell tranRefHead = rowhead.createCell((short) 2); tranRefHead.setCellStyle(headingStyle); tranRefHead.setCellValue("Transaction Ref. No"); HSSFCell amountHead = rowhead.createCell((short) 3); amountHead.setCellStyle(headingStyle); amountHead.setCellValue("Amount(Rs)"); HSSFCell benIfscHead = rowhead.createCell((short) 4); benIfscHead.setCellStyle(headingStyle); benIfscHead.setCellValue("IFSC"); HSSFCell benACNameHead = rowhead.createCell((short) 5); benACNameHead.setCellStyle(headingStyle); benACNameHead.setCellValue("A/c Name"); HSSFCell benACTypeHead = rowhead.createCell((short) 6); benACTypeHead.setCellStyle(headingStyle); benACTypeHead.setCellValue("A/c Type"); HSSFCell benACNoHead = rowhead.createCell((short) 7); benACNoHead.setCellStyle(headingStyle); benACNoHead.setCellValue("A/c No"); HSSFCell senIfscHead = rowhead.createCell((short) 8); senIfscHead.setCellStyle(headingStyle); senIfscHead.setCellValue("IFSC"); HSSFCell senACNameHead = rowhead.createCell((short) 9); senACNameHead.setCellStyle(headingStyle); senACNameHead.setCellValue("A/c Name"); HSSFCell senACTypeHead = rowhead.createCell((short) 10); senACTypeHead.setCellStyle(headingStyle); senACTypeHead.setCellValue("A/c Type"); HSSFCell senACNoHead = rowhead.createCell((short) 11); senACNoHead.setCellStyle(headingStyle); senACNoHead.setCellValue("A/c No"); HSSFCell tranStatusHead = rowhead.createCell((short) 12); tranStatusHead.setCellStyle(headingStyle); tranStatusHead.setCellValue("Transaction Status"); HSSFRow row = null; for (int i = exportXLS.size(), rowIndex = 0; rowIndex < i; rowIndex++) { TransactionInfo ti = (TransactionInfo) exportXLS.get(rowIndex); rowCount++; row = sheet.createRow(rowCount); HSSFCell snoCell = row.createCell((short) 0); snoCell.setCellStyle(contentStyle); snoCell.setCellValue(rowIndex + 1); HSSFCell valueDateCell = row.createCell((short) 1); valueDateCell.setCellStyle(stringStyle); if (ti.getValueDate() != null) { valueDateCell.setCellValue(InstaReportUtil.getDateInSpecificFormat(dateFormat, ti.getValueDate().toString())); } else { valueDateCell.setCellValue(""); } HSSFCell tranRefCell = row.createCell((short) 2); tranRefCell.setCellStyle(stringStyle); if (ti.getUtrNo() != null) { tranRefCell.setCellValue(ti.getUtrNo()); } else { tranRefCell.setCellValue(""); } HSSFCell amountCell = row.createCell((short) 3); amountCell.setCellStyle(stringStyle); if (ti.getAmount() != null) { amountCell.setCellValue(ti.getAmount().toString()); } else { amountCell.setCellValue(""); } HSSFCell benIfscCell = row.createCell((short) 4); benIfscCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccIfsc() != null) { benIfscCell.setCellValue(ti.getBeneficiaryInfo().getAccIfsc()); } else { benIfscCell.setCellValue(""); } HSSFCell benACNameCell = row.createCell((short) 5); benACNameCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccName() != null) { benACNameCell.setCellValue(ti.getBeneficiaryInfo().getAccName()); } else { benACNameCell.setCellValue(""); } HSSFCell benACTypeCell = row.createCell((short) 6); benACTypeCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccType() != null) { benACTypeCell.setCellValue(ti.getBeneficiaryInfo().getAccType()); } else { benACTypeCell.setCellValue(""); } HSSFCell benACNoCell = row.createCell((short) 7); benACNoCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccNo() != null) { benACNoCell.setCellValue(ti.getBeneficiaryInfo().getAccNo()); } else { benACNoCell.setCellValue(""); } HSSFCell senIfscCell = row.createCell((short) 8); senIfscCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccIfsc() != null) { senIfscCell.setCellValue(ti.getSenderInfo().getAccIfsc()); } else { senIfscCell.setCellValue(""); } HSSFCell senACNameCell = row.createCell((short) 9); senACNameCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccName() != null) { senACNameCell.setCellValue(ti.getSenderInfo().getAccName()); } else { senACNameCell.setCellValue(""); } HSSFCell senACTypeCell = row.createCell((short) 10); senACTypeCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccType() != null) { senACTypeCell.setCellValue(ti.getSenderInfo().getAccType()); } else { senACTypeCell.setCellValue(""); } HSSFCell senACNoCell = row.createCell((short) 11); senACNoCell.setCellStyle(stringStyle); if (ti.getBeneficiaryInfo().getAccNo() != null) { senACNoCell.setCellValue(ti.getSenderInfo().getAccNo()); } else { senACNoCell.setCellValue(""); } HSSFCell tranStatusCell = row.createCell((short) 12); tranStatusCell.setCellStyle(stringStyle); if (ti != null) { tranStatusCell.setCellValue(ti.getStatusShortDesc()); } else { tranStatusCell.setCellValue(""); } } rowCount = rowCount + 3; } } wb.write(out); out.flush(); out.close(); } catch (Exception e) { logger.error("Exception while creating Excel sheet file" + e.getMessage()); throw new Exception("Exception while creating Excel sheet file" + e); } }
From source file:com.pixelandtag.reports.ReportGenerator.java
License:Open Source License
/** * Sets the cell border// w w w . j av a 2 s .c o m * * @param <code>HSSFCellStyle</code>style to set */ private static void setStyleBorder(HSSFCellStyle style) { style.setBorderBottom((short) 1); style.setBorderBottom((short) 1); style.setBorderLeft((short) 1); style.setBorderRight((short) 1); style.setBorderTop((short) 1); }
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsStyleHelper.java
License:Open Source License
private HSSFCellStyle getHeaderStyle(final HSSFWorkbook workbook, final short borderLeft, final short borderRight, final short alignment, final short boldweight) { HSSFCellStyle style = workbook.createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM); style.setBorderLeft(borderLeft);/*from w w w .ja v a 2s . com*/ style.setBorderRight(borderRight); style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM); style.setAlignment(alignment); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setIndention((short) 3); style.setWrapText(true); style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); Font font = workbook.createFont(); font.setFontName(HSSFFont.FONT_ARIAL); font.setFontHeightInPoints((short) 12); font.setBoldweight(boldweight); style.setFont(font); return style; }
From source file:com.qcadoo.mes.assignmentToShift.print.xls.AssignmentToShiftXlsStyleHelper.java
License:Open Source License
private HSSFCellStyle getSeriesStyle(final HSSFWorkbook workbook, final short borderLeft, final short borderRight, final short alignment, final short boldweight) { HSSFCellStyle style = workbook.createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(borderLeft);// w w w . ja v a 2 s. c om style.setBorderRight(borderRight); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(alignment); style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); style.setWrapText(true); Font font = workbook.createFont(); font.setFontName(HSSFFont.FONT_ARIAL); font.setFontHeightInPoints((short) 11); font.setBoldweight(boldweight); style.setFont(font); return style; }