Example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createFont

List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook createFont

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFWorkbook createFont.

Prototype


@Override
public HSSFFont createFont() 

Source Link

Document

create a new Font and add it to the workbook's font table

Usage

From source file:com.objectfrontier.insta.neft.reports.bean.InstaNEFTReportBean.java

License:Open Source License

/**
 * Method used to export the Future Dated Txns report in to Excel
 *//*  w  ww .j  a  v  a 2s  . c o  m*/
public void neftFutureDatedTxnExportToExcel(ServletOutputStream out) throws Exception {

    try {

        int rowCount = 0;
        //          double grandInwTotTxnAmt = 0;
        //          double grandOwTotTxnAmt = 0;
        BigDecimal grandInwTotTxnAmt = BigDecimal.ZERO;
        BigDecimal grandOwTotTxnAmt = BigDecimal.ZERO;

        //Only If the list is not empty
        if (getReportMap().size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "NEFT Future Dated Txns Report", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            String statusName = "";
            if (getReportDto().getStatus().equalsIgnoreCase("2000")) {
                statusName = "Active";
            } else if (getReportDto().getStatus().equalsIgnoreCase("2050")) {
                statusName = "Cancelled";
            }
            cell.setCellValue("NEFT  Date wise Future Dated Txns Report from "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate())
                    + " to " + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getToDate())
                    + "with status " + statusName);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 6);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            Set set = getReportMap().entrySet();
            for (Iterator z = set.iterator(); z.hasNext();) {

                Map.Entry<String, List<ReportDTO>> entry = (Map.Entry<String, List<ReportDTO>>) z.next();

                List exportXLS = new ArrayList(1);
                exportXLS.addAll(entry.getValue());

                if (exportXLS.size() > 0) {

                    String date = entry.getKey();

                    row = sheet.createRow(rowCount);
                    rowCount += 1;
                    cell = row.createCell((short) 0);
                    cell.setCellValue("Date : " + date);
                    BigDecimal inwTotTxnAmt = BigDecimal.ZERO;
                    BigDecimal owTotTxnAmt = BigDecimal.ZERO;
                    long sno = 0;

                    for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                        row = sheet.createRow(rowCount);
                        rowCount += 1;
                        for (short j = 0; j < 11; j++) {
                            cell = row.createCell(j);

                            // for header
                            if (roww == 0) {
                                if (j == 0) {
                                    cell.setCellValue("S.No");
                                } else if (j == 1) {
                                    cell.setCellValue("Value Date");
                                } else if (j == 2) {
                                    cell.setCellValue("Msg Type");
                                } else if (j == 3) {
                                    cell.setCellValue("UTR Number");
                                } else if (j == 4) {
                                    cell.setCellValue("Sender Address");
                                } else if (j == 5) {
                                    cell.setCellValue("Receiver Address");
                                } else if (j == 6) {
                                    cell.setCellValue("Account Number");
                                } else if (j == 7) {
                                    cell.setCellValue("Beneficiary Details");
                                } else if (j == 8) {
                                    cell.setCellValue("Entry By");
                                } else if (j == 9) {
                                    cell.setCellValue("Cancelled By");
                                } else if (j == 10) {
                                    cell.setCellValue("Amount");
                                }
                            } else {
                                // Setting values in cell for each and every row
                                if (j == 0) {

                                    String no = null;
                                    sno += 1;
                                    no = String.valueOf(sno);
                                    cell.setCellValue(no);
                                } else if (j == 1) {

                                    String valueDate = null;
                                    if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                        valueDate = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                                        valueDate = InstaReportUtil.getDateInSpecificFormat(dateFormat,
                                                valueDate);
                                    }
                                    cell.setCellValue(valueDate);
                                } else if (j == 2) {

                                    String msgType = null;
                                    if (((ReportDTO) exportXLS.get(roww - 1)).getMsgSubType() != null) {
                                        msgType = ((ReportDTO) exportXLS.get(roww - 1)).getMsgSubType();
                                    }
                                    cell.setCellValue(msgType);
                                } else if (j == 3) {

                                    String utrNo = null;
                                    if (((ReportDTO) exportXLS.get(roww - 1)).getUtrNo() != null) {
                                        utrNo = ((ReportDTO) exportXLS.get(roww - 1)).getUtrNo();
                                    }
                                    cell.setCellValue(utrNo);
                                } else if (j == 4) {

                                    String sendAdd = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress() != null) {
                                        sendAdd = ((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress();
                                    }
                                    cell.setCellValue(sendAdd);

                                } else if (j == 5) {

                                    String recAdd = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress() != null) {
                                        recAdd = ((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress();
                                    }
                                    cell.setCellValue(recAdd);
                                } else if (j == 6) {

                                    String accNo = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getAccNo() != null) {
                                        accNo = ((ReportDTO) exportXLS.get(roww - 1)).getAccNo();
                                    }
                                    cell.setCellValue(accNo);
                                } else if (j == 7) {

                                    String beneName = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getBeneficiaryName() != null) {
                                        beneName = ((ReportDTO) exportXLS.get(roww - 1)).getBeneficiaryName();
                                    }
                                    cell.setCellValue(beneName);
                                } else if (j == 8) {

                                    String status = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getEntryBy() != null) {
                                        status = ((ReportDTO) exportXLS.get(roww - 1)).getEntryBy();
                                    }
                                    cell.setCellValue(status);
                                } else if (j == 9) {

                                    String status = null;

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getPassBy() != null) {
                                        status = ((ReportDTO) exportXLS.get(roww - 1)).getPassBy();
                                    }
                                    cell.setCellValue(status);
                                } else if (j == 10) {

                                    String inwTxnAmount = "0.00";

                                    if (((ReportDTO) exportXLS.get(roww - 1)).getTranType()
                                            .equalsIgnoreCase("inward")) {
                                        if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                                .compareTo(BigDecimal.ZERO) != 0.0) {
                                            inwTxnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                                        }
                                        inwTotTxnAmt = inwTotTxnAmt
                                                .add(new BigDecimal(inwTxnAmount).setScale(2));
                                        cell.setCellValue(new BigDecimal(inwTxnAmount).setScale(2).toString());
                                    }
                                }
                            }
                            cell.setCellStyle(caption_style);
                        }
                    }

                    row = sheet.createRow(rowCount);
                    rowCount += 1;
                    cell = row.createCell((short) 8);
                    cell.setCellValue("Total ( Date : " + date + " ) ");
                    cell = row.createCell((short) 9);
                    cell.setCellValue(inwTotTxnAmt.toString());
                    grandInwTotTxnAmt = grandInwTotTxnAmt.add(inwTotTxnAmt);
                    row = sheet.createRow(rowCount);
                    rowCount += 1;
                }

            }
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 9);
            cell.setCellValue("Total Amount : ");
            cell = row.createCell((short) 10);
            cell.setCellValue(grandInwTotTxnAmt.toString());
            book.write(out);
            out.flush();
            out.close();
        }
    } catch (Exception e) {
        logger.error("Exception while exporting NEFT Future dated txns Report into Excel" + e.getMessage());
        throw new Exception("Exception while exporting NEFT Future dated txns Report into Excel" + e);
    }
}

From source file:com.objectfrontier.insta.neft.reports.bean.InstaNEFTReportBean.java

License:Open Source License

/**
 * Method used to export NEFT Inward possible Return Payment Rejected by user Report
 * @author MohanaDevis//from  ww  w. jav a2  s .c  o m
 */
public void neftReturnPaymentRejectedReportExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "NEFT Return Payment Rejected", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("NEFT Inward Possible Return Payment Rejected By User Report between "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate())
                    + " and "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getToDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 4);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;

            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 10; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("UTR No");
                        } else if (j == 2) {
                            cell.setCellValue("Transaction Type");
                        } else if (j == 3) {
                            cell.setCellValue("Rejected By");
                        } else if (j == 4) {
                            cell.setCellValue("Sender Address");
                        } else if (j == 5) {
                            cell.setCellValue("Receiver Address");
                        } else if (j == 6) {
                            cell.setCellValue("Amount (Rs.)");
                        } else if (j == 7) {
                            cell.setCellValue("Business date");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String utrNo = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getUtrNo() != null) {
                                utrNo = ((ReportDTO) exportXLS.get(roww - 1)).getUtrNo();
                            }
                            cell.setCellValue(utrNo);
                        } else if (j == 2) {

                            String tranType = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getTranType() != null) {
                                tranType = ((ReportDTO) exportXLS.get(roww - 1)).getTranType();
                            }
                            cell.setCellValue(tranType);
                        } else if (j == 3) {

                            String userId = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getUserId() != null) {
                                userId = ((ReportDTO) exportXLS.get(roww - 1)).getUserId();
                            }
                            cell.setCellValue(userId);

                        } else if (j == 4) {

                            String sendAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress() != null) {
                                sendAdd = ((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress();
                            }
                            cell.setCellValue(sendAdd);

                        } else if (j == 5) {

                            String recAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress() != null) {
                                recAdd = ((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress();
                            }
                            cell.setCellValue(recAdd);
                        } else if (j == 6) {

                            String amount = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getAmt() != null) {
                                amount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                            }

                            cell.setCellValue(new BigDecimal(amount).setScale(2).toString());
                        } else if (j == 7) {

                            String date = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                date = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                            }

                            cell.setCellValue(date);
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            sheet = book.createSheet();

            book.write(out);
            out.flush();
            out.close();
        }
    } catch (Exception e) {
        logger.error(
                "Exception while creating Excel sheet file for NEFT inward Possible Return Payment rejected Report"
                        + 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 summary report in to Excel for both Inward and Outward.
  */*w  ww  .  j  a  v a2  s .  c o  m*/
  * @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.
  */*from   w  w w  . j  av  a  2  s .  c  om*/
  * @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.objectfrontier.insta.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the list in to Excel
 *///from w  w  w  . j  a  v  a  2  s  . c  om
public void reconcillationExportToExcel(ServletOutputStream out) throws Exception {

    try {
        List exportXLS = new ArrayList(1);
        List consolList = new ArrayList(1);
        int rowCount = 0;
        long sno = 0;
        //Adding the items to a list
        ReconcileReportDTO dto = (ReconcileReportDTO) getNewReportDto();
        for (Iterator i = dto.getReconcileReportDTOs().iterator(); i.hasNext();) {
            ReconcileReportDTO reconcileList = (ReconcileReportDTO) i.next();
            exportXLS.add(reconcileList);
        }

        ConsolidatedReconcileReportDTO consolDto = dto.getConsolidatedReportDTO();
        for (Iterator itr = consolDto.getConsolidatedReportDTOs().iterator(); itr.hasNext();) {
            ConsolidatedReconcileReportDTO conDto = (ConsolidatedReconcileReportDTO) itr.next();
            consolList.add(conDto);
        }

        if (exportXLS.size() != 0) {

            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "NEFT Reconciliation Reports", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);

            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("NEFT Reconciliation Report");

            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue(" ");
            cell = row.createCell((short) 1);
            cell.setCellValue(" ");
            cell = row.createCell((short) 2);
            cell.setCellValue("Reconciliation Report on");
            cell = row.createCell((short) 3);
            cell.setCellValue(
                    InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));

            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 6);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 9; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("Batch Time");
                        } else if (j == 2) {
                            cell.setCellValue("Gross Outward N06,N07(a)");
                        } else if (j == 3) {
                            cell.setCellValue("Add rescheduled from previous batch(b)");
                        } else if (j == 4) {
                            cell.setCellValue("Less rescheduled to next batch (c)");
                        } else if (j == 5) {
                            cell.setCellValue("Less Rejected N03, N09 (d)");
                        } else if (j == 6) {
                            cell.setCellValue("Net outward (e)");
                        } else if (j == 7) {
                            cell.setCellValue("Inward N02 (f)");
                        } else if (j == 8) {
                            cell.setCellValue("Aggregate for the batch (g)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;
                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String batchTime = null;
                            if (((ReconcileReportDTO) exportXLS.get(roww - 1)).getBatchTime() != null) {

                                batchTime = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getBatchTime();
                            } else {
                                batchTime = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getHeading();
                            }
                            cell.setCellValue(batchTime);
                        } else if (j == 2) {

                            //                                double outAmt = 0;
                            BigDecimal outAmt = BigDecimal.ZERO;

                            outAmt = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getGrossOutwardAmount()
                                    .setScale(2);

                            cell.setCellValue(outAmt.toString());
                        } else if (j == 3) {

                            //                                double reshPreAmt = 0;
                            BigDecimal reshPreAmt = BigDecimal.ZERO;
                            reshPreAmt = ((ReconcileReportDTO) exportXLS.get(roww - 1))
                                    .getRescheduledPrevBatchAmt().setScale(2);
                            cell.setCellValue(reshPreAmt.toString());
                        } else if (j == 4) {

                            //                                double reshNextAmt = 0;
                            BigDecimal reshNextAmt = BigDecimal.ZERO;

                            reshNextAmt = ((ReconcileReportDTO) exportXLS.get(roww - 1))
                                    .getRescheduledNextBatchAmt().setScale(2);
                            cell.setCellValue(reshNextAmt.toString());
                        } else if (j == 5) {

                            //                                double rejectAmt = 0;
                            BigDecimal rejectAmt = BigDecimal.ZERO;

                            rejectAmt = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getRejectedAmt()
                                    .setScale(2);
                            cell.setCellValue(rejectAmt.toString());
                        } else if (j == 6) {

                            //                                double netOutamt = 0;
                            BigDecimal netOutamt = BigDecimal.ZERO;
                            netOutamt = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getNetOutwardAmt()
                                    .setScale(2);
                            cell.setCellValue(netOutamt.toString());
                        } else if (j == 7) {

                            //                                double netInamt = 0;
                            BigDecimal netInamt = BigDecimal.ZERO;

                            netInamt = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getNetInwardAmt()
                                    .setScale(2);
                            cell.setCellValue(netInamt.toString());
                        } else if (j == 8) {

                            //                                double aggAmt = 0;
                            BigDecimal aggAmt = BigDecimal.ZERO;

                            aggAmt = ((ReconcileReportDTO) exportXLS.get(roww - 1)).getAggregateAmt()
                                    .setScale(2);
                            cell.setCellValue(aggAmt.toString());
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }

            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("");
            cell = row.createCell((short) 1);
            cell.setCellValue("");
            cell = row.createCell((short) 2);
            cell.setCellValue("Consolidated Report for the Day");

            if (consolList.size() > 0) {

                for (int size = consolList.size(), rows = 0; rows <= size; rows++) {

                    row = sheet.createRow(rowCount);
                    rowCount += 1;
                    for (short j = 0; j < 3; j++) {
                        cell = row.createCell(j);
                        if (rows == 0) {

                            if (j == 1) {
                                cell.setCellValue("RBI Account");
                            } else if (j == 2) {
                                cell.setCellValue("NEFT Account");
                            }
                        } else {

                            if (j == 0) {
                                String heading = null;

                                heading = ((ConsolidatedReconcileReportDTO) consolList.get(rows - 1))
                                        .getHeading();
                                cell.setCellValue(heading);
                            } else if (j == 1) {
                                //                                    double rbiAcc = 0;
                                String rbiAcc = "0.00";

                                rbiAcc = ((ConsolidatedReconcileReportDTO) consolList.get(rows - 1))
                                        .getRBIAccountAmt();
                                cell.setCellValue(rbiAcc);
                            } else if (j == 2) {
                                //                                    double neftAcc = 0;
                                String neftAcc = "0.00";

                                neftAcc = ((ConsolidatedReconcileReportDTO) consolList.get(rows - 1))
                                        .getNEFTAccountAmt();
                                cell.setCellValue(neftAcc);
                            }
                        }
                    }
                }
            }
            sheet = book.createSheet();

            book.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.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the r41 inward report in to Excel
 *///w w w .jav  a 2 s  .  co  m
public void generateR41InwardExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;
        BigDecimal totAmt = BigDecimal.ZERO;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "R41(CPN) Received", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("Customer Payments Received - Grouped By Sender Address on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 3);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 5; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("Sender Address");
                        } else if (j == 2) {
                            cell.setCellValue("Value Date");
                        } else if (j == 3) {
                            cell.setCellValue("No. of Txns");
                        } else if (j == 4) {
                            cell.setCellValue("Total Txn Amount(Rs.)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String sendAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress() != null) {
                                sendAdd = ((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress();
                            }
                            cell.setCellValue(sendAdd);
                        } else if (j == 2) {

                            String valueDate = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                valueDate = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                                valueDate = InstaReportUtil.getDateInSpecificFormat(dateFormat, valueDate);
                            }
                            cell.setCellValue(valueDate);

                        } else if (j == 3) {

                            long txnCount = 0;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getCount() != 0) {
                                txnCount = ((ReportDTO) exportXLS.get(roww - 1)).getCount();
                            }
                            cell.setCellValue(txnCount);

                        } else if (j == 4) {

                            //                                double txnAmount = 0.0;
                            String txnAmount = "0.00";

                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {
                                txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                            }
                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                            totAmt = totAmt.add(new BigDecimal(txnAmount).setScale(2));
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            row = sheet.createRow(rowCount);
            cell = row.createCell((short) 3);
            cell.setCellValue("Total : ");
            cell = row.createCell((short) 4);
            cell.setCellValue(totAmt.toString());
            sheet = book.createSheet();

            book.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.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the r41 outward report in to Excel
 *//*from www . ja  v a  2s.  c  o m*/
public void generateR41OutwardExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;
        BigDecimal totAmt = BigDecimal.ZERO;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "R41(CPR) Submitted", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("Customer Payments Submitted - Grouped By Receiver Address on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 3);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 5; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("Value Date");
                        } else if (j == 2) {
                            cell.setCellValue("Receiver Address");
                        } else if (j == 3) {
                            cell.setCellValue("No. of Txns");
                        } else if (j == 4) {
                            cell.setCellValue("Total Txn Amount(Rs.)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String valueDate = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                valueDate = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                                valueDate = InstaReportUtil.getDateInSpecificFormat(dateFormat, valueDate);
                            }
                            cell.setCellValue(valueDate);

                        } else if (j == 2) {

                            String recAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress() != null) {
                                recAdd = ((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress();
                            }
                            cell.setCellValue(recAdd);
                        } else if (j == 3) {

                            long txnCount = 0;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getCount() != 0) {
                                txnCount = ((ReportDTO) exportXLS.get(roww - 1)).getCount();
                            }
                            cell.setCellValue(txnCount);

                        } else if (j == 4) {

                            //                                double txnAmount = 0.0;
                            String txnAmount = "0.00";

                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {
                                txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                            }
                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                            totAmt = totAmt.add(new BigDecimal(txnAmount).setScale(2));
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            row = sheet.createRow(rowCount);
            cell = row.createCell((short) 3);
            cell.setCellValue("Total : ");
            cell = row.createCell((short) 4);
            cell.setCellValue(totAmt.toString());
            sheet = book.createSheet();

            book.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.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the r42 inward report in to Excel
 *///from   www.  ja  va 2s .  com
public void generateR42InwardExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;
        BigDecimal totAmt = BigDecimal.ZERO;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "R42(IPN) Received", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("Interbank Payments Received - Grouped By Sender Address on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 3);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 5; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("Sender Address");
                        } else if (j == 2) {
                            cell.setCellValue("Value Date");
                        } else if (j == 3) {
                            cell.setCellValue("No. of Txns");
                        } else if (j == 4) {
                            cell.setCellValue("Total Txn Amount(Rs.)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String sendAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress() != null) {
                                sendAdd = ((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress();
                            }
                            cell.setCellValue(sendAdd);
                        } else if (j == 2) {

                            String valueDate = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                valueDate = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                                valueDate = InstaReportUtil.getDateInSpecificFormat(dateFormat, valueDate);
                            }
                            cell.setCellValue(valueDate);
                        } else if (j == 3) {

                            long txnCount = 0;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getCount() != 0) {
                                txnCount = ((ReportDTO) exportXLS.get(roww - 1)).getCount();
                            }
                            cell.setCellValue(txnCount);

                        } else if (j == 4) {

                            //                                double txnAmount = 0.0;
                            String txnAmount = "0.00";
                            //                                if (((ReportDTO)exportXLS
                            //                                .get(roww - 1)).getAmount() != 0.0) {
                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {
                                txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                            }
                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                            totAmt = totAmt.add(new BigDecimal(txnAmount).setScale(2));
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            row = sheet.createRow(rowCount);
            cell = row.createCell((short) 3);
            cell.setCellValue("Total : ");
            cell = row.createCell((short) 4);
            cell.setCellValue(totAmt.toString());
            sheet = book.createSheet();

            book.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.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the r42 outward report in to Excel
 *//*  w w w  .  ja  va 2  s .c o  m*/
public void generateR42OutwardExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;
        BigDecimal totAmt = BigDecimal.ZERO;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "R42(IPR) Submitted", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("Interbank Payments Submitted - Grouped By Receiver Address on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 3);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 5; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("Receiver Address");
                        } else if (j == 2) {
                            cell.setCellValue("VALUE DATE");
                        } else if (j == 3) {
                            cell.setCellValue("No. of Txns");
                        } else if (j == 4) {
                            cell.setCellValue("Total Txn Amount(Rs.)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String recAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress() != null) {
                                recAdd = ((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress();
                            }
                            cell.setCellValue(recAdd);
                        } else if (j == 2) {

                            String valueDate = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getValueDate() != null) {
                                valueDate = ((ReportDTO) exportXLS.get(roww - 1)).getValueDate();
                                valueDate = InstaReportUtil.getDateInSpecificFormat(dateFormat, valueDate);
                            }
                            cell.setCellValue(valueDate);

                        } else if (j == 3) {

                            long txnCount = 0;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getCount() != 0) {
                                txnCount = ((ReportDTO) exportXLS.get(roww - 1)).getCount();
                            }
                            cell.setCellValue(txnCount);

                        } else if (j == 4) {

                            //                                double txnAmount = 0.0;
                            String txnAmount = "0.00";

                            if ((new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO)) != 0.0) {
                                txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                            }
                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                            totAmt = totAmt.add(new BigDecimal(txnAmount).setScale(2));
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            row = sheet.createRow(rowCount);
            cell = row.createCell((short) 3);
            cell.setCellValue("Total : ");
            cell = row.createCell((short) 4);
            cell.setCellValue(totAmt.toString());
            sheet = book.createSheet();

            book.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.rtgs.reports.bean.InstaReportBean.java

License:Open Source License

/**
 * Method used to export the Graduated Payment report in to Excel
 *//*from ww w. j  a  v a  2  s  .  com*/
public void generateGraduatedPaymentExportToExcel(ServletOutputStream out) throws Exception {

    try {

        List exportXLS = new ArrayList(1);
        long sno = 0;
        int rowCount = 0;

        //Adding the items to a list
        for (Iterator i = getReportDTOs().iterator(); i.hasNext();) {
            ReportDTO dtoList = (ReportDTO) i.next();
            exportXLS.add(dtoList);

        }

        //Only If the list is not empty
        if (exportXLS.size() != 0) {

            // start to export excel
            HSSFWorkbook book = new HSSFWorkbook();
            HSSFSheet sheet = book.createSheet();
            HSSFRow row = null;
            HSSFCell cell = null;
            HSSFFont caption_font = null;
            HSSFCellStyle caption_style = null;

            book.setSheetName(0, "Graduated Payment Report", HSSFWorkbook.ENCODING_COMPRESSED_UNICODE);

            caption_font = book.createFont();
            caption_font.setFontHeightInPoints((short) 10);
            caption_font.setFontName("Verdana");
            caption_style = book.createCellStyle();
            caption_style.setFont(caption_font);
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 0);
            cell.setCellValue("Graduated Payment Report on "); //Heading modified
            cell = row.createCell((short) 1);
            cell.setCellValue(
                    InstaReportUtil.getDateInSpecificFormat(dateFormat, getReportDto().getValueDate()));
            row = sheet.createRow(rowCount);
            rowCount += 1;
            cell = row.createCell((short) 7);
            String dateForm = currentReportPrintTime.substring(0, 11);
            String time = currentReportPrintTime.substring(11);
            cell.setCellValue("Report Printed on "
                    + InstaReportUtil.getDateInSpecificFormat(dateFormat, dateForm) + time);
            rowCount += 1;
            for (int i = exportXLS.size(), roww = 0; roww <= i; roww++) {

                row = sheet.createRow(rowCount);
                rowCount += 1;
                for (short j = 0; j < 10; j++) {
                    cell = row.createCell(j);

                    // for header
                    if (roww == 0) {
                        if (j == 0) {
                            cell.setCellValue("S.No");
                        } else if (j == 1) {
                            cell.setCellValue("UTR No");
                        } else if (j == 2) {
                            cell.setCellValue("Msg Type");
                        } else if (j == 3) {
                            cell.setCellValue("Tran Type");
                        } else if (j == 4) {
                            cell.setCellValue("Sender Address");
                        } else if (j == 5) {
                            cell.setCellValue("Receiver Address");
                        } else if (j == 6) {
                            cell.setCellValue("Credit Amount (Rs.)");
                        } else if (j == 7) {
                            cell.setCellValue("Debit Amount (Rs.)");
                        } else if (j == 8) {
                            cell.setCellValue("Balance (Rs.)");
                        }
                    } else {
                        // Setting values in cell for each and every row
                        if (j == 0) {

                            String no = null;

                            sno += 1;
                            no = String.valueOf(sno);
                            cell.setCellValue(no);
                        } else if (j == 1) {

                            String utrNo = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getUtrNo() != null) {
                                utrNo = ((ReportDTO) exportXLS.get(roww - 1)).getUtrNo();
                            }
                            cell.setCellValue(utrNo);
                        } else if (j == 2) {

                            String msgType = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getMsgType() != null) {
                                msgType = ((ReportDTO) exportXLS.get(roww - 1)).getMsgType();
                            }
                            cell.setCellValue(msgType);
                        } else if (j == 3) {

                            String tranType = null;
                            if (((ReportDTO) exportXLS.get(roww - 1)).getTranType() != null) {
                                tranType = ((ReportDTO) exportXLS.get(roww - 1)).getTranType();
                            }
                            cell.setCellValue(tranType);
                        } else if (j == 4) {

                            String sendAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress() != null) {
                                sendAdd = ((ReportDTO) exportXLS.get(roww - 1)).getSenderAddress();
                            }
                            cell.setCellValue(sendAdd);

                        } else if (j == 5) {

                            String recAdd = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress() != null) {
                                recAdd = ((ReportDTO) exportXLS.get(roww - 1)).getReceiverAddress();
                            }
                            cell.setCellValue(recAdd);
                        } else if (j == 6) {

                            String debitCredit = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getDebitCredit() != null) {
                                debitCredit = ((ReportDTO) exportXLS.get(roww - 1)).getDebitCredit();
                            }
                            String txnAmount = "0.00";
                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {
                                if (debitCredit != null && debitCredit.equalsIgnoreCase("credit")) {

                                    txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                                }
                            }

                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                        } else if (j == 7) {

                            String debitCredit = null;

                            if (((ReportDTO) exportXLS.get(roww - 1)).getDebitCredit() != null) {
                                debitCredit = ((ReportDTO) exportXLS.get(roww - 1)).getDebitCredit();
                            }
                            String txnAmount = "0.00";
                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getAmt())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {

                                if (debitCredit != null && debitCredit.equalsIgnoreCase("debit")) {

                                    txnAmount = ((ReportDTO) exportXLS.get(roww - 1)).getAmt();
                                }
                            }

                            cell.setCellValue(new BigDecimal(txnAmount).setScale(2).toString());
                        } else if (j == 8) {

                            String balance = "0.00";

                            if (new BigDecimal(((ReportDTO) exportXLS.get(roww - 1)).getBalance())
                                    .compareTo(BigDecimal.ZERO) != 0.0) {
                                balance = ((ReportDTO) exportXLS.get(roww - 1)).getBalance();
                            }
                            cell.setCellValue(new BigDecimal(balance).setScale(2).toString());
                        }
                    }
                    cell.setCellStyle(caption_style);
                }
            }
            sheet = book.createSheet();

            book.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);
    }
}