Example usage for org.apache.poi.hssf.usermodel HSSFDataFormat getFormat

List of usage examples for org.apache.poi.hssf.usermodel HSSFDataFormat getFormat

Introduction

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

Prototype

public String getFormat(short index) 

Source Link

Document

get the format string that matches the given format index

Usage

From source file:com.smi.travel.controller.excel.booking.OutboundPackageSummary.java

public void genOutboundPackageSummaryReport(HSSFWorkbook wb, List opslist) {
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    String sheetName = "Sheet1";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);

    OutboundPackageSummaryView dataheader = new OutboundPackageSummaryView();

    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    styleC21.setDataFormat(currency.getFormat("#,##0.00"));
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);

    if (!opslist.isEmpty()) {
        dataheader = (OutboundPackageSummaryView) opslist.get(0);

        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cell1 = row1.createCell(0);
        cell1.setCellValue("Package Summary");
        styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
        cell1.setCellStyle(styleC1);/*  w ww.  ja va  2 s .  co m*/
        sheet.addMergedRegion(CellRangeAddress.valueOf("A1:F1"));

        // Row 2
        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("City : ");
        cell21.setCellStyle(styleC21);
        HSSFCell cell22 = row2.createCell(1);
        cell22.setCellValue(dataheader.getHeadercity());
        cell22.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B2:D2"));
        HSSFCell cell23 = row2.createCell(4);
        cell23.setCellValue("Pay By : ");
        cell23.setCellStyle(styleC21);
        HSSFCell cell24 = row2.createCell(5);
        cell24.setCellValue(dataheader.getHeaderpayby());
        cell24.setCellStyle(styleC22);

        // Row 3
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Package : ");
        cell31.setCellStyle(styleC21);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(dataheader.getHeaderpackage());
        cell32.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
        HSSFCell cell33 = row3.createCell(4);
        cell33.setCellValue("Bank Transfer : ");
        cell33.setCellStyle(styleC21);
        HSSFCell cell34 = row3.createCell(5);
        cell34.setCellValue(dataheader.getHeaderbank());
        cell34.setCellStyle(styleC22);

        // Row 4
        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Date : ");
        cell41.setCellStyle(styleC21);
        HSSFCell cell42 = row4.createCell(1);
        cell42.setCellValue(dataheader.getHeaderdate());
        cell42.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));
        HSSFCell cell43 = row4.createCell(4);
        cell43.setCellValue("Status : ");
        cell43.setCellStyle(styleC21);
        HSSFCell cell44 = row4.createCell(5);
        cell44.setCellValue(dataheader.getHeaderstatus());
        cell44.setCellStyle(styleC22);

    }
    // Header Table
    HSSFCellStyle styleC3 = wb.createCellStyle();
    styleC3.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleC3.setAlignment(styleC3.ALIGN_CENTER);
    styleC3.setVerticalAlignment(styleC3.VERTICAL_CENTER);
    styleC3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderTop(HSSFCellStyle.BORDER_THIN);

    HSSFCellStyle styletop = wb.createCellStyle();
    styletop.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styletop.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styletop.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styletop.setAlignment(styletop.ALIGN_CENTER);
    styletop.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styletop.setVerticalAlignment(styletop.VERTICAL_CENTER);

    HSSFCellStyle stylebottom = wb.createCellStyle();
    stylebottom.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    stylebottom.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    stylebottom.setBorderRight(HSSFCellStyle.BORDER_THIN);
    stylebottom.setAlignment(styletop.ALIGN_CENTER);
    stylebottom.setFont(excelFunction.getHeaderTable(wb.createFont()));
    stylebottom.setVerticalAlignment(styletop.VERTICAL_CENTER);
    //        
    //        for(int i = 0 ; i < 20 ; i++){
    //            HSSFRow row4 = sheet.createRow(4);
    //            HSSFCell cell = row4.createCell(i);
    //            cell.setCellStyle(stylebottom);
    //        }

    HSSFRow row5 = sheet.createRow(5);
    HSSFCell cell61 = row5.createCell(0);
    cell61.setCellValue("SALE DATE");
    cell61.setCellStyle(styletop);
    HSSFCell cell62 = row5.createCell(1);
    cell62.setCellValue("RECORD NO");
    cell62.setCellStyle(styletop);
    HSSFCell cell63 = row5.createCell(2);
    cell63.setCellValue("REF NO");
    cell63.setCellStyle(styletop);
    HSSFCell cell64 = row5.createCell(3);
    cell64.setCellValue("TOUR CODE");
    cell64.setCellStyle(styletop);
    HSSFCell cell65 = row5.createCell(4);
    cell65.setCellValue("TOUR NAME");
    cell65.setCellStyle(styletop);
    HSSFCell cell66 = row5.createCell(5);
    cell66.setCellValue("CUSTOMER NAME");
    cell66.setCellStyle(styletop);
    sheet.autoSizeColumn(5);
    HSSFCell cell67 = row5.createCell(6);
    cell67.setCellValue("PERIOD");
    cell67.setCellStyle(styletop);
    HSSFCell cell68 = row5.createCell(7);
    cell68.setCellValue("PAX");
    cell68.setCellStyle(styletop);
    HSSFCell cell068 = row5.createCell(8);
    cell068.setCellValue("");
    cell068.setCellStyle(styletop);
    HSSFCell cell069 = row5.createCell(9);
    cell069.setCellValue("");
    cell069.setCellStyle(styletop);
    HSSFCell cell70 = row5.createCell(10);
    cell70.setCellValue("TOTAL");
    cell70.setCellStyle(styletop);
    HSSFCell cell71 = row5.createCell(11);
    cell71.setCellValue("TOTAL");
    cell71.setCellStyle(styletop);
    HSSFCell cell72 = row5.createCell(12);
    cell72.setCellValue("TOTAL");
    cell72.setCellStyle(styletop);
    HSSFCell cell73 = row5.createCell(13);
    cell73.setCellValue("BANK");
    cell73.setCellStyle(styletop);
    HSSFCell cell74 = row5.createCell(14);
    cell74.setCellValue("DATE");
    cell74.setCellStyle(styletop);
    HSSFCell cell75 = row5.createCell(15);
    cell75.setCellValue("STATUS");
    cell75.setCellStyle(styletop);
    HSSFCell cell76 = row5.createCell(16);
    cell76.setCellValue("REMARK");
    cell76.setCellStyle(styletop);
    HSSFCell cell77 = row5.createCell(17);
    cell77.setCellValue("SELLER");
    cell77.setCellStyle(styletop);

    sheet.addMergedRegion(CellRangeAddress.valueOf("A6:A7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("B6:B7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("C6:C7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("D6:D7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("E6:E7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("F6:F7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("G6:G7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("H6:J6"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("P6:P7"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("R6:R7"));

    HSSFRow row6 = sheet.createRow(6);
    HSSFCell cell78 = row6.createCell(0);
    cell78.setCellStyle(stylebottom);
    HSSFCell cell79 = row6.createCell(1);
    cell79.setCellStyle(stylebottom);
    HSSFCell cell80 = row6.createCell(2);
    cell80.setCellValue("");
    cell80.setCellStyle(stylebottom);
    HSSFCell cell81 = row6.createCell(3);
    cell81.setCellValue("");
    cell81.setCellStyle(stylebottom);
    HSSFCell cell82 = row6.createCell(4);
    cell82.setCellValue("");
    cell82.setCellStyle(stylebottom);
    HSSFCell cell83 = row6.createCell(5);
    cell83.setCellValue("");
    cell83.setCellStyle(stylebottom);
    HSSFCell cell84 = row6.createCell(6);
    cell84.setCellValue("");
    cell84.setCellStyle(stylebottom);
    HSSFCell cell85 = row6.createCell(7);
    cell85.setCellValue("AD");
    cell85.setCellStyle(styleC3);
    HSSFCell cell86 = row6.createCell(8);
    cell86.setCellValue("CH");
    cell86.setCellStyle(styleC3);
    HSSFCell cell87 = row6.createCell(9);
    cell87.setCellValue("IN");
    cell87.setCellStyle(styleC3);
    HSSFCell cell91 = row6.createCell(10);
    cell91.setCellValue("NETT");
    cell91.setCellStyle(stylebottom);
    HSSFCell cell92 = row6.createCell(11);
    cell92.setCellValue("SALE");
    cell92.setCellStyle(stylebottom);
    HSSFCell cell93 = row6.createCell(12);
    cell93.setCellValue("PROFIT");
    cell93.setCellStyle(stylebottom);
    HSSFCell cell94 = row6.createCell(13);
    cell94.setCellValue("TRSF");
    cell94.setCellStyle(stylebottom);
    HSSFCell cell95 = row6.createCell(14);
    cell95.setCellValue("TRSF");
    cell95.setCellStyle(stylebottom);
    HSSFCell cell96 = row6.createCell(15);
    cell96.setCellValue("");
    cell96.setCellStyle(stylebottom);
    HSSFCell cell97 = row6.createCell(16);
    cell97.setCellValue("SUPPLIER");
    cell97.setCellStyle(stylebottom);
    HSSFCell cell98 = row6.createCell(17);
    cell98.setCellValue("");
    cell98.setCellStyle(stylebottom);

    //Detail of Table
    int count = 7;
    HSSFCellStyle styleC23 = wb.createCellStyle();
    styleC23.setAlignment(styleC23.ALIGN_CENTER);
    styleC23.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC23.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC23.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC23.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC23.setDataFormat(currency.getFormat("#,##0"));

    HSSFCellStyle styleC24 = wb.createCellStyle();
    styleC24.setAlignment(styleC24.ALIGN_LEFT);
    styleC24.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC24.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC24.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC24.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    HSSFCellStyle styleC25 = wb.createCellStyle();
    styleC25.setAlignment(styleC25.ALIGN_RIGHT);
    styleC25.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC25.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC26 = wb.createCellStyle();
    styleC26.setAlignment(styleC26.ALIGN_CENTER);
    styleC26.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    for (int i = 0; i < opslist.size(); i++) {
        OutboundPackageSummaryView data = (OutboundPackageSummaryView) opslist.get(i);
        HSSFRow row = sheet.createRow(count + i);

        HSSFCell celldata0 = row.createCell(0);
        celldata0.setCellValue(data.getDepartdate());
        celldata0.setCellStyle(styleC23);

        HSSFCell celldata1 = row.createCell(1);
        celldata1.setCellValue(data.getRecondno());
        celldata1.setCellStyle(styleC24);

        HSSFCell celldata2 = row.createCell(2);
        celldata2.setCellValue(data.getRefno());
        celldata2.setCellStyle(styleC24);

        HSSFCell celldata3 = row.createCell(3);
        celldata3.setCellValue(data.getPackagecode());
        celldata3.setCellStyle(styleC24);

        HSSFCell celldata4 = row.createCell(4);
        celldata4.setCellValue(data.getPackagename());
        celldata4.setCellStyle(styleC24);

        HSSFCell celldata5 = row.createCell(5);
        celldata5.setCellValue(data.getLeader());
        celldata5.setCellStyle(styleC24);

        HSSFCell celldata6 = row.createCell(6);
        celldata6.setCellValue(data.getPeriod());
        celldata6.setCellStyle(styleC26);

        HSSFCell celldata7 = row.createCell(7);
        celldata7.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxadult())) ? 0
                : new BigDecimal(data.getPaxadult()).doubleValue());
        celldata7.setCellStyle(styleC23);

        HSSFCell celldata8 = row.createCell(8);
        celldata8.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxchild())) ? 0
                : new BigDecimal(data.getPaxchild()).doubleValue());
        celldata8.setCellStyle(styleC23);

        //set data 
        HSSFCell celldata9 = row.createCell(9);
        celldata9.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxinfant())) ? 0
                : new BigDecimal(data.getPaxinfant()).doubleValue());
        celldata9.setCellStyle(styleC23);

        HSSFCell celldata10 = row.createCell(10);
        celldata10.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNet())) ? 0
                : new BigDecimal(data.getNet()).doubleValue());
        celldata10.setCellStyle(styleC25);

        HSSFCell celldata11 = row.createCell(11);
        celldata11.setCellValue("".equalsIgnoreCase(String.valueOf(data.getSell())) ? 0
                : new BigDecimal(data.getSell()).doubleValue());
        celldata11.setCellStyle(styleC25);

        HSSFCell celldata12 = row.createCell(12);
        celldata12.setCellValue("".equalsIgnoreCase(String.valueOf(data.getProfit())) ? 0
                : new BigDecimal(data.getProfit()).doubleValue());
        celldata12.setCellStyle(styleC25);

        HSSFCell celldata13 = row.createCell(13);
        celldata13.setCellValue(data.getBanktransfer());
        celldata13.setCellStyle(styleC23);

        HSSFCell celldata14 = row.createCell(14);
        celldata14.setCellValue(data.getTransferdate());
        celldata14.setCellStyle(styleC23);

        HSSFCell celldata15 = row.createCell(15);
        celldata15.setCellValue(data.getStatusname());
        celldata15.setCellStyle(styleC23);

        HSSFCell celldata16 = row.createCell(16);
        celldata16.setCellValue(data.getRemark());
        celldata16.setCellStyle(styleC24);

        HSSFCell celldata17 = row.createCell(17);
        celldata17.setCellValue(data.getSeller());
        celldata17.setCellStyle(styleC24);

    }

    for (int j = 0; j < 21; j++) {
        sheet.autoSizeColumn(j);
    }

    sheet.setColumnWidth(0, 256 * 15);
    sheet.setColumnWidth(1, 256 * 15);
    sheet.setColumnWidth(2, 256 * 15);
    sheet.setColumnWidth(3, 256 * 15);
    //        sheet.setColumnWidth(4, 256*25);
    //        sheet.setColumnWidth(5, 256*25);
    sheet.setColumnWidth(6, 256 * 15);
    sheet.setColumnWidth(10, 256 * 15);
    sheet.setColumnWidth(11, 256 * 15);
    sheet.setColumnWidth(12, 256 * 15);
    sheet.setColumnWidth(13, 256 * 15);
    sheet.setColumnWidth(14, 256 * 15);
    sheet.setColumnWidth(15, 256 * 15);
    sheet.setColumnWidth(16, 256 * 15);
    sheet.setColumnWidth(17, 256 * 15);
    //        sheet.setColumnWidth(18, 256*15);
    //        sheet.setColumnWidth(19, 256*15);
    //        sheet.setColumnWidth(20, 256*15);

}

From source file:com.smi.travel.controller.excel.booking.OutboundProductSummary.java

public void getPaymentProfitLossSummary(HSSFWorkbook wb, List listPayment) {
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    String sheetName = "Sheet1";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);

    PaymentProfitLossView dataheader = new PaymentProfitLossView();

    HSSFDataFormat currency = wb.createDataFormat();

    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    styleC21.setDataFormat(currency.getFormat("#,##0"));
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);

    HSSFCellStyle styleC23 = wb.createCellStyle();
    styleC23.setAlignment(styleC23.ALIGN_CENTER);

    HSSFCellStyle styleGroup = wb.createCellStyle();
    styleGroup.setAlignment(styleGroup.ALIGN_CENTER);
    styleGroup.setFont(excelFunction.getHeaderTable(wb.createFont()));

    HSSFCellStyle styleGroupdata = wb.createCellStyle();
    styleGroupdata.setAlignment(styleGroupdata.ALIGN_LEFT);
    //        styleGroupdata.setFont(excelFunction.getHeaderTable(wb.createFont()));

    HSSFCellStyle styleC25 = wb.createCellStyle();
    styleC25.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC25.setDataFormat(currency.getFormat("#,##0.00"));
    styleC25.setVerticalAlignment(styleC25.VERTICAL_CENTER);

    HSSFCellStyle styleC26 = wb.createCellStyle();
    styleC26.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC26.setDataFormat(currency.getFormat("#,##0"));
    styleC26.setAlignment(styleC26.ALIGN_CENTER);
    styleC26.setVerticalAlignment(styleC26.VERTICAL_CENTER);
    //        styleC26.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    //        styleC26.setFillPattern(styleC26.SOLID_FOREGROUND);

    HSSFCellStyle styleC27 = wb.createCellStyle();
    styleC27.setAlignment(styleC27.ALIGN_RIGHT);
    styleC27.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC28 = wb.createCellStyle();
    styleC28.setAlignment(styleC28.ALIGN_CENTER);
    styleC28.setDataFormat(currency.getFormat("#,##0"));

    HSSFCellStyle styleC29 = wb.createCellStyle();
    styleC29.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC29.setWrapText(true);//w w w  .java 2s.  c om
    styleC29.setVerticalAlignment(styleC29.VERTICAL_CENTER);
    //        styleC29.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    //        styleC29.setFillPattern(styleC29.SOLID_FOREGROUND);

    HSSFCellStyle styleC30 = wb.createCellStyle();
    styleC30.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC30.setAlignment(styleC22.ALIGN_CENTER);
    styleC30.setWrapText(true);
    styleC30.setVerticalAlignment(styleC30.VERTICAL_CENTER);
    //        styleC30.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    //        styleC30.setFillPattern(styleC30.SOLID_FOREGROUND);

    HSSFCellStyle styleTotal = wb.createCellStyle();
    styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleTotal.setWrapText(true);
    styleTotal.setVerticalAlignment(styleTotal.VERTICAL_CENTER);
    styleTotal.setAlignment(styleTotal.ALIGN_CENTER);
    styleTotal.setFont(excelFunction.getHeadDetailBoldFont(wb.createFont()));
    styleTotal.setDataFormat(currency.getFormat("#,##0"));
    //        styleTotal.setFillForegroundColor(IndexedColors.BLUE.getIndex());
    //        styleTotal.setFillPattern(styleTotal.SOLID_FOREGROUND);

    HSSFCellStyle styleTotalCurrency = wb.createCellStyle();
    styleTotalCurrency.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleTotalCurrency.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleTotalCurrency.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleTotalCurrency.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleTotalCurrency.setWrapText(true);
    styleTotalCurrency.setVerticalAlignment(styleTotalCurrency.VERTICAL_CENTER);
    styleTotalCurrency.setAlignment(styleTotalCurrency.ALIGN_RIGHT);
    styleTotalCurrency.setFont(excelFunction.getHeadDetailBoldFont(wb.createFont()));
    styleTotalCurrency.setDataFormat(currency.getFormat("#,##0.00"));
    //        styleTotalCurrency.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
    //        styleTotalCurrency.setFillPattern(styleTotalCurrency.SOLID_FOREGROUND);

    if (!listPayment.isEmpty()) {
        dataheader = (PaymentProfitLossView) listPayment.get(0);
        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cell1 = row1.createCell(0);
        cell1.setCellValue("Profit & Loss Summary");
        styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
        cell1.setCellStyle(styleC1);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A1:G1"));

        // Row 2
        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("Owner : ");
        cell21.setCellStyle(styleC21);
        HSSFCell cell22 = row2.createCell(1);
        cell22.setCellValue(dataheader.getHeaderowner());
        cell22.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B2:D2"));
        HSSFCell cell23 = row2.createCell(4);
        cell23.setCellValue("Invoice Sup : ");
        cell23.setCellStyle(styleC21);
        HSSFCell cell24 = row2.createCell(5);
        cell24.setCellValue(dataheader.getHeaderinvsup());
        cell24.setCellStyle(styleC22);

        // Row 3
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("City : ");
        cell31.setCellStyle(styleC21);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(dataheader.getHeadercity());
        cell32.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
        HSSFCell cell33 = row3.createCell(4);
        cell33.setCellValue("Group : ");
        cell33.setCellStyle(styleC21);
        HSSFCell cell34 = row3.createCell(5);
        cell34.setCellValue(dataheader.getHeadergroup());
        cell34.setCellStyle(styleC22);

        // Row 4
        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Product Type : ");
        cell41.setCellStyle(styleC21);
        HSSFCell cell42 = row4.createCell(1);
        cell42.setCellValue(dataheader.getHeaderproducttype());
        cell42.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));
        HSSFCell cell43 = row4.createCell(4);
        cell43.setCellValue("Pay Date : ");
        cell43.setCellStyle(styleC21);
        HSSFCell cell44 = row4.createCell(5);
        cell44.setCellValue(dataheader.getHeaderpaydate());
        cell44.setCellStyle(styleC22);

        // Row 5
        HSSFRow row5 = sheet.createRow(4);
        HSSFCell cell51 = row5.createCell(0);
        cell51.setCellValue("Departure Date : ");
        cell51.setCellStyle(styleC21);
        HSSFCell cell52 = row5.createCell(1);
        cell52.setCellValue(dataheader.getHeaderdepartdate());
        cell52.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));
        HSSFCell cell53 = row5.createCell(4);
        cell53.setCellValue("Invoice Date : ");
        cell53.setCellStyle(styleC21);
        HSSFCell cell54 = row5.createCell(5);
        cell54.setCellValue(dataheader.getHeaderinvdate());
        cell54.setCellStyle(styleC22);
    }
    // Header Table
    HSSFCellStyle styleC3 = wb.createCellStyle();
    styleC3.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleC3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC3.setAlignment(styleC3.ALIGN_CENTER);
    //        styleC3.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
    //        styleC3.setFillPattern(styleC3.SOLID_FOREGROUND);
    // Detail of Table
    String temp = "group";
    int count = 6;
    int ktemp = 9;
    String temprefno = "";
    //Total
    BigDecimal totalpax = new BigDecimal("0.00");
    BigDecimal totalsale = new BigDecimal("0.00");
    BigDecimal totalcost = new BigDecimal("0.00");
    BigDecimal totalprofit = new BigDecimal("0.00");

    BigDecimal totalpaxAll = new BigDecimal("0.00");
    BigDecimal totalsaleAll = new BigDecimal("0.00");
    BigDecimal totalcostAll = new BigDecimal("0.00");
    BigDecimal totalprofitAll = new BigDecimal("0.00");

    for (int i = 0; i < listPayment.size(); i++) {
        PaymentProfitLossView data = (PaymentProfitLossView) listPayment.get(i);
        String groupby = data.getHeadergroup();
        String groupbytemp = "";

        if ("OWNER".equalsIgnoreCase(groupby)) {
            groupbytemp = data.getOwner();
        } else if ("PRODUCT TYPE".equalsIgnoreCase(groupby)) {
            groupbytemp = data.getProducttype();
        } else if ("CITY".equalsIgnoreCase(groupby)) {
            groupbytemp = data.getCity();
        } else if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
            groupbytemp = data.getInvto();
        } else if ("DEPARTURE DATE".equalsIgnoreCase(groupby)) {
            groupbytemp = data.getDepartdate();
        }

        if (!temprefno.equalsIgnoreCase(data.getRefno())) {
            if (!"".equalsIgnoreCase(temprefno)) {
                HSSFRow rowtotal = sheet.createRow(count + i);
                // Set align Text
                HSSFCell cellTotal = rowtotal.createCell(0);
                cellTotal.setCellValue("Total");
                cellTotal.setCellStyle(styleTotal);
                if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                    HSSFCell cellTotal01 = rowtotal.createCell(5);
                    cellTotal01.setCellValue(totalpax.doubleValue());
                    cellTotal01.setCellStyle(styleC26);
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("B" + (count + i + 1) + ":E" + (count + i + 1)));
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("G" + (count + i + 1) + ":M" + (count + i + 1)));
                    for (int j = 1; j < 16; j++) {
                        if (j != 5 && j != 13 && j != 14 && j != 15) {
                            HSSFCell cellTotal05 = rowtotal.createCell(j);
                            cellTotal05.setCellStyle(styleC29);
                        }
                    }
                } else {
                    HSSFCell cellTotal01 = rowtotal.createCell(4);
                    cellTotal01.setCellValue(totalpax.doubleValue());
                    cellTotal01.setCellStyle(styleC26);
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("B" + (count + i + 1) + ":D" + (count + i + 1)));
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("F" + (count + i + 1) + ":M" + (count + i + 1)));
                    for (int j = 1; j < 16; j++) {
                        if (j != 4 && j != 13 && j != 14 && j != 15) {
                            HSSFCell cellTotal05 = rowtotal.createCell(j);
                            cellTotal05.setCellStyle(styleC29);
                        }
                    }
                }
                HSSFCell cellTotal02 = rowtotal.createCell(13);
                cellTotal02.setCellValue(totalsale.doubleValue());
                cellTotal02.setCellStyle(styleC25);
                HSSFCell cellTotal03 = rowtotal.createCell(14);
                cellTotal03.setCellValue(totalcost.doubleValue());
                cellTotal03.setCellStyle(styleC25);
                HSSFCell cellTotal04 = rowtotal.createCell(15);
                cellTotal04.setCellValue(totalprofit.doubleValue());
                cellTotal04.setCellStyle(styleC25);

                totalpaxAll = totalpaxAll.add(totalpax);
                totalsaleAll = totalsaleAll.add(totalsale);
                totalcostAll = totalcostAll.add(totalcost);
                totalprofitAll = totalprofitAll.add(totalprofit);

                totalpax = new BigDecimal(BigInteger.ZERO);
                totalsale = new BigDecimal(BigInteger.ZERO);
                totalcost = new BigDecimal(BigInteger.ZERO);
                totalprofit = new BigDecimal(BigInteger.ZERO);

                count = count + 1;
                ktemp = count + 2 + i;
            }
        }

        if (!temp.equalsIgnoreCase(groupbytemp)) {
            if (!"group".equalsIgnoreCase(temp)) {
                HSSFRow row = sheet.createRow(count + i);
                // Set align Text
                HSSFCell cellTotal = row.createCell(0);
                cellTotal.setCellValue("");
                cellTotal.setCellStyle(styleC30);
                if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                    HSSFCell cellTotal01 = row.createCell(5);
                    cellTotal01.setCellValue(totalpaxAll.doubleValue());
                    cellTotal01.setCellStyle(styleTotal);
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("A" + (count + i + 1) + ":E" + (count + i + 1)));
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("G" + (count + i + 1) + ":M" + (count + i + 1)));
                    for (int j = 1; j < 16; j++) {
                        if (j != 5 && j != 13 && j != 14 && j != 15) {
                            HSSFCell cellTotal05 = row.createCell(j);
                            cellTotal05.setCellStyle(styleC29);
                        }
                    }
                } else {
                    HSSFCell cellTotal01 = row.createCell(4);
                    cellTotal01.setCellValue(totalpaxAll.doubleValue());
                    cellTotal01.setCellStyle(styleTotal);
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("A" + (count + i + 1) + ":D" + (count + i + 1)));
                    sheet.addMergedRegion(
                            CellRangeAddress.valueOf("F" + (count + i + 1) + ":M" + (count + i + 1)));
                    for (int j = 1; j < 16; j++) {
                        if (j != 4 && j != 13 && j != 14 && j != 15) {
                            HSSFCell cellTotal05 = row.createCell(j);
                            cellTotal05.setCellStyle(styleC29);
                        }
                    }
                }
                HSSFCell cellTotal02 = row.createCell(13);
                cellTotal02.setCellValue(totalsaleAll.doubleValue());
                cellTotal02.setCellStyle(styleTotalCurrency);
                HSSFCell cellTotal03 = row.createCell(14);
                cellTotal03.setCellValue(totalcostAll.doubleValue());
                cellTotal03.setCellStyle(styleTotalCurrency);
                HSSFCell cellTotal04 = row.createCell(15);
                cellTotal04.setCellValue(totalprofitAll.doubleValue());
                cellTotal04.setCellStyle(styleTotalCurrency);

                totalpaxAll = new BigDecimal(BigInteger.ZERO);
                totalsaleAll = new BigDecimal(BigInteger.ZERO);
                totalcostAll = new BigDecimal(BigInteger.ZERO);
                totalprofitAll = new BigDecimal(BigInteger.ZERO);

                count = count + 2;
                ktemp = count + 3 + i;
            }

            int counts = count + i;
            int countss = count + 1 + i;
            System.out.println(" Print Header Table Group count ::  " + count + " ==== i ==== " + i);
            // Row Agent Name
            System.out.println(" Print Header Group counts ::  " + counts);
            HSSFRow row008 = sheet.createRow(counts);
            HSSFCell cell0081 = row008.createCell(0);
            cell0081.setCellValue(groupby);
            cell0081.setCellStyle(styleGroup);
            HSSFCell cell0082 = row008.createCell(1);
            cell0082.setCellValue(groupbytemp);
            cell0082.setCellStyle(styleGroupdata);
            sheet.addMergedRegion(CellRangeAddress.valueOf("B" + (counts + 1) + ":D" + (counts + 1)));
            temp = groupbytemp;

            System.out.println(" Print Header Table countss ::  " + countss);
            HSSFRow row09 = sheet.createRow(countss);
            HSSFCell cell091 = row09.createCell(0);
            cell091.setCellValue("REF NO");
            cell091.setCellStyle(styleC3);
            sheet.autoSizeColumn(0);
            System.out.println(" groupby " + groupby);
            if ("OWNER".equalsIgnoreCase(groupby)) {
                HSSFCell cell092 = row09.createCell(1);
                cell092.setCellValue("TOUR NAME");
                cell092.setCellStyle(styleC3);
                sheet.autoSizeColumn(1);
                HSSFCell cell093 = row09.createCell(2);
                cell093.setCellValue("DEPARTURE DATE");
                sheet.autoSizeColumn(2);
                cell093.setCellStyle(styleC3);
                HSSFCell cell094 = row09.createCell(3);
                cell094.setCellValue("CITY");
                cell094.setCellStyle(styleC3);
                sheet.autoSizeColumn(3);
                HSSFCell cell095 = row09.createCell(4);
                cell095.setCellValue("PAX");
                cell095.setCellStyle(styleC3);
                sheet.autoSizeColumn(4);
                HSSFCell cell096 = row09.createCell(5);
                cell096.setCellValue("CLIENT NAME");
                cell096.setCellStyle(styleC3);
                sheet.autoSizeColumn(5);
            } else if ("PRODUCT TYPE".equalsIgnoreCase(groupby)) {

            } else if ("CITY".equalsIgnoreCase(groupby)) {
                HSSFCell cell092 = row09.createCell(1);
                cell092.setCellValue("OWNER");
                cell092.setCellStyle(styleC3);
                sheet.autoSizeColumn(1);
                HSSFCell cell093 = row09.createCell(2);
                cell093.setCellValue("TOUR NAME");
                sheet.autoSizeColumn(2);
                cell093.setCellStyle(styleC3);
                HSSFCell cell094 = row09.createCell(3);
                cell094.setCellValue("DEPARTURE DATE");
                cell094.setCellStyle(styleC3);
                sheet.autoSizeColumn(3);
                HSSFCell cell095 = row09.createCell(4);
                cell095.setCellValue("PAX");
                cell095.setCellStyle(styleC3);
                sheet.autoSizeColumn(4);
                HSSFCell cell096 = row09.createCell(5);
                cell096.setCellValue("CLIENT NAME");
                cell096.setCellStyle(styleC3);
                sheet.autoSizeColumn(5);
            } else if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                HSSFCell cell092 = row09.createCell(1);
                cell092.setCellValue("OWNER");
                cell092.setCellStyle(styleC3);
                sheet.autoSizeColumn(1);
                HSSFCell cell093 = row09.createCell(2);
                cell093.setCellValue("TOUR NAME");
                sheet.autoSizeColumn(2);
                cell093.setCellStyle(styleC3);
                HSSFCell cell094 = row09.createCell(3);
                cell094.setCellValue("DEPARTURE DATE");
                cell094.setCellStyle(styleC3);
                sheet.autoSizeColumn(3);
                HSSFCell cell095 = row09.createCell(4);
                cell095.setCellValue("CITY");
                cell095.setCellStyle(styleC3);
                sheet.autoSizeColumn(4);
                HSSFCell cell096 = row09.createCell(5);
                cell096.setCellValue("PAX");
                cell096.setCellStyle(styleC3);
                sheet.autoSizeColumn(5);
            } else if ("DEPARTURE DATE".equalsIgnoreCase(groupby)) {
                HSSFCell cell092 = row09.createCell(1);
                cell092.setCellValue("OWNER");
                cell092.setCellStyle(styleC3);
                sheet.autoSizeColumn(1);
                HSSFCell cell093 = row09.createCell(2);
                cell093.setCellValue("TOUR NAME");
                sheet.autoSizeColumn(2);
                cell093.setCellStyle(styleC3);
                HSSFCell cell094 = row09.createCell(3);
                cell094.setCellValue("CITY");
                cell094.setCellStyle(styleC3);
                sheet.autoSizeColumn(3);
                HSSFCell cell095 = row09.createCell(4);
                cell095.setCellValue("PAX");
                cell095.setCellStyle(styleC3);
                sheet.autoSizeColumn(4);
                HSSFCell cell096 = row09.createCell(5);
                cell096.setCellValue("CLIENT NAME");
                cell096.setCellStyle(styleC3);
                sheet.autoSizeColumn(5);
            }

            HSSFCell cell097 = row09.createCell(6);
            cell097.setCellValue("INVOICE NO");
            cell097.setCellStyle(styleC3);
            sheet.autoSizeColumn(6);
            HSSFCell cell098 = row09.createCell(7);
            cell098.setCellValue("RECEIPT NO");
            cell098.setCellStyle(styleC3);
            sheet.autoSizeColumn(7);
            HSSFCell cell099 = row09.createCell(8);
            cell099.setCellValue("TAX INVOICE NO");
            cell099.setCellStyle(styleC3);
            sheet.autoSizeColumn(8);
            HSSFCell cell100 = row09.createCell(9);
            cell100.setCellValue("PRODUCT TYPE");
            cell100.setCellStyle(styleC3);
            sheet.autoSizeColumn(9);
            HSSFCell cell101 = row09.createCell(10);
            cell101.setCellValue("DESCRIPTION");
            cell101.setCellStyle(styleC3);
            sheet.autoSizeColumn(10);
            HSSFCell cell102 = row09.createCell(11);
            cell102.setCellValue("PAY NO");
            cell102.setCellStyle(styleC3);
            sheet.autoSizeColumn(11);
            HSSFCell cell103 = row09.createCell(12);
            cell103.setCellValue("SUPPLIER");
            cell103.setCellStyle(styleC3);
            sheet.autoSizeColumn(12);
            HSSFCell cell104 = row09.createCell(13);
            cell104.setCellValue("SALE PRICE");
            cell104.setCellStyle(styleC3);
            sheet.autoSizeColumn(13);
            HSSFCell cell105 = row09.createCell(14);
            cell105.setCellValue("COST");
            cell105.setCellStyle(styleC3);
            sheet.autoSizeColumn(14);
            HSSFCell cell106 = row09.createCell(15);
            cell106.setCellValue("PROFIT");
            cell106.setCellStyle(styleC3);
            sheet.autoSizeColumn(15);
            count = count + 2;
        }

        //set data 
        System.out.println(" Print Data Table count ::  " + count + " ==== i ==== " + i);
        HSSFRow row = sheet.createRow(count + i);
        if (!temprefno.equalsIgnoreCase(data.getRefno())) {
            HSSFCell celldata01 = row.createCell(0);
            celldata01.setCellValue(data.getRefno());
            celldata01.setCellStyle(styleC29);

            if ("OWNER".equalsIgnoreCase(groupby)) {
                HSSFCell celldata02 = row.createCell(1);
                celldata02.setCellValue(data.getTourname());
                celldata02.setCellStyle(styleC29);
                HSSFCell celldata03 = row.createCell(2);
                celldata03.setCellValue(data.getDepartdate());
                celldata03.setCellStyle(styleC29);
                HSSFCell celldata04 = row.createCell(3);
                celldata04.setCellValue(data.getCity());
                celldata04.setCellStyle(styleC29);
                HSSFCell celldata05 = row.createCell(4);
                celldata05.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPax())) ? 0
                        : new BigDecimal(data.getPax()).doubleValue());
                celldata05.setCellStyle(styleC26);
                HSSFCell celldata06 = row.createCell(5);
                celldata06.setCellValue(data.getInvto());
                celldata06.setCellStyle(styleC29);
                sheet.setColumnWidth(3, 256 * 15);
            } else if ("PRODUCT TYPE".equalsIgnoreCase(groupby)) {

            } else if ("CITY".equalsIgnoreCase(groupby)) {
                HSSFCell celldata02 = row.createCell(1);
                celldata02.setCellValue(data.getOwner());
                celldata02.setCellStyle(styleC29);
                HSSFCell celldata03 = row.createCell(2);
                celldata03.setCellValue(data.getTourname());
                celldata03.setCellStyle(styleC29);
                HSSFCell celldata04 = row.createCell(3);
                celldata04.setCellValue(data.getDepartdate());
                celldata04.setCellStyle(styleC29);
                HSSFCell celldata05 = row.createCell(4);
                celldata05.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPax())) ? 0
                        : new BigDecimal(data.getPax()).doubleValue());
                celldata05.setCellStyle(styleC26);
                HSSFCell celldata06 = row.createCell(5);
                celldata06.setCellValue(data.getInvto());
                celldata06.setCellStyle(styleC29);
            } else if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                HSSFCell celldata02 = row.createCell(1);
                celldata02.setCellValue(data.getOwner());
                celldata02.setCellStyle(styleC29);
                HSSFCell celldata03 = row.createCell(2);
                celldata03.setCellValue(data.getTourname());
                celldata03.setCellStyle(styleC29);
                HSSFCell celldata04 = row.createCell(3);
                celldata04.setCellValue(data.getDepartdate());
                celldata04.setCellStyle(styleC29);
                HSSFCell celldata05 = row.createCell(4);
                celldata05.setCellValue(data.getCity());
                celldata05.setCellStyle(styleC29);
                HSSFCell celldata06 = row.createCell(5);
                celldata06.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPax())) ? 0
                        : new BigDecimal(data.getPax()).doubleValue());
                celldata06.setCellStyle(styleC26);
                sheet.setColumnWidth(4, 256 * 15);
            } else if ("DEPARTURE DATE".equalsIgnoreCase(groupby)) {
                HSSFCell celldata02 = row.createCell(1);
                celldata02.setCellValue(data.getOwner());
                celldata02.setCellStyle(styleC29);
                HSSFCell celldata03 = row.createCell(2);
                celldata03.setCellValue(data.getTourname());
                celldata03.setCellStyle(styleC29);
                HSSFCell celldata04 = row.createCell(3);
                celldata04.setCellValue(data.getCity());
                celldata04.setCellStyle(styleC29);
                HSSFCell celldata05 = row.createCell(4);
                celldata05.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPax())) ? 0
                        : new BigDecimal(data.getPax()).doubleValue());
                celldata05.setCellStyle(styleC26);
                HSSFCell celldata06 = row.createCell(5);
                celldata06.setCellValue(data.getInvto());
                celldata06.setCellStyle(styleC29);
                sheet.setColumnWidth(3, 256 * 15);
            }
        } else {
            for (int j = 0; j < 6; j++) {
                HSSFCell celldata02 = row.createCell(j);
                celldata02.setCellStyle(styleC29);
            }
            sheet.addMergedRegion(CellRangeAddress.valueOf("A" + (count + i + 1) + ":F" + (count + i + 1)));
        }

        HSSFCell celldata07 = row.createCell(6);
        celldata07.setCellValue(data.getInvno());
        celldata07.setCellStyle(styleC29);
        HSSFCell celldata08 = row.createCell(7);
        celldata08.setCellValue(data.getReceipt());
        celldata08.setCellStyle(styleC29);
        HSSFCell celldata09 = row.createCell(8);
        celldata09.setCellValue(data.getTaxinvoice());
        celldata09.setCellStyle(styleC29);
        HSSFCell celldata10 = row.createCell(9);
        celldata10.setCellValue(data.getProducttype());
        celldata10.setCellStyle(styleC29);
        HSSFCell celldata11 = row.createCell(10);
        celldata11.setCellValue(data.getDescription());
        celldata11.setCellStyle(styleC29);
        HSSFCell celldata12 = row.createCell(11);
        celldata12.setCellValue(data.getPayno());
        celldata12.setCellStyle(styleC29);
        HSSFCell celldata13 = row.createCell(12);
        celldata13.setCellValue(data.getSupplier());
        celldata13.setCellStyle(styleC29);
        HSSFCell celldata14 = row.createCell(13);
        celldata14.setCellValue("".equalsIgnoreCase(String.valueOf(data.getSale())) ? 0
                : new BigDecimal(data.getSale()).doubleValue());
        celldata14.setCellStyle(styleC25);
        HSSFCell celldata15 = row.createCell(14);
        celldata15.setCellValue("".equalsIgnoreCase(String.valueOf(data.getCost())) ? 0
                : new BigDecimal(data.getCost()).doubleValue());
        celldata15.setCellStyle(styleC25);
        HSSFCell celldata16 = row.createCell(15);
        celldata16.setCellValue("".equalsIgnoreCase(String.valueOf(data.getProfit())) ? 0
                : new BigDecimal(data.getProfit()).doubleValue());
        celldata16.setCellStyle(styleC25);

        totalpax = ("".equalsIgnoreCase(String.valueOf(data.getPax())) ? new BigDecimal(BigInteger.ZERO)
                : new BigDecimal(data.getPax()));
        totalsale = totalsale
                .add("".equalsIgnoreCase(String.valueOf(data.getSale())) ? new BigDecimal(BigInteger.ZERO)
                        : new BigDecimal(data.getSale()));
        totalcost = totalcost
                .add("".equalsIgnoreCase(String.valueOf(data.getCost())) ? new BigDecimal(BigInteger.ZERO)
                        : new BigDecimal(data.getCost()));
        totalprofit = totalprofit
                .add("".equalsIgnoreCase(String.valueOf(data.getProfit())) ? new BigDecimal(BigInteger.ZERO)
                        : new BigDecimal(data.getProfit()));

        temprefno = data.getRefno();

        // set total last row
        if (i == (listPayment.size() - 1)) {

            HSSFRow rowtotal = sheet.createRow(count + i + 1);
            // Set align Text
            HSSFCell cellTotal = rowtotal.createCell(0);
            cellTotal.setCellValue("Total");
            cellTotal.setCellStyle(styleTotal);
            if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                HSSFCell cellTotal01 = rowtotal.createCell(5);
                cellTotal01.setCellValue(totalpax.doubleValue());
                cellTotal01.setCellStyle(styleC26);
                sheet.addMergedRegion(CellRangeAddress.valueOf("B" + (count + i + 2) + ":E" + (count + i + 2)));
                sheet.addMergedRegion(CellRangeAddress.valueOf("G" + (count + i + 2) + ":M" + (count + i + 2)));
                for (int j = 1; j < 16; j++) {
                    if (j != 5 && j != 13 && j != 14 && j != 15) {
                        HSSFCell cellTotal05 = rowtotal.createCell(j);
                        cellTotal05.setCellStyle(styleTotal);
                    }
                }
            } else {
                HSSFCell cellTotal01 = rowtotal.createCell(4);
                cellTotal01.setCellValue(totalpax.doubleValue());
                cellTotal01.setCellStyle(styleC26);
                sheet.addMergedRegion(CellRangeAddress.valueOf("B" + (count + i + 2) + ":D" + (count + i + 2)));
                sheet.addMergedRegion(CellRangeAddress.valueOf("F" + (count + i + 2) + ":M" + (count + i + 2)));
                for (int j = 1; j < 16; j++) {
                    if (j != 4 && j != 13 && j != 14 && j != 15) {
                        HSSFCell cellTotal05 = rowtotal.createCell(j);
                        cellTotal05.setCellStyle(styleC29);
                    }
                }
            }
            HSSFCell cellTotal02 = rowtotal.createCell(13);
            cellTotal02.setCellValue(totalsale.doubleValue());
            cellTotal02.setCellStyle(styleC25);
            HSSFCell cellTotal03 = rowtotal.createCell(14);
            cellTotal03.setCellValue(totalcost.doubleValue());
            cellTotal03.setCellStyle(styleC25);
            HSSFCell cellTotal04 = rowtotal.createCell(15);
            cellTotal04.setCellValue(totalprofit.doubleValue());
            cellTotal04.setCellStyle(styleC25);

            totalpaxAll = totalpaxAll.add(totalpax);
            totalsaleAll = totalsaleAll.add(totalsale);
            totalcostAll = totalcostAll.add(totalcost);
            totalprofitAll = totalprofitAll.add(totalprofit);

            //                    count = count+1;
            //                    ktemp = count+2+i;

            row = sheet.createRow(count + i + 2);
            // Set align Text
            HSSFCell cellTotalAll = row.createCell(0);
            cellTotalAll.setCellValue("");
            cellTotalAll.setCellStyle(styleTotal);
            if ("CLIENT NAME".equalsIgnoreCase(groupby)) {
                HSSFCell cellTotal01 = row.createCell(5);
                cellTotal01.setCellValue(totalpaxAll.doubleValue());
                cellTotal01.setCellStyle(styleTotal);
                sheet.addMergedRegion(CellRangeAddress.valueOf("A" + (count + i + 3) + ":E" + (count + i + 3)));
                sheet.addMergedRegion(CellRangeAddress.valueOf("G" + (count + i + 3) + ":M" + (count + i + 3)));
                for (int j = 1; j < 16; j++) {
                    if (j != 5 && j != 13 && j != 14 && j != 15) {
                        HSSFCell cellTotal05 = row.createCell(j);
                        cellTotal05.setCellStyle(styleC29);
                    }
                }
            } else {
                HSSFCell cellTotal01 = row.createCell(4);
                cellTotal01.setCellValue(totalpaxAll.doubleValue());
                cellTotal01.setCellStyle(styleTotal);
                sheet.addMergedRegion(CellRangeAddress.valueOf("A" + (count + i + 3) + ":D" + (count + i + 3)));
                sheet.addMergedRegion(CellRangeAddress.valueOf("F" + (count + i + 3) + ":M" + (count + i + 3)));
                for (int j = 1; j < 16; j++) {
                    if (j != 4 && j != 13 && j != 14 && j != 15) {
                        HSSFCell cellTotal05 = row.createCell(j);
                        cellTotal05.setCellStyle(styleC29);
                    }
                }
            }
            HSSFCell cellTotalAll02 = row.createCell(13);
            cellTotalAll02.setCellValue(totalsaleAll.doubleValue());
            cellTotalAll02.setCellStyle(styleTotalCurrency);
            HSSFCell cellTotalAll03 = row.createCell(14);
            cellTotalAll03.setCellValue(totalcostAll.doubleValue());
            cellTotalAll03.setCellStyle(styleTotalCurrency);
            HSSFCell cellTotalAll04 = row.createCell(15);
            cellTotalAll04.setCellValue(totalprofitAll.doubleValue());
            cellTotalAll04.setCellStyle(styleTotalCurrency);
        }
    }

    for (int x = 0; x < 17; x++) {
        sheet.autoSizeColumn(x);
    }
    sheet.setColumnWidth(6, 256 * 25);
    sheet.setColumnWidth(7, 256 * 25);
    sheet.setColumnWidth(8, 256 * 25);

    sheet.setColumnWidth(13, 256 * 15);
    sheet.setColumnWidth(14, 256 * 15);
    sheet.setColumnWidth(15, 256 * 15);
}

From source file:com.smi.travel.controller.excel.booking.OutboundProductSummary.java

private void getOutboundProductSummary(HSSFWorkbook wb, List listOutboundProductSummary) {
    List<OutboundProductSummaryExcel> listOutboundProduct = listOutboundProductSummary;
    String sheetName = "Sheet1";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    // Set align Text
    HSSFCellStyle styleAlignRight = wb.createCellStyle();
    styleAlignRight.setAlignment(styleAlignRight.ALIGN_RIGHT);
    HSSFCellStyle styleAlignLeft = wb.createCellStyle();
    styleAlignLeft.setAlignment(styleAlignLeft.ALIGN_LEFT);
    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleNumber = wb.createCellStyle();
    styleNumber.setAlignment(styleNumber.ALIGN_RIGHT);
    styleNumber.setDataFormat(currency.getFormat("#,##0.00"));

    // set Header Report (Row 1)
    HSSFCellStyle styleHeader1 = wb.createCellStyle();
    HSSFRow row1 = sheet.createRow(0);//www. ja v a  2 s  .  c om
    HSSFCell cell1 = row1.createCell(0);
    cell1.setCellValue("Outbound Product Summary");
    styleHeader1.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell1.setCellStyle(styleHeader1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:I1"));

    if (listOutboundProduct != null && listOutboundProduct.size() != 0) {
        OutboundProductSummaryExcel outboundProduct = new OutboundProductSummaryExcel();
        outboundProduct = listOutboundProduct.get(0);

        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("Product : ");
        cell21.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell22 = row2.createCell(1);
        cell22.setCellValue(outboundProduct.getProductnamepage());
        cell22.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell23 = row2.createCell(2);
        cell23.setCellValue("Pay By : ");
        cell23.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(2);
        HSSFCell cell24 = row2.createCell(3);
        cell24.setCellValue(outboundProduct.getPaybypage());
        cell24.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(3);

        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Sale Date : ");
        cell31.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(outboundProduct.getSaledatepage());
        cell32.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell33 = row3.createCell(2);
        cell33.setCellValue("Bank Transfer : ");
        cell33.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(2);
        HSSFCell cell34 = row3.createCell(3);
        cell34.setCellValue(outboundProduct.getBankpage());
        cell34.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(3);

        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Sale By : ");
        cell41.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell42 = row4.createCell(1);
        cell42.setCellValue(outboundProduct.getSalebypage());
        cell42.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell43 = row4.createCell(2);
        cell43.setCellValue("Status : ");
        cell43.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(2);
        HSSFCell cell44 = row4.createCell(3);
        cell44.setCellValue(outboundProduct.getStatuspage());
        cell44.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(3);
    }

    // Header Table
    HSSFCellStyle styleHeader = wb.createCellStyle();
    styleHeader.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleHeader.setAlignment(styleHeader.ALIGN_CENTER);
    styleHeader.setBorderTop(styleHeader.BORDER_THIN);
    styleHeader.setBorderLeft(styleHeader.BORDER_THIN);
    styleHeader.setBorderBottom(styleHeader.BORDER_THIN);
    styleHeader.setBorderRight(styleHeader.BORDER_THIN);
    styleHeader.setVerticalAlignment(styleHeader.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);
    styleDetailTable.setVerticalAlignment(styleDetailTable.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableCenter = wb.createCellStyle();
    styleDetailTableCenter.setAlignment(styleDetailTableCenter.ALIGN_CENTER);
    styleDetailTableCenter.setBorderTop(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderBottom(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderRight(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderLeft(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setWrapText(true);
    styleDetailTableCenter.setVerticalAlignment(styleDetailTableCenter.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableNumber = wb.createCellStyle();
    styleDetailTableNumber.setAlignment(styleDetailTableNumber.ALIGN_RIGHT);
    styleDetailTableNumber.setBorderLeft(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setBorderRight(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleDetailTableNumber.setWrapText(true);
    styleDetailTableNumber.setVerticalAlignment(styleDetailTableNumber.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableBorderBottom = wb.createCellStyle();
    styleDetailTableBorderBottom.setBorderTop(styleDetailTableBorderBottom.BORDER_THIN);
    HSSFCellStyle styleBorderTop = wb.createCellStyle();
    styleBorderTop.setBorderBottom(styleBorderTop.BORDER_THIN);
    styleBorderTop.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleBorderTop.setAlignment(styleBorderTop.ALIGN_CENTER);
    HSSFCellStyle styleBorderRight = wb.createCellStyle();
    styleBorderRight.setBorderRight(styleBorderRight.BORDER_THIN);
    styleBorderRight.setAlignment(styleBorderRight.ALIGN_CENTER);
    HSSFCellStyle styleBorderBottomAndRight = wb.createCellStyle();
    styleBorderBottomAndRight.setBorderRight(styleBorderBottomAndRight.BORDER_THIN);
    styleBorderBottomAndRight.setBorderBottom(styleBorderBottomAndRight.BORDER_THIN);
    styleBorderBottomAndRight.setAlignment(styleBorderBottomAndRight.ALIGN_CENTER);
    styleBorderBottomAndRight.setVerticalAlignment(styleBorderBottomAndRight.VERTICAL_CENTER);

    HSSFCellStyle styleAlignLeftBorderTopRight = wb.createCellStyle(); // use
    styleAlignLeftBorderTopRight.setAlignment(styleAlignLeftBorderTopRight.ALIGN_LEFT);
    styleAlignLeftBorderTopRight.setBorderTop(styleAlignLeftBorderTopRight.BORDER_THIN);
    styleAlignLeftBorderTopRight.setBorderRight(styleAlignLeftBorderTopRight.BORDER_THIN);
    styleAlignLeftBorderTopRight.setVerticalAlignment(styleAlignLeftBorderTopRight.VERTICAL_CENTER);
    HSSFCellStyle styleAlignLeftBorderTopLeft = wb.createCellStyle(); // use
    styleAlignLeftBorderTopLeft.setAlignment(styleAlignLeftBorderTopLeft.ALIGN_LEFT);
    styleAlignLeftBorderTopLeft.setBorderTop(styleAlignLeftBorderTopLeft.BORDER_THIN);
    styleAlignLeftBorderTopLeft.setBorderLeft(styleAlignLeftBorderTopLeft.BORDER_THIN);
    styleAlignLeftBorderTopLeft.setVerticalAlignment(styleAlignLeftBorderTopLeft.VERTICAL_CENTER);
    HSSFCellStyle styleBorderTopP = wb.createCellStyle(); // use
    styleBorderTopP.setBorderTop(styleBorderTopP.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderBottomRight = wb.createCellStyle();//use
    styleAlignRightBorderBottomRight.setAlignment(styleAlignRightBorderBottomRight.ALIGN_LEFT);
    styleAlignRightBorderBottomRight.setBorderBottom(styleAlignRightBorderBottomRight.BORDER_THIN);
    styleAlignRightBorderBottomRight.setBorderRight(styleAlignRightBorderBottomRight.BORDER_THIN);
    styleAlignRightBorderBottomRight.setVerticalAlignment(styleAlignRightBorderBottomRight.VERTICAL_CENTER);
    HSSFCellStyle styleAlignRightBorderBottomLeft = wb.createCellStyle();
    styleAlignRightBorderBottomLeft.setAlignment(styleAlignRightBorderBottomLeft.ALIGN_LEFT);
    styleAlignRightBorderBottomLeft.setBorderBottom(styleAlignRightBorderBottomLeft.BORDER_THIN);
    styleAlignRightBorderBottomLeft.setBorderLeft(styleAlignRightBorderBottomLeft.BORDER_THIN);
    styleAlignRightBorderBottomLeft.setVerticalAlignment(styleAlignRightBorderBottomLeft.VERTICAL_CENTER);
    HSSFCellStyle styleBorderBottom = wb.createCellStyle(); //use
    styleBorderBottom.setBorderBottom(styleBorderBottom.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderRight = wb.createCellStyle(); //use
    styleAlignRightBorderRight.setAlignment(styleAlignRightBorderRight.ALIGN_RIGHT);
    styleAlignRightBorderRight.setBorderRight(styleAlignRightBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignLeftBorderRight = wb.createCellStyle();
    styleAlignLeftBorderRight.setAlignment(styleAlignLeftBorderRight.ALIGN_LEFT);
    styleAlignLeftBorderRight.setBorderRight(styleAlignLeftBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderLeft = wb.createCellStyle();//use
    styleAlignRightBorderLeft.setAlignment(styleAlignRightBorderLeft.ALIGN_RIGHT);
    styleAlignRightBorderLeft.setBorderLeft(styleAlignRightBorderLeft.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderAllNumber = wb.createCellStyle();
    styleAlignRightBorderAllNumber.setAlignment(styleAlignRightBorderAllNumber.ALIGN_RIGHT);
    styleAlignRightBorderAllNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleAlignRightBorderAllNumber.setBorderTop(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderBottom(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderRight(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderLeft(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setVerticalAlignment(styleAlignRightBorderAllNumber.VERTICAL_CENTER);
    HSSFCellStyle styleAlignRightBorderAll = wb.createCellStyle();
    styleAlignRightBorderAll.setAlignment(styleAlignRightBorderAll.ALIGN_LEFT);
    styleAlignRightBorderAll.setBorderTop(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderBottom(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderRight(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderLeft(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setVerticalAlignment(styleAlignRightBorderAll.VERTICAL_CENTER);
    styleAlignRightBorderAll.setWrapText(true);
    HSSFRow row4 = sheet.createRow(6);
    row4.createCell(7).setCellStyle(styleBorderTop);
    row4.createCell(8).setCellStyle(styleBorderTop);
    row4.createCell(9).setCellStyle(styleBorderTop);
    row4.createCell(10).setCellStyle(styleBorderTop);
    row4.createCell(11).setCellStyle(styleBorderTop);
    row4.createCell(12).setCellStyle(styleBorderTop);
    row4.createCell(13).setCellStyle(styleBorderTop);
    row4.createCell(14).setCellStyle(styleBorderTop);
    row4.createCell(15).setCellStyle(styleBorderTop);
    HSSFRow row5 = sheet.createRow(7);
    HSSFCell cell61 = row5.createCell(0);
    cell61.setCellValue("SALE DATE");
    cell61.setCellStyle(styleHeader);
    sheet.autoSizeColumn(0);
    HSSFCell cell62 = row5.createCell(1);
    cell62.setCellValue("RECORD NO");
    cell62.setCellStyle(styleHeader);
    sheet.autoSizeColumn(1);
    HSSFCell cell63 = row5.createCell(2);
    cell63.setCellValue("REF NO");
    cell63.setCellStyle(styleHeader);
    sheet.autoSizeColumn(2);
    //        HSSFCell cell64 = row5.createCell(3);
    //            cell64.setCellValue("PRODUCT NAME");
    //            cell64.setCellStyle(styleHeader);
    //            sheet.autoSizeColumn(3);
    HSSFCell cell65 = row5.createCell(3);
    cell65.setCellValue("PASS NO");
    cell65.setCellStyle(styleHeader);
    sheet.autoSizeColumn(3);
    HSSFCell cell66 = row5.createCell(4);
    cell66.setCellValue("DULATION");
    cell66.setCellStyle(styleHeader);
    sheet.autoSizeColumn(4);
    HSSFCell cell67 = row5.createCell(5);
    cell67.setCellValue("INV NO");
    cell67.setCellStyle(styleHeader);
    sheet.autoSizeColumn(5);
    HSSFCell cell68 = row5.createCell(6);
    cell68.setCellValue("CUSTOMER NAME");
    cell68.setCellStyle(styleHeader);
    sheet.autoSizeColumn(6);
    HSSFCell cell59 = row5.createCell(7);
    cell59.setCellValue("PAX");
    cell59.setCellStyle(styleBorderTop);
    sheet.autoSizeColumn(7);
    sheet.addMergedRegion(CellRangeAddress.valueOf("H8:J8"));
    row5.createCell(9).setCellStyle(styleBorderRight);
    HSSFCell cell627 = row5.createCell(10);
    cell627.setCellValue("TOTAL NETT");
    cell627.setCellStyle(styleBorderTop);
    sheet.autoSizeColumn(10);
    sheet.addMergedRegion(CellRangeAddress.valueOf("K8:M8"));
    //        row5.createCell(12).setCellStyle(styleBorderTop);
    row5.createCell(12).setCellStyle(styleBorderRight);
    HSSFCell cell657 = row5.createCell(13);
    cell657.setCellValue("TOTAL SALE");
    cell657.setCellStyle(styleBorderTop);
    sheet.autoSizeColumn(13);
    sheet.addMergedRegion(CellRangeAddress.valueOf("N8:P8"));
    //        row5.createCell(15).setCellStyle(styleBorderTop);
    row5.createCell(15).setCellStyle(styleBorderRight);
    HSSFCell cell78 = row5.createCell(16);
    cell78.setCellValue("PROFIT TOTAL");
    cell78.setCellStyle(styleHeader);
    sheet.autoSizeColumn(16);
    HSSFCell cell79 = row5.createCell(17);
    cell79.setCellValue("PAY BY");
    cell79.setCellStyle(styleHeader);
    sheet.autoSizeColumn(17);
    HSSFCell cell80 = row5.createCell(18);
    cell80.setCellValue("DATE TRSF");
    cell80.setCellStyle(styleHeader);
    sheet.autoSizeColumn(18);
    HSSFCell cell81 = row5.createCell(19);
    cell81.setCellValue("SALLER");
    cell81.setCellStyle(styleHeader);
    sheet.autoSizeColumn(19);

    sheet.addMergedRegion(CellRangeAddress.valueOf("A8:A9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("B8:B9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("C8:C9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("D8:D9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("E8:E9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("F8:F9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("G8:G9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("Q8:Q9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("R8:R9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("S8:S9"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("T8:T9"));

    HSSFRow row6 = sheet.createRow(8);
    row6.createCell(0).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(1).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(2).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(3).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(4).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(5).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(6).setCellStyle(styleBorderBottomAndRight);
    HSSFCell cell69 = row6.createCell(7);
    cell69.setCellValue("AD");
    cell69.setCellStyle(styleHeader);
    sheet.autoSizeColumn(7);
    HSSFCell cell70 = row6.createCell(8);
    cell70.setCellValue("CH");
    cell70.setCellStyle(styleHeader);
    sheet.autoSizeColumn(8);
    HSSFCell cell71 = row6.createCell(9);
    cell71.setCellValue("IN");
    cell71.setCellStyle(styleHeader);
    sheet.autoSizeColumn(9);
    HSSFCell cell72 = row6.createCell(10);
    cell72.setCellValue("ADULT");
    cell72.setCellStyle(styleHeader);
    sheet.autoSizeColumn(10);
    HSSFCell cell73 = row6.createCell(11);
    cell73.setCellValue("CHILD");
    cell73.setCellStyle(styleHeader);
    sheet.autoSizeColumn(11);
    HSSFCell cell74 = row6.createCell(12);
    cell74.setCellValue("INFANT");
    cell74.setCellStyle(styleHeader);
    sheet.autoSizeColumn(12);
    HSSFCell cell75 = row6.createCell(13);
    cell75.setCellValue("ADULT");
    cell75.setCellStyle(styleHeader);
    sheet.autoSizeColumn(13);
    HSSFCell cell76 = row6.createCell(14);
    cell76.setCellValue("CHILD");
    cell76.setCellStyle(styleHeader);
    sheet.autoSizeColumn(14);
    HSSFCell cell77 = row6.createCell(15);
    cell77.setCellValue("INFANT");
    cell77.setCellStyle(styleHeader);
    sheet.autoSizeColumn(15);
    row6.createCell(16).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(17).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(18).setCellStyle(styleBorderBottomAndRight);
    row6.createCell(19).setCellStyle(styleBorderBottomAndRight);

    int count = 9 + listOutboundProduct.size();
    int num = 0;
    int end = 0;
    if (listOutboundProduct != null && listOutboundProduct.size() != 0) {
        for (int r = 9; r < count; r++) {
            if (num <= (listOutboundProduct.size() - 1)) {
                if (num != 0) { // Check not row first
                    String temp = listOutboundProduct.get(num - 1).getProductname();
                    if (temp.equals(listOutboundProduct.get(num).getProductname())) { // equal type   
                        //                        System.out.println("Num : " + num + " Last Row : " + (listOutboundProduct.size()-1));
                        if (num != (listOutboundProduct.size() - 1)) { // check not last row
                            HSSFRow row = sheet.createRow(r);
                            createCell(row, listOutboundProduct, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll, styleDetailTableCenter);
                            if (listOutboundProduct.get(num).getInvno() != null
                                    && !"".equals(listOutboundProduct.get(num).getInvno())) {
                                sheet.autoSizeColumn(5);
                            }
                            num++;
                        } else { // last row            
                            //                            System.out.println("Num : " + num + " Last Row : " + (listOutboundProduct.size()-1));
                            HSSFRow row = sheet.createRow(r);
                            createCell(row, listOutboundProduct, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll, styleDetailTableCenter);
                            if (listOutboundProduct.get(num).getInvno() != null
                                    && !"".equals(listOutboundProduct.get(num).getInvno())) {
                                sheet.autoSizeColumn(5);
                            }
                            num++;

                            // total
                            HSSFRow rowT = sheet.createRow(r + 1);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleBorderBottom);
                            rowT.createCell(13).setCellStyle(styleBorderBottom);
                            rowT.createCell(14).setCellStyle(styleBorderBottom);
                            rowT.createCell(15).setCellStyle(styleBorderBottom);
                            rowT.createCell(16).setCellStyle(styleBorderBottom);
                            rowT.createCell(17).setCellStyle(styleBorderBottom);
                            rowT.createCell(18).setCellStyle(styleBorderBottom);
                            rowT.createCell(19).setCellStyle(styleAlignRightBorderBottomRight);
                        }
                    } else { // not equal type
                        if (num == (listOutboundProduct.size() - 1)) { // check  last row            
                            //                            System.out.println("Num : " + num + " Last Row : " + (listOutboundProduct.size()-1));
                            HSSFRow row = sheet.createRow(r);
                            createCell(row, listOutboundProduct, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll, styleDetailTableCenter);
                            if (listOutboundProduct.get(num).getInvno() != null
                                    && !"".equals(listOutboundProduct.get(num).getInvno())) {
                                sheet.autoSizeColumn(5);
                            }
                            num++;
                            // total
                            HSSFRow rowT = sheet.createRow(r + 1);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleBorderBottom);
                            rowT.createCell(13).setCellStyle(styleBorderBottom);
                            rowT.createCell(14).setCellStyle(styleBorderBottom);
                            rowT.createCell(15).setCellStyle(styleBorderBottom);
                            rowT.createCell(16).setCellStyle(styleBorderBottom);
                            rowT.createCell(17).setCellStyle(styleBorderBottom);
                            rowT.createCell(18).setCellStyle(styleBorderBottom);
                            rowT.createCell(19).setCellStyle(styleAlignRightBorderBottomRight);
                        } else {
                            //                                System.out.println("Num : " + num + " Last Row : " + (listOutboundProduct.size()-1));
                            // total
                            HSSFRow rowT = sheet.createRow(r);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleBorderBottom);
                            rowT.createCell(13).setCellStyle(styleBorderBottom);
                            rowT.createCell(14).setCellStyle(styleBorderBottom);
                            rowT.createCell(15).setCellStyle(styleBorderBottom);
                            rowT.createCell(16).setCellStyle(styleBorderBottom);
                            rowT.createCell(17).setCellStyle(styleBorderBottom);
                            rowT.createCell(18).setCellStyle(styleBorderBottom);
                            rowT.createCell(19).setCellStyle(styleAlignRightBorderBottomRight);
                            // Start New Row (Group)
                            HSSFRow row0 = sheet.createRow(r + 1);
                            HSSFCell cell = row0.createCell(0);
                            cell.setCellValue(listOutboundProduct.get(num).getProductname());
                            //                                    cell.setCellStyle(styleAlignRightBorderAll);
                            row0.createCell(19).setCellStyle(styleAlignRightBorderAll);
                            if (listOutboundProduct.get(num).getInvno() != null
                                    && !"".equals(listOutboundProduct.get(num).getInvno())) {
                                sheet.autoSizeColumn(5);
                            }
                            String add = "A" + (r + 2) + ":M" + (r + 2) + "";
                            //                                System.out.println("Add : " + add);
                            sheet.addMergedRegion(CellRangeAddress.valueOf(add));
                            HSSFRow row122 = sheet.createRow(r + 2);
                            createCell(row122, listOutboundProduct, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll, styleDetailTableCenter);
                            num++;
                            count = count + 2;
                            r = r + 2;
                        }
                    }
                } else { // row first
                    //                        System.out.println("Num : " + num + " Last Row : " + (listOutboundProduct.size()-1));

                    HSSFRow row0 = sheet.createRow(r);
                    HSSFCell cell = row0.createCell(0);
                    cell.setCellValue(listOutboundProduct.get(num).getProductname());
                    //                            cell.setCellStyle(styleAlignRightBorderAll);
                    row0.createCell(19).setCellStyle(styleAlignRightBorderAll);
                    String add = "A" + (r + 1) + ":T" + (r + 1) + "";
                    //                        System.out.println("Add : " + add);
                    sheet.addMergedRegion(CellRangeAddress.valueOf(add));

                    HSSFRow row = sheet.createRow(r + 1);
                    createCell(row, listOutboundProduct, num, styleAlignRightBorderAllNumber,
                            styleAlignRightBorderAll, styleDetailTableCenter);
                    if (listOutboundProduct.get(num).getInvno() != null
                            && !"".equals(listOutboundProduct.get(num).getInvno())) {
                        sheet.autoSizeColumn(5);
                    }
                    //                        sheet.autoSizeColumn(20);
                    num = num + 1;
                    count = count + 1;
                    r = r + 1;
                }
                sheet.autoSizeColumn(6);
                sheet.autoSizeColumn(9);
            }
        }
    }
    //        sheet.setColumnWidth(3, 256*15);
}

From source file:com.smi.travel.controller.excel.booking.OutboundProductSummary.java

private void getPaymentSummary(HSSFWorkbook wb, List listPaymentSummary) {
    List<PaymentOutboundAllDetail> paymentSummaryList = listPaymentSummary;
    String sheetName = "PaymentSummary";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    // Set align Text
    HSSFCellStyle styleAlignRight = wb.createCellStyle();
    styleAlignRight.setAlignment(styleAlignRight.ALIGN_RIGHT);
    HSSFCellStyle styleAlignLeft = wb.createCellStyle();
    styleAlignLeft.setAlignment(styleAlignLeft.ALIGN_LEFT);
    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleNumber = wb.createCellStyle();
    styleNumber.setAlignment(styleNumber.ALIGN_RIGHT);
    styleNumber.setDataFormat(currency.getFormat("#,##0.00"));

    // set Header Report (Row 1)
    HSSFCellStyle styleHeader1 = wb.createCellStyle();
    HSSFRow row1 = sheet.createRow(0);//from w ww . ja va2 s .c om
    HSSFCell cell1 = row1.createCell(0);
    cell1.setCellValue("Payment Outbound Summary");
    styleHeader1.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell1.setCellStyle(styleHeader1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:I1"));

    if (paymentSummaryList != null && paymentSummaryList.size() != 0) {
        PaymentOutboundAllDetail poad = new PaymentOutboundAllDetail();
        poad = paymentSummaryList.get(0);
        // ROW 1
        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("Invoice Sup : ");
        cell21.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell22 = row2.createCell(1);
        cell22.setCellValue(poad.getHeaderinvoicesupcode());
        cell22.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);

        HSSFCell cell23 = row2.createCell(2);
        cell23.setCellValue("Staff : ");
        cell23.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(2);
        HSSFCell cell24 = row2.createCell(3);
        cell24.setCellValue(poad.getHeaderstaff());
        cell24.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(3);

        // ROW 2   
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Pay Date : ");
        cell31.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(poad.getDatefromto());
        cell32.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);

        HSSFCell cell33 = row3.createCell(2);
        cell33.setCellValue("Ref No : ");
        cell33.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(2);
        HSSFCell cell34 = row3.createCell(3);
        cell34.setCellValue(poad.getHeaderrefno());
        cell34.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(3);

        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Inv Date : ");
        cell41.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell42 = row4.createCell(1);
        cell42.setCellValue(poad.getInvdatefromto());
        cell42.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell43 = row4.createCell(2);
        cell43.setCellValue("Inv Name : ");
        cell43.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell44 = row4.createCell(3);
        cell44.setCellValue(poad.getHeaderinvname());
        cell44.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);

        HSSFRow row5 = sheet.createRow(4);
        HSSFCell cell51 = row5.createCell(0);
        cell51.setCellValue("Country : ");
        cell51.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell52 = row5.createCell(1);
        cell52.setCellValue(poad.getHeadercountry());
        cell52.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell53 = row5.createCell(2);
        cell53.setCellValue("City : ");
        cell53.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell54 = row5.createCell(3);
        cell54.setCellValue(poad.getHeadercity());
        cell54.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);

        HSSFRow row6 = sheet.createRow(5);
        HSSFCell cell61 = row6.createCell(0);
        cell61.setCellValue("Product Type : ");
        cell61.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell62 = row6.createCell(1);
        cell62.setCellValue(poad.getHeaderproducttype());
        cell62.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);
        HSSFCell cell63 = row6.createCell(2);
        cell63.setCellValue("Product : ");
        cell63.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell64 = row6.createCell(3);
        cell64.setCellValue(poad.getHeaderproductname());
        cell64.setCellStyle(styleAlignLeft);
        sheet.autoSizeColumn(1);

    }

    // Header Table
    HSSFCellStyle styleHeader = wb.createCellStyle();
    styleHeader.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleHeader.setAlignment(styleHeader.ALIGN_CENTER);
    styleHeader.setBorderTop(styleHeader.BORDER_THIN);
    styleHeader.setBorderLeft(styleHeader.BORDER_THIN);
    styleHeader.setBorderBottom(styleHeader.BORDER_THIN);
    styleHeader.setBorderRight(styleHeader.BORDER_THIN);
    styleHeader.setVerticalAlignment(styleHeader.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);
    styleDetailTable.setVerticalAlignment(styleDetailTable.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableCenter = wb.createCellStyle();
    styleDetailTableCenter.setAlignment(styleDetailTableCenter.ALIGN_CENTER);
    styleDetailTableCenter.setBorderTop(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderBottom(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderRight(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setBorderLeft(styleDetailTableCenter.BORDER_THIN);
    styleDetailTableCenter.setWrapText(true);
    styleDetailTableCenter.setDataFormat(currency.getFormat("#,##0"));
    styleDetailTableCenter.setVerticalAlignment(styleDetailTableCenter.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableNumber = wb.createCellStyle();
    styleDetailTableNumber.setAlignment(styleDetailTableNumber.ALIGN_RIGHT);
    styleDetailTableNumber.setBorderLeft(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setBorderRight(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleDetailTableNumber.setWrapText(true);
    styleDetailTableNumber.setVerticalAlignment(styleDetailTableNumber.VERTICAL_CENTER);
    HSSFCellStyle styleDetailTableBorderBottom = wb.createCellStyle();
    styleDetailTableBorderBottom.setBorderTop(styleDetailTableBorderBottom.BORDER_THIN);
    HSSFCellStyle styleBorderTop = wb.createCellStyle();
    styleBorderTop.setBorderBottom(styleBorderTop.BORDER_THIN);
    styleBorderTop.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleBorderTop.setAlignment(styleBorderTop.ALIGN_CENTER);
    HSSFCellStyle styleBorderRight = wb.createCellStyle();
    styleBorderRight.setBorderRight(styleBorderRight.BORDER_THIN);
    styleBorderRight.setAlignment(styleBorderRight.ALIGN_CENTER);
    HSSFCellStyle styleBorderBottomAndRight = wb.createCellStyle();
    styleBorderBottomAndRight.setBorderRight(styleBorderBottomAndRight.BORDER_THIN);
    styleBorderBottomAndRight.setBorderBottom(styleBorderBottomAndRight.BORDER_THIN);
    styleBorderBottomAndRight.setAlignment(styleBorderBottomAndRight.ALIGN_CENTER);
    styleBorderBottomAndRight.setVerticalAlignment(styleBorderBottomAndRight.VERTICAL_CENTER);

    HSSFCellStyle styleAlignLeftBorderTopRight = wb.createCellStyle(); // use
    styleAlignLeftBorderTopRight.setAlignment(styleAlignLeftBorderTopRight.ALIGN_LEFT);
    styleAlignLeftBorderTopRight.setBorderTop(styleAlignLeftBorderTopRight.BORDER_THIN);
    styleAlignLeftBorderTopRight.setBorderRight(styleAlignLeftBorderTopRight.BORDER_THIN);
    styleAlignLeftBorderTopRight.setVerticalAlignment(styleAlignLeftBorderTopRight.VERTICAL_CENTER);
    HSSFCellStyle styleAlignLeftBorderTopLeft = wb.createCellStyle(); // use
    styleAlignLeftBorderTopLeft.setAlignment(styleAlignLeftBorderTopLeft.ALIGN_LEFT);
    styleAlignLeftBorderTopLeft.setBorderTop(styleAlignLeftBorderTopLeft.BORDER_THIN);
    styleAlignLeftBorderTopLeft.setBorderLeft(styleAlignLeftBorderTopLeft.BORDER_THIN);
    styleAlignLeftBorderTopLeft.setVerticalAlignment(styleAlignLeftBorderTopLeft.VERTICAL_CENTER);
    HSSFCellStyle styleBorderTopP = wb.createCellStyle(); // use
    styleBorderTopP.setBorderTop(styleBorderTopP.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderBottomRight = wb.createCellStyle();//use
    styleAlignRightBorderBottomRight.setAlignment(styleAlignRightBorderBottomRight.ALIGN_LEFT);
    styleAlignRightBorderBottomRight.setBorderBottom(styleAlignRightBorderBottomRight.BORDER_THIN);
    styleAlignRightBorderBottomRight.setBorderRight(styleAlignRightBorderBottomRight.BORDER_THIN);
    styleAlignRightBorderBottomRight.setVerticalAlignment(styleAlignRightBorderBottomRight.VERTICAL_CENTER);
    HSSFCellStyle styleAlignRightBorderBottomLeft = wb.createCellStyle();
    styleAlignRightBorderBottomLeft.setAlignment(styleAlignRightBorderBottomLeft.ALIGN_LEFT);
    styleAlignRightBorderBottomLeft.setBorderBottom(styleAlignRightBorderBottomLeft.BORDER_THIN);
    styleAlignRightBorderBottomLeft.setBorderLeft(styleAlignRightBorderBottomLeft.BORDER_THIN);
    styleAlignRightBorderBottomLeft.setVerticalAlignment(styleAlignRightBorderBottomLeft.VERTICAL_CENTER);
    HSSFCellStyle styleBorderBottom = wb.createCellStyle(); //use
    styleBorderBottom.setBorderBottom(styleBorderBottom.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderRight = wb.createCellStyle(); //use
    styleAlignRightBorderRight.setAlignment(styleAlignRightBorderRight.ALIGN_RIGHT);
    styleAlignRightBorderRight.setBorderRight(styleAlignRightBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignLeftBorderRight = wb.createCellStyle();
    styleAlignLeftBorderRight.setAlignment(styleAlignLeftBorderRight.ALIGN_LEFT);
    styleAlignLeftBorderRight.setBorderRight(styleAlignLeftBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderLeft = wb.createCellStyle();//use
    styleAlignRightBorderLeft.setAlignment(styleAlignRightBorderLeft.ALIGN_RIGHT);
    styleAlignRightBorderLeft.setBorderLeft(styleAlignRightBorderLeft.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderAllNumber = wb.createCellStyle();
    styleAlignRightBorderAllNumber.setAlignment(styleAlignRightBorderAllNumber.ALIGN_RIGHT);
    styleAlignRightBorderAllNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleAlignRightBorderAllNumber.setBorderTop(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderBottom(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderRight(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderLeft(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setVerticalAlignment(styleAlignRightBorderAllNumber.VERTICAL_CENTER);
    styleAlignRightBorderAllNumber.setWrapText(true);
    HSSFCellStyle styleAlignRightBorderAll = wb.createCellStyle();
    styleAlignRightBorderAll.setAlignment(styleAlignRightBorderAll.ALIGN_RIGHT);
    styleAlignRightBorderAll.setBorderTop(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderBottom(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderRight(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderLeft(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setVerticalAlignment(styleAlignRightBorderAll.VERTICAL_CENTER);
    styleAlignRightBorderAll.setWrapText(true);
    HSSFCellStyle styleAlignLeftBorderAllNumber = wb.createCellStyle();
    styleAlignLeftBorderAllNumber.setAlignment(styleAlignLeftBorderAllNumber.ALIGN_LEFT);
    styleAlignLeftBorderAllNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleAlignLeftBorderAllNumber.setBorderTop(styleAlignLeftBorderAllNumber.BORDER_THIN);
    styleAlignLeftBorderAllNumber.setBorderBottom(styleAlignLeftBorderAllNumber.BORDER_THIN);
    styleAlignLeftBorderAllNumber.setBorderRight(styleAlignLeftBorderAllNumber.BORDER_THIN);
    styleAlignLeftBorderAllNumber.setBorderLeft(styleAlignLeftBorderAllNumber.BORDER_THIN);
    styleAlignLeftBorderAllNumber.setVerticalAlignment(styleAlignLeftBorderAllNumber.VERTICAL_CENTER);
    styleAlignLeftBorderAllNumber.setWrapText(true);
    HSSFCellStyle styleAlignLeftBorderAll = wb.createCellStyle();
    styleAlignLeftBorderAll.setAlignment(styleAlignLeftBorderAll.ALIGN_LEFT);
    styleAlignLeftBorderAll.setBorderTop(styleAlignLeftBorderAll.BORDER_THIN);
    styleAlignLeftBorderAll.setBorderBottom(styleAlignLeftBorderAll.BORDER_THIN);
    styleAlignLeftBorderAll.setBorderRight(styleAlignLeftBorderAll.BORDER_THIN);
    styleAlignLeftBorderAll.setBorderLeft(styleAlignLeftBorderAll.BORDER_THIN);
    styleAlignLeftBorderAll.setVerticalAlignment(styleAlignLeftBorderAll.VERTICAL_CENTER);
    styleAlignLeftBorderAll.setWrapText(true);
    HSSFCellStyle styleAlignRightBorderAllNumberRate = wb.createCellStyle();
    styleAlignRightBorderAllNumberRate.setAlignment(styleAlignRightBorderAllNumberRate.ALIGN_RIGHT);
    styleAlignRightBorderAllNumberRate.setDataFormat(currency.getFormat("#,##0.0000"));
    styleAlignRightBorderAllNumberRate.setBorderTop(styleAlignRightBorderAllNumberRate.BORDER_THIN);
    styleAlignRightBorderAllNumberRate.setBorderBottom(styleAlignRightBorderAllNumberRate.BORDER_THIN);
    styleAlignRightBorderAllNumberRate.setBorderRight(styleAlignRightBorderAllNumberRate.BORDER_THIN);
    styleAlignRightBorderAllNumberRate.setBorderLeft(styleAlignRightBorderAllNumberRate.BORDER_THIN);
    styleAlignRightBorderAllNumberRate.setVerticalAlignment(styleAlignRightBorderAllNumberRate.VERTICAL_CENTER);
    styleAlignRightBorderAllNumberRate.setWrapText(true);

    HSSFRow row4 = sheet.createRow(6);
    for (int x = 0; x < 46; x++) {
        //            if( (x > 8 && x < 12) || ( x>17 && x < 26) || x == 30 || x == 31){
        row4.createCell(x).setCellStyle(styleBorderTop);
        //            }
    }

    HSSFRow row5 = sheet.createRow(7);
    HSSFCell cell51 = row5.createCell(0);
    cell51.setCellValue("REF NO");
    cell51.setCellStyle(styleHeader);
    sheet.autoSizeColumn(0);
    HSSFCell cell52 = row5.createCell(1);
    cell52.setCellValue("ISSUE DATE");
    cell52.setCellStyle(styleHeader);
    sheet.autoSizeColumn(1);
    HSSFCell cell53 = row5.createCell(2);
    cell53.setCellValue("TOUR CODE");
    cell53.setCellStyle(styleHeader);
    sheet.autoSizeColumn(2);
    HSSFCell cell54 = row5.createCell(3);
    cell54.setCellValue("INV NO");
    cell54.setCellStyle(styleHeader);
    sheet.autoSizeColumn(3);
    HSSFCell cell55 = row5.createCell(4);
    cell55.setCellValue("INV DATE");
    cell55.setCellStyle(styleHeader);
    sheet.autoSizeColumn(4);
    HSSFCell cell56 = row5.createCell(5);
    cell56.setCellValue("STAFF");
    cell56.setCellStyle(styleHeader);
    sheet.autoSizeColumn(5);
    HSSFCell cell57 = row5.createCell(6);
    cell57.setCellValue("INV TO");
    cell57.setCellStyle(styleHeader);
    sheet.autoSizeColumn(6);
    HSSFCell cell58 = row5.createCell(7);
    cell58.setCellValue("PAX");
    cell58.setCellStyle(styleHeader);
    sheet.autoSizeColumn(7);
    HSSFCell cell59 = row5.createCell(10);
    cell59.setCellValue("COUNTRY");
    cell59.setCellStyle(styleHeader);
    sheet.autoSizeColumn(10);
    HSSFCell cell60 = row5.createCell(11);
    cell60.setCellValue("CITY");
    cell60.setCellStyle(styleHeader);
    sheet.autoSizeColumn(11);
    HSSFCell cell61 = row5.createCell(12);
    cell61.setCellValue("P TYPE");
    cell61.setCellStyle(styleHeader);
    sheet.autoSizeColumn(12);
    HSSFCell cell62 = row5.createCell(13);
    cell62.setCellValue("DEPARTTURE");
    cell62.setCellStyle(styleHeader);
    sheet.autoSizeColumn(13);
    HSSFCell cell63 = row5.createCell(14);
    cell63.setCellValue("NO TICKET");
    cell63.setCellStyle(styleHeader);
    sheet.autoSizeColumn(14);
    HSSFCell cell64 = row5.createCell(15);
    cell64.setCellValue("DESCRIPTION");
    cell64.setCellStyle(styleHeader);
    sheet.autoSizeColumn(15);
    HSSFCell cell65 = row5.createCell(16);
    cell65.setCellValue("PERIOD OF USED");
    cell65.setCellStyle(styleHeader);
    sheet.autoSizeColumn(16);
    HSSFCell cell66 = row5.createCell(18);
    cell66.setCellValue("QTY");
    cell66.setCellStyle(styleHeader);
    sheet.autoSizeColumn(18);
    HSSFCell cell67 = row5.createCell(21);
    cell67.setCellValue("BEFORE VAT");
    cell67.setCellStyle(styleHeader);
    sheet.autoSizeColumn(21);
    HSSFCell cell68 = row5.createCell(22);
    cell68.setCellValue("PRICE");
    cell68.setCellStyle(styleHeader);
    sheet.autoSizeColumn(22);
    HSSFCell cell69 = row5.createCell(23);
    cell69.setCellValue("ACC");
    cell69.setCellStyle(styleHeader);
    sheet.autoSizeColumn(23);
    HSSFCell cell70 = row5.createCell(24);
    cell70.setCellValue("PAID");
    cell70.setCellStyle(styleHeader);
    sheet.autoSizeColumn(24);
    HSSFCell cell71 = row5.createCell(33);
    cell71.setCellValue("AMOUNT LOCAL (R)");
    cell71.setCellStyle(styleHeader);
    sheet.autoSizeColumn(33);
    HSSFCell cell72 = row5.createCell(34);
    cell72.setCellValue("AMOUNT LOCAL (P)");
    cell72.setCellStyle(styleHeader);
    sheet.autoSizeColumn(34);
    HSSFCell cell73 = row5.createCell(35);
    cell73.setCellValue("VAT");
    cell73.setCellStyle(styleHeader);
    sheet.autoSizeColumn(35);
    HSSFCell cell74 = row5.createCell(36);
    cell74.setCellValue("WHT");
    cell74.setCellStyle(styleHeader);
    sheet.autoSizeColumn(36);
    HSSFCell cell75 = row5.createCell(37);
    cell75.setCellValue("GROSS PROFIT");
    cell75.setCellStyle(styleHeader);
    sheet.autoSizeColumn(37);
    HSSFCell cell76 = row5.createCell(39);
    cell76.setCellValue("PAYCOM");
    cell76.setCellStyle(styleHeader);
    sheet.autoSizeColumn(39);
    HSSFCell cell77 = row5.createCell(43);
    cell77.setCellValue("PROFIT BALANCE");
    cell77.setCellStyle(styleHeader);
    sheet.autoSizeColumn(43);
    HSSFCell cell78 = row5.createCell(44);
    cell78.setCellValue("RECEIPT NO");
    cell78.setCellStyle(styleHeader);
    sheet.autoSizeColumn(44);
    HSSFCell cell79 = row5.createCell(45);
    cell79.setCellValue("RECEIPT DATE");
    cell79.setCellStyle(styleHeader);
    sheet.autoSizeColumn(45);
    //        HSSFCell cell80 = row5.createCell(45);
    //            cell80.setCellValue("");
    //            cell80.setCellStyle(styleHeader);
    //            sheet.autoSizeColumn(45);

    sheet.addMergedRegion(CellRangeAddress.valueOf("H8:J8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("Q8:R8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("S8:U8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("Y8:AG8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("AL8:AM8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("AN8:AQ8"));

    //        row5.createCell(11).setCellStyle(styleBorderRight); 
    //        row5.createCell(25).setCellStyle(styleBorderRight); 
    //        row5.createCell(31).setCellStyle(styleBorderRight); 

    String merge[] = { "A", "B", "C", "D", "E", "F", "G", "K", "L", "M", "N", "O", "P", "V", "W", "X", "AH",
            "AI", "AJ", "AK", "AR", "AS", "AT" };
    for (int x = 0; x < merge.length; x++) {
        sheet.addMergedRegion(CellRangeAddress.valueOf(merge[x] + "8:" + merge[x] + "9"));
    }

    HSSFRow row6 = sheet.createRow(8);
    for (int x = 0; x < 46; x++) {
        row6.createCell(x).setCellStyle(styleBorderBottomAndRight);
    }

    HSSFCell cell073 = row6.createCell(7);
    cell073.setCellValue("AD");
    cell073.setCellStyle(styleHeader);
    sheet.autoSizeColumn(7);
    HSSFCell cell074 = row6.createCell(8);
    cell074.setCellValue("CH");
    cell074.setCellStyle(styleHeader);
    sheet.autoSizeColumn(8);
    HSSFCell cell075 = row6.createCell(9);
    cell075.setCellValue("IN");
    cell075.setCellStyle(styleHeader);
    sheet.autoSizeColumn(9);
    HSSFCell cell0018 = row6.createCell(16);
    cell0018.setCellValue("IN");
    cell0018.setCellStyle(styleHeader);
    sheet.autoSizeColumn(16);
    HSSFCell cell0019 = row6.createCell(17);
    cell0019.setCellValue("OUT");
    cell0019.setCellStyle(styleHeader);
    sheet.autoSizeColumn(17);
    HSSFCell cell0020 = row6.createCell(18);
    cell0020.setCellValue("ROOM");
    cell0020.setCellStyle(styleHeader);
    sheet.autoSizeColumn(18);
    HSSFCell cell0021 = row6.createCell(19);
    cell0021.setCellValue("NIGHT");
    cell0021.setCellStyle(styleHeader);
    sheet.autoSizeColumn(19);
    HSSFCell cell0022 = row6.createCell(20);
    cell0022.setCellValue("TTL");
    cell0022.setCellStyle(styleHeader);
    sheet.autoSizeColumn(20);
    HSSFCell cell076 = row6.createCell(24);
    cell076.setCellValue("PV NO");
    cell076.setCellStyle(styleHeader);
    sheet.autoSizeColumn(24);
    HSSFCell cell077 = row6.createCell(25);
    cell077.setCellValue("DATE");
    cell077.setCellStyle(styleHeader);
    sheet.autoSizeColumn(25);
    HSSFCell cell078 = row6.createCell(26);
    cell078.setCellValue("INV SUP");
    cell078.setCellStyle(styleHeader);
    sheet.autoSizeColumn(26);
    HSSFCell cell079 = row6.createCell(27);
    cell079.setCellValue("INV NO");
    cell079.setCellStyle(styleHeader);
    sheet.autoSizeColumn(27);
    HSSFCell cell0079 = row6.createCell(28);
    cell0079.setCellValue("INV DATE");
    cell0079.setCellStyle(styleHeader);
    sheet.autoSizeColumn(28);
    HSSFCell cell080 = row6.createCell(29);
    cell080.setCellValue("AMOUNT");
    cell080.setCellStyle(styleHeader);
    sheet.autoSizeColumn(29);
    HSSFCell cell081 = row6.createCell(30);
    cell081.setCellValue("CUR");
    cell081.setCellStyle(styleHeader);
    sheet.autoSizeColumn(30);
    HSSFCell cell082 = row6.createCell(31);
    cell082.setCellValue("REAL RATE");
    cell082.setCellStyle(styleHeader);
    sheet.autoSizeColumn(31);
    HSSFCell cell083 = row6.createCell(32);
    cell083.setCellValue("PAY RATE");
    cell083.setCellStyle(styleHeader);
    sheet.autoSizeColumn(32);
    HSSFCell cell084 = row6.createCell(37);
    cell084.setCellValue("REAL");
    cell084.setCellStyle(styleHeader);
    sheet.autoSizeColumn(37);
    HSSFCell cell85 = row6.createCell(38);
    cell85.setCellValue("PAY");
    cell85.setCellStyle(styleHeader);
    sheet.autoSizeColumn(38);
    HSSFCell cell86 = row6.createCell(39);
    cell86.setCellValue("DATE");
    cell86.setCellStyle(styleHeader);
    sheet.autoSizeColumn(39);
    HSSFCell cell87 = row6.createCell(40);
    cell87.setCellValue("PAYEE");
    cell87.setCellStyle(styleHeader);
    sheet.autoSizeColumn(40);
    HSSFCell cell88 = row6.createCell(41);
    cell88.setCellValue("PV NO");
    cell88.setCellStyle(styleHeader);
    sheet.autoSizeColumn(41);
    HSSFCell cell89 = row6.createCell(42);
    cell89.setCellValue("COM");
    cell89.setCellStyle(styleHeader);
    sheet.autoSizeColumn(42);

    int count = 9;
    for (int i = 0; i < listPaymentSummary.size(); i++) {
        PaymentOutboundAllDetail data = (PaymentOutboundAllDetail) listPaymentSummary.get(i);
        HSSFRow row = sheet.createRow(count + i);

        HSSFCell celldata00 = row.createCell(0);
        celldata00.setCellValue(String.valueOf(data.getRefno()));
        celldata00.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata01 = row.createCell(1);
        celldata01.setCellValue(String.valueOf(data.getIssuedate()));
        celldata01.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata02 = row.createCell(2);
        celldata02.setCellValue(String.valueOf(data.getTourcode()));
        celldata02.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata03 = row.createCell(3);
        celldata03.setCellValue(String.valueOf(data.getInvno()));
        celldata03.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata04 = row.createCell(4);
        celldata04.setCellValue(String.valueOf(data.getInvdate()));
        celldata04.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata05 = row.createCell(5);
        celldata05.setCellValue(String.valueOf(data.getStaff()));
        celldata05.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata06 = row.createCell(6);
        celldata06.setCellValue(String.valueOf(data.getInvto()));
        celldata06.setCellStyle(styleAlignLeftBorderAll);

        HSSFCell celldata07 = row.createCell(7);
        celldata07.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAdult())) ? 0
                : (new BigDecimal(data.getAdult())).doubleValue());
        celldata07.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata08 = row.createCell(8);
        celldata08.setCellValue("".equalsIgnoreCase(String.valueOf(data.getChild())) ? 0
                : (new BigDecimal(data.getChild())).doubleValue());
        celldata08.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata09 = row.createCell(9);
        celldata09.setCellValue("".equalsIgnoreCase(String.valueOf(data.getInfant())) ? 0
                : (new BigDecimal(data.getInfant())).doubleValue());
        celldata09.setCellStyle(styleDetailTableCenter);

        HSSFCell celldata10 = row.createCell(10);
        celldata10.setCellValue(String.valueOf(data.getCountry()));
        celldata10.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata11 = row.createCell(11);
        celldata11.setCellValue(String.valueOf(data.getCity()));
        celldata11.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata12 = row.createCell(12);
        celldata12.setCellValue(String.valueOf(data.getProducttype()));
        celldata12.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata13 = row.createCell(13);
        celldata13.setCellValue(String.valueOf(data.getDepartdate()));
        celldata13.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata14 = row.createCell(14);
        celldata14.setCellValue(String.valueOf(data.getNoticket()));
        celldata14.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata15 = row.createCell(15);
        celldata15.setCellValue(String.valueOf(data.getDescription()));
        celldata15.setCellStyle(styleAlignLeftBorderAll);

        HSSFCell celldata16 = row.createCell(16);
        celldata16.setCellValue(String.valueOf(data.getPeriodin()));
        celldata16.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata17 = row.createCell(17);
        celldata17.setCellValue(String.valueOf(data.getPeriodout()));
        celldata17.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata18 = row.createCell(18);
        celldata18.setCellValue("".equalsIgnoreCase(String.valueOf(data.getQtyroom())) ? 0
                : (new BigDecimal(data.getQtyroom())).doubleValue());
        celldata18.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata19 = row.createCell(19);
        celldata19.setCellValue("".equalsIgnoreCase(String.valueOf(data.getQtynight())) ? 0
                : (new BigDecimal(data.getQtynight())).doubleValue());
        celldata19.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata20 = row.createCell(20);
        celldata20.setCellValue("".equalsIgnoreCase(String.valueOf(data.getQtyttl())) ? 0
                : (new BigDecimal(data.getQtyttl())).doubleValue());
        celldata20.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata21 = row.createCell(21);
        celldata21.setCellValue(
                "".equalsIgnoreCase(String.valueOf(data.getBeforevat())) || data.getBeforevat() == null ? 0
                        : (new BigDecimal(data.getBeforevat())).doubleValue());
        celldata21.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata22 = row.createCell(22);
        celldata22.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPrice())) ? 0
                : (new BigDecimal(data.getPrice())).doubleValue());
        celldata22.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata23 = row.createCell(23);
        celldata23.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAcc())) ? 0
                : (new BigDecimal(data.getAcc())).doubleValue());
        celldata23.setCellStyle(styleDetailTableCenter);

        HSSFCell celldata24 = row.createCell(24);
        celldata24.setCellValue(String.valueOf(data.getPvno()));
        celldata24.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata25 = row.createCell(25);
        celldata25.setCellValue(String.valueOf(data.getPaydate()));
        celldata25.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata26 = row.createCell(26);
        celldata26.setCellValue(String.valueOf(data.getInvsup()));
        celldata26.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata27 = row.createCell(27);
        celldata27.setCellValue(String.valueOf(data.getPayinvno()));
        celldata27.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata28 = row.createCell(28);
        celldata28.setCellValue(String.valueOf(data.getPayinvdate()));
        celldata28.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata29 = row.createCell(29);
        celldata29.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmount())) ? 0
                : (new BigDecimal(data.getAmount())).doubleValue());
        celldata29.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata30 = row.createCell(30);
        celldata30.setCellValue(String.valueOf(data.getPaycur()));
        celldata30.setCellStyle(styleDetailTableCenter);
        HSSFCell celldata31 = row.createCell(31);
        celldata31.setCellValue("".equalsIgnoreCase(String.valueOf(data.getRealrate())) ? 0
                : (new BigDecimal(data.getRealrate())).doubleValue());
        celldata31.setCellStyle(styleAlignRightBorderAllNumberRate);
        HSSFCell celldata32 = row.createCell(32);
        celldata32.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPayrate())) ? 0
                : (new BigDecimal(data.getPayrate())).doubleValue());
        celldata32.setCellStyle(styleAlignRightBorderAllNumberRate);
        HSSFCell celldata33 = row.createCell(33);
        celldata33.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountlocalr())) ? 0
                : (new BigDecimal(data.getAmountlocalr())).doubleValue());
        celldata33.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata34 = row.createCell(34);
        celldata34.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountlocalp())) ? 0
                : (new BigDecimal(data.getAmountlocalp())).doubleValue());
        celldata34.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata35 = row.createCell(35);
        celldata35.setCellValue("".equalsIgnoreCase(String.valueOf(data.getVat())) ? 0
                : (new BigDecimal(data.getVat())).doubleValue());
        celldata35.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata36 = row.createCell(36);
        celldata36.setCellValue("".equalsIgnoreCase(String.valueOf(data.getWht())) ? 0
                : (new BigDecimal(data.getWht())).doubleValue());
        celldata36.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata37 = row.createCell(37);
        celldata37.setCellValue("".equalsIgnoreCase(String.valueOf(data.getGrossreal())) ? 0
                : (new BigDecimal(data.getGrossreal())).doubleValue());
        celldata37.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata38 = row.createCell(38);
        celldata38.setCellValue("".equalsIgnoreCase(String.valueOf(data.getGrosspay())) ? 0
                : (new BigDecimal(data.getGrosspay())).doubleValue());
        celldata38.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata39 = row.createCell(39);
        celldata39.setCellValue(String.valueOf(data.getPaycomdate().trim()));
        celldata39.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata40 = row.createCell(40);
        celldata40.setCellValue(String.valueOf(data.getPaycomstaff()));
        celldata40.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata41 = row.createCell(41);
        celldata41.setCellValue(String.valueOf(data.getPaycompvno()));
        celldata41.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata42 = row.createCell(42);
        System.out.println("data.getPaycommission() : " + data.getPaycommission());
        celldata42.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaycommission())) ? 0
                : (new BigDecimal(data.getPaycommission().replaceAll(",", ""))).doubleValue());
        celldata42.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata43 = row.createCell(43);
        celldata43.setCellValue("".equalsIgnoreCase(String.valueOf(data.getBalanceprofit())) ? 0
                : (new BigDecimal(data.getBalanceprofit())).doubleValue());
        celldata43.setCellStyle(styleAlignRightBorderAllNumber);
        HSSFCell celldata44 = row.createCell(44);
        celldata44.setCellValue(String.valueOf(data.getReceiptno()));
        celldata44.setCellStyle(styleAlignLeftBorderAll);
        HSSFCell celldata45 = row.createCell(45);
        celldata45.setCellValue(String.valueOf(data.getReceiptdate()));
        celldata45.setCellStyle(styleAlignLeftBorderAll);

        if (i == (listPaymentSummary.size() - 1)) {
            row = sheet.createRow(count + i + 1);
            for (int k = 0; k < 46; k++) {
                HSSFCellStyle styleSum = wb.createCellStyle();
                styleSum.setAlignment(styleSum.ALIGN_RIGHT);
                styleSum.setBorderTop(HSSFCellStyle.BORDER_THIN);
                styleSum.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                HSSFCell cellSum = row.createCell(k);
                if (k == 0) {
                    styleSum.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                }
                if (k == 45) {
                    styleSum.setBorderRight(HSSFCellStyle.BORDER_THIN);
                }
                cellSum.setCellStyle(styleSum);
            }
            HSSFCellStyle styleSum = wb.createCellStyle();
            styleSum.setFont(excelFunction.getTotalDetailBoldFont(wb.createFont()));
            styleSum.setAlignment(styleSum.ALIGN_RIGHT);
            styleSum.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleSum.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleSum.setBorderTop(HSSFCellStyle.BORDER_THIN);
            styleSum.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleSum.setDataFormat(currency.getFormat("#,##0.00"));

            HSSFCellStyle styleSumCenter = wb.createCellStyle();
            styleSumCenter.setFont(excelFunction.getTotalDetailBoldFont(wb.createFont()));
            styleSumCenter.setAlignment(styleSum.ALIGN_CENTER);
            styleSumCenter.setBorderLeft(HSSFCellStyle.BORDER_THIN);
            styleSumCenter.setBorderRight(HSSFCellStyle.BORDER_THIN);
            styleSumCenter.setBorderTop(HSSFCellStyle.BORDER_THIN);
            styleSumCenter.setBorderBottom(HSSFCellStyle.BORDER_THIN);
            styleSumCenter.setDataFormat(currency.getFormat("#,##0"));

            String sumAd = "SUM(H" + 10 + ":H" + (count + i + 1) + ")";
            String sumCh = "SUM(I" + 10 + ":I" + (count + i + 1) + ")";
            String sumIn = "SUM(J" + 10 + ":J" + (count + i + 1) + ")";
            String sumRoom = "SUM(S" + 10 + ":S" + (count + i + 1) + ")";
            String sumNight = "SUM(T" + 10 + ":T" + (count + i + 1) + ")";
            String sumTtl = "SUM(U" + 10 + ":U" + (count + i + 1) + ")";
            String sumBeforeVat = "SUM(V" + 10 + ":V" + (count + i + 1) + ")";
            String sumPrice = "SUM(W" + 10 + ":W" + (count + i + 1) + ")";
            String sumAmount = "SUM(AD" + 10 + ":AD" + (count + i + 1) + ")";
            String sumLocalR = "SUM(AH" + 10 + ":AH" + (count + i + 1) + ")";
            String sumLocalP = "SUM(AI" + 10 + ":AI" + (count + i + 1) + ")";
            String sumVat = "SUM(AJ" + 10 + ":AJ" + (count + i + 1) + ")";
            String sumWht = "SUM(AK" + 10 + ":AK" + (count + i + 1) + ")";
            String sumGrossReal = "SUM(AL" + 10 + ":AL" + (count + i + 1) + ")";
            String sumGrossPay = "SUM(AM" + 10 + ":AM" + (count + i + 1) + ")";
            String sumPaycomCom = "SUM(AQ" + 10 + ":AQ" + (count + i + 1) + ")";
            String sumProfitBalance = "SUM(AR" + 10 + ":AR" + (count + i + 1) + ")";

            HSSFCell cell5Sum = row.createCell(6);
            cell5Sum.setCellValue("Total");
            cell5Sum.setCellStyle(styleSumCenter);
            HSSFCell cell7Sum = row.createCell(7);
            cell7Sum.setCellFormula(sumAd);
            cell7Sum.setCellStyle(styleSumCenter);
            HSSFCell cell8Sum = row.createCell(8);
            cell8Sum.setCellFormula(sumCh);
            cell8Sum.setCellStyle(styleSumCenter);
            HSSFCell cell9Sum = row.createCell(9);
            cell9Sum.setCellFormula(sumIn);
            cell9Sum.setCellStyle(styleSumCenter);
            HSSFCell cell18Sum = row.createCell(18);
            cell18Sum.setCellFormula(sumRoom);
            cell18Sum.setCellStyle(styleSumCenter);
            HSSFCell cell19Sum = row.createCell(19);
            cell19Sum.setCellFormula(sumNight);
            cell19Sum.setCellStyle(styleSumCenter);
            HSSFCell cell20Sum = row.createCell(20);
            cell20Sum.setCellFormula(sumTtl);
            cell20Sum.setCellStyle(styleSumCenter);
            HSSFCell cell21Sum = row.createCell(21);
            cell21Sum.setCellFormula(sumBeforeVat);
            cell21Sum.setCellStyle(styleSum);
            HSSFCell cell22Sum = row.createCell(22);
            cell22Sum.setCellFormula(sumPrice);
            cell22Sum.setCellStyle(styleSum);
            HSSFCell cell29Sum = row.createCell(29);
            cell29Sum.setCellFormula(sumAmount);
            cell29Sum.setCellStyle(styleSum);
            HSSFCell cell33Sum = row.createCell(33);
            cell33Sum.setCellFormula(sumLocalR);
            cell33Sum.setCellStyle(styleSum);
            HSSFCell cell34Sum = row.createCell(34);
            cell34Sum.setCellFormula(sumLocalP);
            cell34Sum.setCellStyle(styleSum);
            HSSFCell cell35Sum = row.createCell(35);
            cell35Sum.setCellFormula(sumVat);
            cell35Sum.setCellStyle(styleSum);
            HSSFCell cell36Sum = row.createCell(36);
            cell36Sum.setCellFormula(sumWht);
            cell36Sum.setCellStyle(styleSum);
            HSSFCell cell37Sum = row.createCell(37);
            cell37Sum.setCellFormula(sumGrossReal);
            cell37Sum.setCellStyle(styleSum);
            HSSFCell cell38Sum = row.createCell(38);
            cell38Sum.setCellFormula(sumGrossPay);
            cell38Sum.setCellStyle(styleSum);
            HSSFCell cell42Sum = row.createCell(42);
            cell42Sum.setCellFormula(sumPaycomCom);
            cell42Sum.setCellStyle(styleSum);
            HSSFCell cell43Sum = row.createCell(43);
            cell43Sum.setCellFormula(sumProfitBalance);
            cell43Sum.setCellStyle(styleSum);
        }
    }
    sheet.setColumnWidth(2, 256 * 20);
    sheet.setColumnWidth(3, 256 * 15);
    sheet.setColumnWidth(4, 256 * 15);
    sheet.setColumnWidth(5, 256 * 30);
    sheet.setColumnWidth(6, 256 * 15);
    sheet.setColumnWidth(10, 256 * 15);
    sheet.setColumnWidth(11, 256 * 15);
    sheet.setColumnWidth(12, 256 * 15);

    sheet.setColumnWidth(16, 256 * 15);
    sheet.setColumnWidth(17, 256 * 15);
    sheet.setColumnWidth(18, 256 * 10);
    sheet.setColumnWidth(19, 256 * 10);
    sheet.setColumnWidth(20, 256 * 10);

    sheet.setColumnWidth(21, 256 * 15);
    sheet.setColumnWidth(22, 256 * 15);
    sheet.setColumnWidth(23, 256 * 15);
    sheet.setColumnWidth(24, 256 * 15);
    sheet.setColumnWidth(25, 256 * 15);
    sheet.setColumnWidth(26, 256 * 30);
    sheet.setColumnWidth(27, 256 * 15);
    sheet.setColumnWidth(28, 256 * 15);
    sheet.setColumnWidth(29, 256 * 15);

    sheet.setColumnWidth(35, 256 * 10);
    sheet.setColumnWidth(36, 256 * 10);
    sheet.setColumnWidth(37, 256 * 15);
    sheet.setColumnWidth(38, 256 * 15);
    sheet.setColumnWidth(39, 256 * 15);
    sheet.setColumnWidth(40, 256 * 20);
    sheet.setColumnWidth(41, 256 * 15);
    sheet.setColumnWidth(42, 256 * 15);
}

From source file:com.smi.travel.controller.excel.checking.airticket.AirlineSummary.java

private void getSummaryAirline(HSSFWorkbook wb, List summaryAirline) {
    List<SummaryAirline> listAR = summaryAirline;
    String sheetName = "Sheet1";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    // Set align Text
    HSSFCellStyle styleAlignRight = wb.createCellStyle();
    styleAlignRight.setAlignment(styleAlignRight.ALIGN_RIGHT);
    HSSFCellStyle styleAlignLeft = wb.createCellStyle();
    styleAlignLeft.setAlignment(styleAlignLeft.ALIGN_LEFT);
    HSSFCellStyle styleAlignCenter = wb.createCellStyle();
    styleAlignCenter.setAlignment(styleAlignCenter.ALIGN_CENTER);
    HSSFCellStyle styleBorderLeft = wb.createCellStyle();
    styleBorderLeft.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    HSSFCellStyle styleBorderRight = wb.createCellStyle();
    styleBorderRight.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    HSSFDataFormat currency = wb.createDataFormat();
    HSSFCellStyle styleNumber = wb.createCellStyle();
    styleNumber.setAlignment(styleNumber.ALIGN_RIGHT);
    styleNumber.setDataFormat(currency.getFormat("#,##0.00"));
    HSSFCellStyle styleNumberBorderRight = wb.createCellStyle();
    styleNumberBorderRight.setAlignment(styleNumberBorderRight.ALIGN_RIGHT);
    styleNumberBorderRight.setDataFormat(currency.getFormat("#,##0.00"));
    styleNumberBorderRight.setBorderRight(styleNumberBorderRight.BORDER_THIN);

    // set Header Report (Row 1)
    HSSFCellStyle styleC1 = wb.createCellStyle();
    HSSFRow row1 = sheet.createRow(0);//from w w w  .j  a  v  a 2  s.  com
    HSSFCell cell0 = row1.createCell(0);
    cell0.setCellValue("LIST SUMMARY AIRLINE");
    styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell0.setCellStyle(styleC1);
    sheet.autoSizeColumn(0);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:I1"));

    // Row 2
    HSSFRow row2 = sheet.createRow(1);
    HSSFCell cell1 = row2.createCell(0);
    cell1.setCellValue("Invoice Date : ");
    cell1.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell2 = row2.createCell(1);
    Date date = new Date();
    SimpleDateFormat sm = new SimpleDateFormat("dd-MM-yyyy");
    String strDate = sm.format(date);
    cell2.setCellValue(strDate);
    cell2.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    HSSFCell cell3 = row2.createCell(2);
    cell3.setCellValue(" To ");
    cell3.setCellStyle(styleAlignCenter);
    sheet.autoSizeColumn(2);
    HSSFCell cell4 = row2.createCell(3);
    cell4.setCellValue(strDate);
    cell4.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(3);
    HSSFCell cell5 = row2.createCell(4);
    cell5.setCellValue("Print on : ");
    cell5.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell6 = row2.createCell(5);
    cell6.setCellValue(strDate);
    cell6.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 3
    HSSFRow row3 = sheet.createRow(2);
    HSSFCell cell31 = row3.createCell(0);
    cell31.setCellValue("Print By : ");
    cell31.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell32 = row3.createCell(1);
    cell32.setCellValue("Adminstarator");
    cell32.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
    HSSFCell cell33 = row3.createCell(4);
    cell33.setCellValue("Rounting Detail : ");
    cell33.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell34 = row3.createCell(5);
    cell34.setCellValue("XXXXXXXXXX");
    cell34.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 4
    HSSFRow row4 = sheet.createRow(3);
    HSSFCell cell41 = row4.createCell(0);
    cell41.setCellValue("Type Rounting : ");
    cell41.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell42 = row4.createCell(1);
    cell42.setCellValue("XXXXXXXX");
    cell42.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));
    HSSFCell cell43 = row4.createCell(4);
    cell43.setCellValue("Passenger : ");
    cell43.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell44 = row4.createCell(5);
    cell44.setCellValue("XXXXXXXXXX");
    cell44.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 5
    HSSFRow row5 = sheet.createRow(4);
    HSSFCell cell51 = row5.createCell(0);
    cell51.setCellValue("Air : ");
    cell51.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell52 = row5.createCell(1);
    cell52.setCellValue("XXXXXXXX");
    cell52.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));
    HSSFCell cell53 = row5.createCell(4);
    cell53.setCellValue("Sale Staff : ");
    cell53.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell54 = row5.createCell(5);
    cell54.setCellValue("XXXXXXXXXX");
    cell54.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 6
    HSSFRow row6 = sheet.createRow(5);
    HSSFCell cell61 = row6.createCell(0);
    cell61.setCellValue("Agent Name : ");
    cell61.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell62 = row6.createCell(1);
    cell62.setCellValue("XXXXXXXX");
    cell62.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B6:D6"));
    HSSFCell cell63 = row6.createCell(4);
    cell63.setCellValue("Department : ");
    cell63.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell64 = row6.createCell(5);
    cell64.setCellValue("XXXXXXXXXX");
    cell64.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 7
    HSSFRow row7 = sheet.createRow(6);
    HSSFCell cell71 = row7.createCell(0);
    cell71.setCellValue("Term Pay : ");
    cell71.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell72 = row7.createCell(1);
    cell72.setCellValue("XXXXXXXX");
    cell72.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));

    // Header Table
    HSSFCellStyle styleHeader = wb.createCellStyle();
    styleHeader.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleHeader.setAlignment(styleHeader.ALIGN_CENTER);
    styleHeader.setBorderTop(styleHeader.BORDER_THIN);
    styleHeader.setBorderLeft(styleHeader.BORDER_THIN);
    styleHeader.setBorderBottom(styleHeader.BORDER_THIN);
    styleHeader.setBorderRight(styleHeader.BORDER_THIN);
    HSSFCellStyle styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);
    HSSFCellStyle styleDetailTableNumber = wb.createCellStyle();
    styleDetailTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleDetailTableNumber.setAlignment(styleDetailTableNumber.ALIGN_RIGHT);
    styleDetailTableNumber.setBorderLeft(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setBorderRight(styleDetailTableNumber.BORDER_THIN);
    HSSFCellStyle styleDetailTableBorderBottom = wb.createCellStyle();
    styleDetailTableBorderBottom.setBorderTop(styleDetailTableBorderBottom.BORDER_THIN);

    HSSFRow rowH = sheet.createRow(8);
    HSSFCell cellH1 = rowH.createCell(0);
    cellH1.setCellValue("Rounting");
    cellH1.setCellStyle(styleHeader);
    sheet.autoSizeColumn(0);
    HSSFCell cellH2 = rowH.createCell(1);
    cellH2.setCellValue("Pax");
    cellH2.setCellStyle(styleHeader);
    sheet.autoSizeColumn(1);
    HSSFCell cellH3 = rowH.createCell(2);
    cellH3.setCellValue("Net Sales");
    cellH3.setCellStyle(styleHeader);
    sheet.autoSizeColumn(2);
    HSSFCell cellH4 = rowH.createCell(3);
    cellH4.setCellValue("Tax");
    cellH4.setCellStyle(styleHeader);
    sheet.autoSizeColumn(3);
    HSSFCell cellH5 = rowH.createCell(4);
    cellH5.setCellValue("Ins");
    cellH5.setCellStyle(styleHeader);
    sheet.autoSizeColumn(4);
    HSSFCell cellH6 = rowH.createCell(5);
    cellH6.setCellValue("Comms");
    cellH6.setCellStyle(styleHeader);
    sheet.autoSizeColumn(5);
    HSSFCell cellH7 = rowH.createCell(6);
    cellH7.setCellValue("Amount Wendy");
    cellH7.setCellStyle(styleHeader);
    sheet.autoSizeColumn(6);
    HSSFCell cellH8 = rowH.createCell(7);
    cellH8.setCellValue("Amount Inbound");
    cellH8.setCellStyle(styleHeader);
    sheet.autoSizeColumn(7);
    HSSFCell cellH9 = rowH.createCell(8);
    cellH9.setCellValue("Diff");
    cellH9.setCellStyle(styleHeader);
    sheet.autoSizeColumn(8);
    if (listAR != null && listAR.size() != 0) {
        int count = 9 + listAR.size();
        int start = 11;
        int end = 0;
        int num = 0;
        for (int r = 9; r < count; r++) {
            if (num <= (listAR.size() - 1)) {
                HSSFRow rowH1 = sheet.createRow(r);
                HSSFCell cellH11 = rowH1.createCell(0);
                cellH11.setCellValue(listAR.get(num).getRouting());
                cellH11.setCellStyle(styleDetailTable);
                sheet.autoSizeColumn(0);
                HSSFCell cellH21 = rowH1.createCell(1);
                cellH21.setCellValue((listAR.get(num).getPax() != null) ? listAR.get(num).getPax().doubleValue()
                        : new BigDecimal("0").doubleValue());
                cellH21.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(1);
                HSSFCell cellH31 = rowH1.createCell(2);
                cellH31.setCellValue(
                        (listAR.get(num).getNetsale() != null) ? listAR.get(num).getNetsale().doubleValue()
                                : new BigDecimal("0").doubleValue());
                cellH31.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(2);
                HSSFCell cellH41 = rowH1.createCell(3);
                cellH41.setCellValue((listAR.get(num).getTax() != null) ? listAR.get(num).getTax().doubleValue()
                        : new BigDecimal("0").doubleValue());
                cellH41.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(3);
                HSSFCell cellH51 = rowH1.createCell(4);
                cellH51.setCellValue((listAR.get(num).getIns() != null) ? listAR.get(num).getIns().doubleValue()
                        : new BigDecimal("0").doubleValue());
                cellH51.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(4);
                HSSFCell cellH61 = rowH1.createCell(5);
                cellH61.setCellValue(
                        (listAR.get(num).getComms() != null) ? listAR.get(num).getComms().doubleValue()
                                : new BigDecimal("0").doubleValue());
                cellH61.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(5);
                HSSFCell cellH71 = rowH1.createCell(6);
                cellH71.setCellValue((listAR.get(num).getAmountwendy() != null)
                        ? listAR.get(num).getAmountwendy().doubleValue()
                        : new BigDecimal("0").doubleValue());
                cellH71.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(6);
                HSSFCell cellH81 = rowH1.createCell(7);
                cellH81.setCellValue((listAR.get(num).getAmountinbound() != null)
                        ? listAR.get(num).getAmountinbound().doubleValue()
                        : new BigDecimal("0").doubleValue());
                cellH81.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(7);
                HSSFCell cellH91 = rowH1.createCell(8);
                cellH91.setCellValue(
                        (listAR.get(num).getDiff() != null) ? listAR.get(num).getDiff().doubleValue()
                                : new BigDecimal("0").doubleValue());
                cellH91.setCellStyle(styleDetailTableNumber);
                sheet.autoSizeColumn(8);
                num++;
            }
        }
        String sumPax = "SUM(B" + 10 + ":B" + (count - 1) + ")";
        String sumNetSales = "SUM(C" + 10 + ":C" + (count - 1) + ")";
        String sumTax = "SUM(D" + 10 + ":D" + (count - 1) + ")";
        String sumIns = "SUM(E" + 10 + ":E" + (count - 1) + ")";
        String sumComms = "SUM(F" + 10 + ":F" + (count - 1) + ")";
        String sumAmountWendy = "SUM(G" + 10 + ":G" + (count - 1) + ")";
        String sumAmountInbound = "SUM(H" + 10 + ":H" + (count - 1) + ")";
        String sumDiff = "SUM(I" + 10 + ":I" + (count - 1) + ")";

        HSSFRow row = sheet.createRow(count);
        HSSFCell cell6Sum = row.createCell(1);
        cell6Sum.setCellFormula(sumPax);
        cell6Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell7Sum = row.createCell(2);
        cell7Sum.setCellFormula(sumNetSales);
        cell7Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell8Sum = row.createCell(3);
        cell8Sum.setCellFormula(sumTax);
        cell8Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell9Sum = row.createCell(4);
        cell9Sum.setCellFormula(sumIns);
        cell9Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell10Sum = row.createCell(5);
        cell10Sum.setCellFormula(sumComms);
        cell10Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell11Sum = row.createCell(6);
        cell11Sum.setCellFormula(sumAmountWendy);
        cell11Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell12Sum = row.createCell(7);
        cell12Sum.setCellFormula(sumAmountInbound);
        cell12Sum.setCellStyle(styleDetailTableNumber);
        HSSFCell cell13Sum = row.createCell(8);
        cell13Sum.setCellFormula(sumDiff);
        cell13Sum.setCellStyle(styleDetailTableNumber);
        HSSFRow rowL = sheet.createRow(count + 1);
        rowL.createCell(0).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(1).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(2).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(3).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(4).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(5).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(6).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(7).setCellStyle(styleDetailTableBorderBottom);
        rowL.createCell(8).setCellStyle(styleDetailTableBorderBottom);
    }
}

From source file:com.smi.travel.controller.excel.checking.airticket.AirlineSummary.java

public void genTicketFareSummaryAirlineReport(HSSFWorkbook wb, List ticketSummaryAirline) {
    String sheetNamePax = "Pax"; // name of sheet
    String sheetNameDetail = "Detail";
    String sheetNameRounting = "Rounting";
    HSSFSheet sheetPax = wb.createSheet(sheetNamePax);
    HSSFSheet sheetDetail = wb.createSheet(sheetNameDetail);
    HSSFSheet sheetRounting = wb.createSheet(sheetNameRounting);

    UtilityExcelFunction excelFunction = new UtilityExcelFunction();

    TicketSummaryAirlineView dataheader = new TicketSummaryAirlineView();

    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);
    HSSFCellStyle styleC23 = wb.createCellStyle();
    styleC23.setAlignment(styleC22.ALIGN_CENTER);

    HSSFCellStyle styleC25 = wb.createCellStyle();
    styleC25.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC25.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC26 = wb.createCellStyle();
    styleC26.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC26.setDataFormat(currency.getFormat("#,##0"));
    styleC26.setAlignment(styleC22.ALIGN_CENTER);

    HSSFCellStyle styleC27 = wb.createCellStyle();
    styleC27.setAlignment(styleC27.ALIGN_RIGHT);
    styleC27.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC28 = wb.createCellStyle();
    styleC28.setAlignment(styleC28.ALIGN_CENTER);
    styleC28.setDataFormat(currency.getFormat("#,##0"));

    HSSFCellStyle styleC29 = wb.createCellStyle();
    styleC29.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    HSSFCellStyle styleC30 = wb.createCellStyle();
    styleC30.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC30.setAlignment(styleC22.ALIGN_CENTER);

    HSSFCellStyle stylebordertotal = wb.createCellStyle();
    stylebordertotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    HSSFCellStyle stylebordertotalleft = wb.createCellStyle();
    stylebordertotalleft.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    stylebordertotalleft.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    if (!ticketSummaryAirline.isEmpty()) {
        dataheader = (TicketSummaryAirlineView) ticketSummaryAirline.get(0);
        for (int x = 1; x < 4; x++) {
            if (x == 1) {
                // set Header Report (Row 1)
                HSSFCellStyle styleC1 = wb.createCellStyle();
                HSSFRow row1 = sheetPax.createRow(0);
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("List Summary Airline");
                styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
                cell1.setCellStyle(styleC1);
                sheetPax.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));

                // Row 2
                HSSFRow row2 = sheetPax.createRow(1);
                HSSFCell cell21 = row2.createCell(0);
                cell21.setCellValue("Invoice Date : ");
                cell21.setCellStyle(styleC21);
                HSSFCell cell22 = row2.createCell(1);
                cell22.setCellValue(dataheader.getHeaderdatefrom());
                cell22.setCellStyle(styleC22);
                //sheetPax.addMergedRegion(CellRangeAddress.valueOf("B2:C2"));
                HSSFCell cell23 = row2.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderdateto())) {
                    cell23.setCellValue(" to " + dataheader.getHeaderdateto());
                    cell23.setCellStyle(styleC22);
                }//from   www  .ja  v a2  s  .c  o  m
                HSSFCell cell24 = row2.createCell(3);
                cell24.setCellValue("Print on : ");
                cell24.setCellStyle(styleC21);
                HSSFCell cell25 = row2.createCell(4);
                cell25.setCellValue(dataheader.getHeaderprinton());
                cell25.setCellStyle(styleC22);

                // Row 3
                HSSFRow row3 = sheetPax.createRow(2);
                HSSFCell cell31 = row3.createCell(0);
                cell31.setCellValue("Issue Date : ");
                cell31.setCellStyle(styleC21);
                HSSFCell cell32 = row3.createCell(1);
                cell32.setCellValue(dataheader.getHeaderissuedatefrom());
                cell32.setCellStyle(styleC22);
                HSSFCell cell33 = row3.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderissuedateto())) {
                    cell33.setCellValue(" to " + dataheader.getHeaderissuedateto());
                    cell33.setCellStyle(styleC22);
                }
                HSSFCell cell34 = row3.createCell(3);
                cell34.setCellValue("Routing Detail : ");
                cell34.setCellStyle(styleC21);
                HSSFCell cell35 = row3.createCell(4);
                cell35.setCellValue(dataheader.getHeaderroutingdetail());
                cell35.setCellStyle(styleC22);

                // Row 4
                HSSFRow row4 = sheetPax.createRow(3);
                HSSFCell cell41 = row4.createCell(0);
                cell41.setCellValue("Type Routing : ");
                cell41.setCellStyle(styleC21);
                HSSFCell cell42 = row4.createCell(1);
                cell42.setCellValue(dataheader.getHeadertyperouting());
                cell42.setCellStyle(styleC22);
                HSSFCell cell43 = row4.createCell(3);
                cell43.setCellValue("Passenger : ");
                cell43.setCellStyle(styleC21);
                HSSFCell cell44 = row4.createCell(4);
                cell44.setCellValue(dataheader.getHeaderpassenger());
                cell44.setCellStyle(styleC22);

                // Row 5
                HSSFRow row5 = sheetPax.createRow(4);
                HSSFCell cell51 = row5.createCell(0);
                cell51.setCellValue("Airline Code : ");
                cell51.setCellStyle(styleC21);
                HSSFCell cell52 = row5.createCell(1);
                cell52.setCellValue(dataheader.getHeaderair());
                cell52.setCellStyle(styleC22);
                HSSFCell cell53 = row5.createCell(3);
                cell53.setCellValue("Sale Staff : ");
                cell53.setCellStyle(styleC21);
                HSSFCell cell54 = row5.createCell(4);
                cell54.setCellValue(dataheader.getHeadersalestaff());
                cell54.setCellStyle(styleC22);

                // Row 6
                HSSFRow row6 = sheetPax.createRow(5);
                HSSFCell cell61 = row6.createCell(0);
                cell61.setCellValue("Agent Name : ");
                cell61.setCellStyle(styleC21);
                HSSFCell cell62 = row6.createCell(1);
                cell62.setCellValue(dataheader.getHeaderagentname());
                cell62.setCellStyle(styleC22);
                HSSFCell cell63 = row6.createCell(3);
                cell63.setCellValue("Department : ");
                cell63.setCellStyle(styleC21);
                HSSFCell cell64 = row6.createCell(4);
                cell64.setCellValue(dataheader.getHeaderdepartment());
                cell64.setCellStyle(styleC22);

                // Row 7
                HSSFRow row7 = sheetPax.createRow(6);
                HSSFCell cell71 = row7.createCell(0);
                cell71.setCellValue("Term Pay : ");
                cell71.setCellStyle(styleC21);
                HSSFCell cell72 = row7.createCell(1);
                cell72.setCellValue(dataheader.getHeadertermpay());
                cell72.setCellStyle(styleC22);
                HSSFCell cell73 = row7.createCell(3);
                cell73.setCellValue("Print By : ");
                cell73.setCellStyle(styleC21);
                HSSFCell cell74 = row7.createCell(4);
                cell74.setCellValue(dataheader.getHeaderprintby());
                cell74.setCellStyle(styleC22);
            }
            if (x == 2) {
                // set Header Report (Row 1)
                HSSFCellStyle styleC1 = wb.createCellStyle();
                HSSFRow row1 = sheetDetail.createRow(0);
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("List Summary Airline");
                styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
                cell1.setCellStyle(styleC1);
                sheetDetail.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));

                // Row 2
                HSSFRow row2 = sheetDetail.createRow(1);
                HSSFCell cell21 = row2.createCell(0);
                cell21.setCellValue("Invoice Date : ");
                cell21.setCellStyle(styleC21);
                HSSFCell cell22 = row2.createCell(1);
                cell22.setCellValue(dataheader.getHeaderdatefrom());
                cell22.setCellStyle(styleC22);
                //sheetDetail.addMergedRegion(CellRangeAddress.valueOf("B2:C2"));
                HSSFCell cell23 = row2.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderdateto())) {
                    cell23.setCellValue(" to " + dataheader.getHeaderdateto());
                    cell23.setCellStyle(styleC22);
                }
                HSSFCell cell24 = row2.createCell(3);
                cell24.setCellValue("Print on : ");
                cell24.setCellStyle(styleC21);
                HSSFCell cell25 = row2.createCell(4);
                cell25.setCellValue(dataheader.getHeaderprinton());
                cell25.setCellStyle(styleC22);

                // Row 3
                HSSFRow row3 = sheetDetail.createRow(2);
                HSSFCell cell31 = row3.createCell(0);
                cell31.setCellValue("Issue Date : ");
                cell31.setCellStyle(styleC21);
                HSSFCell cell32 = row3.createCell(1);
                cell32.setCellValue(dataheader.getHeaderissuedatefrom());
                cell32.setCellStyle(styleC22);
                HSSFCell cell33 = row3.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderissuedateto())) {
                    cell33.setCellValue(" to " + dataheader.getHeaderissuedateto());
                    cell33.setCellStyle(styleC22);
                }
                HSSFCell cell34 = row3.createCell(3);
                cell34.setCellValue("Routing Detail : ");
                cell34.setCellStyle(styleC21);
                HSSFCell cell35 = row3.createCell(4);
                cell35.setCellValue(dataheader.getHeaderroutingdetail());
                cell35.setCellStyle(styleC22);

                // Row 4
                HSSFRow row4 = sheetDetail.createRow(3);
                HSSFCell cell41 = row4.createCell(0);
                cell41.setCellValue("Type Routing : ");
                cell41.setCellStyle(styleC21);
                HSSFCell cell42 = row4.createCell(1);
                cell42.setCellValue(dataheader.getHeadertyperouting());
                cell42.setCellStyle(styleC22);
                HSSFCell cell43 = row4.createCell(3);
                cell43.setCellValue("Passenger : ");
                cell43.setCellStyle(styleC21);
                HSSFCell cell44 = row4.createCell(4);
                cell44.setCellValue(dataheader.getHeaderpassenger());
                cell44.setCellStyle(styleC22);

                // Row 5
                HSSFRow row5 = sheetDetail.createRow(4);
                HSSFCell cell51 = row5.createCell(0);
                cell51.setCellValue("Airline Code : ");
                cell51.setCellStyle(styleC21);
                HSSFCell cell52 = row5.createCell(1);
                cell52.setCellValue(dataheader.getHeaderair());
                cell52.setCellStyle(styleC22);
                HSSFCell cell53 = row5.createCell(3);
                cell53.setCellValue("Sale Staff : ");
                cell53.setCellStyle(styleC21);
                HSSFCell cell54 = row5.createCell(4);
                cell54.setCellValue(dataheader.getHeadersalestaff());
                cell54.setCellStyle(styleC22);

                // Row 6
                HSSFRow row6 = sheetDetail.createRow(5);
                HSSFCell cell61 = row6.createCell(0);
                cell61.setCellValue("Agent Name : ");
                cell61.setCellStyle(styleC21);
                HSSFCell cell62 = row6.createCell(1);
                cell62.setCellValue(dataheader.getHeaderagentname());
                cell62.setCellStyle(styleC22);
                HSSFCell cell63 = row6.createCell(3);
                cell63.setCellValue("Department : ");
                cell63.setCellStyle(styleC21);
                HSSFCell cell64 = row6.createCell(4);
                cell64.setCellValue(dataheader.getHeaderdepartment());
                cell64.setCellStyle(styleC22);

                // Row 7
                HSSFRow row7 = sheetDetail.createRow(6);
                HSSFCell cell71 = row7.createCell(0);
                cell71.setCellValue("Term Pay : ");
                cell71.setCellStyle(styleC21);
                HSSFCell cell72 = row7.createCell(1);
                cell72.setCellValue(dataheader.getHeadertermpay());
                cell72.setCellStyle(styleC22);
                HSSFCell cell73 = row7.createCell(3);
                cell73.setCellValue("Print By : ");
                cell73.setCellStyle(styleC21);
                HSSFCell cell74 = row7.createCell(4);
                cell74.setCellValue(dataheader.getHeaderprintby());
                cell74.setCellStyle(styleC22);
            }
            if (x == 3) {
                // set Header Report (Row 1)
                HSSFCellStyle styleC1 = wb.createCellStyle();
                HSSFRow row1 = sheetRounting.createRow(0);
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("List Summary Airline");
                styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
                cell1.setCellStyle(styleC1);
                sheetRounting.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));

                // Row 2
                HSSFRow row2 = sheetRounting.createRow(1);
                HSSFCell cell21 = row2.createCell(0);
                cell21.setCellValue("Invoice Date : ");
                cell21.setCellStyle(styleC21);
                HSSFCell cell22 = row2.createCell(1);
                cell22.setCellValue(dataheader.getHeaderdatefrom());
                cell22.setCellStyle(styleC22);
                //sheetRounting.addMergedRegion(CellRangeAddress.valueOf("B2:C2"));
                HSSFCell cell23 = row2.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderdateto())) {
                    cell23.setCellValue(" to " + dataheader.getHeaderdateto());
                    cell23.setCellStyle(styleC22);
                }
                HSSFCell cell24 = row2.createCell(3);
                cell24.setCellValue("Print on : ");
                cell24.setCellStyle(styleC21);
                HSSFCell cell25 = row2.createCell(4);
                cell25.setCellValue(dataheader.getHeaderprinton());
                cell25.setCellStyle(styleC22);

                // Row 3
                HSSFRow row3 = sheetRounting.createRow(2);
                HSSFCell cell31 = row3.createCell(0);
                cell31.setCellValue("Issue Date : ");
                cell31.setCellStyle(styleC21);
                HSSFCell cell32 = row3.createCell(1);
                cell32.setCellValue(dataheader.getHeaderissuedatefrom());
                cell32.setCellStyle(styleC22);
                HSSFCell cell33 = row3.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderissuedateto())) {
                    cell33.setCellValue(" to " + dataheader.getHeaderissuedateto());
                    cell33.setCellStyle(styleC22);
                }
                HSSFCell cell34 = row3.createCell(3);
                cell34.setCellValue("Routing Detail : ");
                cell34.setCellStyle(styleC21);
                HSSFCell cell35 = row3.createCell(4);
                cell35.setCellValue(dataheader.getHeaderroutingdetail());
                cell35.setCellStyle(styleC22);

                // Row 4
                HSSFRow row4 = sheetRounting.createRow(3);
                HSSFCell cell41 = row4.createCell(0);
                cell41.setCellValue("Type Routing : ");
                cell41.setCellStyle(styleC21);
                HSSFCell cell42 = row4.createCell(1);
                cell42.setCellValue(dataheader.getHeadertyperouting());
                cell42.setCellStyle(styleC22);
                HSSFCell cell43 = row4.createCell(3);
                cell43.setCellValue("Passenger : ");
                cell43.setCellStyle(styleC21);
                HSSFCell cell44 = row4.createCell(4);
                cell44.setCellValue(dataheader.getHeaderpassenger());
                cell44.setCellStyle(styleC22);

                // Row 5
                HSSFRow row5 = sheetRounting.createRow(4);
                HSSFCell cell51 = row5.createCell(0);
                cell51.setCellValue("Airline Code : ");
                cell51.setCellStyle(styleC21);
                HSSFCell cell52 = row5.createCell(1);
                cell52.setCellValue(dataheader.getHeaderair());
                cell52.setCellStyle(styleC22);
                HSSFCell cell53 = row5.createCell(3);
                cell53.setCellValue("Sale Staff : ");
                cell53.setCellStyle(styleC21);
                HSSFCell cell54 = row5.createCell(4);
                cell54.setCellValue(dataheader.getHeadersalestaff());
                cell54.setCellStyle(styleC22);

                // Row 6
                HSSFRow row6 = sheetRounting.createRow(5);
                HSSFCell cell61 = row6.createCell(0);
                cell61.setCellValue("Agent Name : ");
                cell61.setCellStyle(styleC21);
                HSSFCell cell62 = row6.createCell(1);
                cell62.setCellValue(dataheader.getHeaderagentname());
                cell62.setCellStyle(styleC22);
                HSSFCell cell63 = row6.createCell(3);
                cell63.setCellValue("Department : ");
                cell63.setCellStyle(styleC21);
                HSSFCell cell64 = row6.createCell(4);
                cell64.setCellValue(dataheader.getHeaderdepartment());
                cell64.setCellStyle(styleC22);

                // Row 7
                HSSFRow row7 = sheetRounting.createRow(6);
                HSSFCell cell71 = row7.createCell(0);
                cell71.setCellValue("Term Pay : ");
                cell71.setCellStyle(styleC21);
                HSSFCell cell72 = row7.createCell(1);
                cell72.setCellValue(dataheader.getHeadertermpay());
                cell72.setCellStyle(styleC22);
                HSSFCell cell73 = row7.createCell(3);
                cell73.setCellValue("Print By : ");
                cell73.setCellStyle(styleC21);
                HSSFCell cell74 = row7.createCell(4);
                cell74.setCellValue(dataheader.getHeaderprintby());
                cell74.setCellStyle(styleC22);
            }
        }
        // Header Table
        HSSFCellStyle styleC3 = wb.createCellStyle();
        styleC3.setFont(excelFunction.getHeaderTable(wb.createFont()));
        styleC3.setAlignment(styleC3.ALIGN_CENTER);
        styleC3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderRight(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderTop(HSSFCellStyle.BORDER_THIN);

        int count = 9;
        int tempcount = 0;
        int tempcount2 = 0;
        int tempcount3 = 0;
        int rowdetail = 0;
        int rowrouting = 0;
        int x = 0;
        int y = 0;
        for (int i = 0; i < ticketSummaryAirline.size(); i++) {
            TicketSummaryAirlineView data = (TicketSummaryAirlineView) ticketSummaryAirline.get(i);

            if ("pax".equalsIgnoreCase(data.getPage())) {
                //pax
                HSSFRow row8 = sheetPax.createRow(8);
                HSSFCell cell81 = row8.createCell(0);
                cell81.setCellValue("Payment Type");
                cell81.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(0);
                HSSFCell cell82 = row8.createCell(1);
                cell82.setCellValue("Type Routing");
                cell82.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(1);
                HSSFCell cell83 = row8.createCell(2);
                cell83.setCellValue("Pax");
                //                    sheetPax.autoSizeColumn(2);
                cell83.setCellStyle(styleC3);
                HSSFCell cell84 = row8.createCell(3);
                cell84.setCellValue("Net Sales");
                cell84.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(3);
                HSSFCell cell85 = row8.createCell(4);
                cell85.setCellValue("Tax");
                cell85.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(4);
                HSSFCell cell86 = row8.createCell(5);
                cell86.setCellValue("Ins.");
                cell86.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(5);
                HSSFCell cell87 = row8.createCell(6);
                cell87.setCellValue("Comms");
                cell87.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(6);
                HSSFCell cell88 = row8.createCell(7);
                cell88.setCellValue("Amount Wendy");
                cell88.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(7);
                HSSFCell cell89 = row8.createCell(8);
                cell89.setCellValue("Amount Outbound");
                cell89.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(8);
                HSSFCell cell90 = row8.createCell(9);
                cell90.setCellValue("Amount Inbound");
                cell90.setCellStyle(styleC3);
                //                    sheetPax.autoSizeColumn(9);

                HSSFRow row = sheetPax.createRow(count + i);
                HSSFCell celldata0 = row.createCell(0);
                celldata0.setCellValue(String.valueOf(data.getPaymenttypeP()));
                celldata0.setCellStyle(styleC30);

                HSSFCell celldata1 = row.createCell(1);
                celldata1.setCellValue(String.valueOf(data.getTyperoutingP()));
                celldata1.setCellStyle(styleC30);

                HSSFCell celldata2 = row.createCell(2);
                celldata2.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxP())) ? 0
                        : (new BigDecimal(data.getPaxP())).doubleValue());
                celldata2.setCellStyle(styleC26);

                HSSFCell celldata3 = row.createCell(3);
                celldata3.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNetsalesP())) ? 0
                        : (new BigDecimal(data.getNetsalesP())).doubleValue());
                celldata3.setCellStyle(styleC25);

                HSSFCell celldata4 = row.createCell(4);
                celldata4.setCellValue("".equalsIgnoreCase(String.valueOf(data.getTaxP())) ? 0
                        : (new BigDecimal(data.getTaxP())).doubleValue());
                celldata4.setCellStyle(styleC25);

                HSSFCell celldata5 = row.createCell(5);
                celldata5.setCellValue("".equalsIgnoreCase(String.valueOf(data.getInsP())) ? 0
                        : (new BigDecimal(data.getInsP())).doubleValue());
                celldata5.setCellStyle(styleC25);

                HSSFCell celldata6 = row.createCell(6);
                celldata6.setCellValue("".equalsIgnoreCase(String.valueOf(data.getCommsP())) ? 0
                        : (new BigDecimal(data.getCommsP())).doubleValue());
                celldata6.setCellStyle(styleC25);

                HSSFCell celldata7 = row.createCell(7);
                celldata7.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountwendyP())) ? 0
                        : (new BigDecimal(data.getAmountwendyP())).doubleValue());
                celldata7.setCellStyle(styleC25);

                HSSFCell celldata8 = row.createCell(8);
                celldata8.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountoutboundP())) ? 0
                        : (new BigDecimal(data.getAmountoutboundP())).doubleValue());
                celldata8.setCellStyle(styleC25);

                HSSFCell celldata9 = row.createCell(9);
                celldata9.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountinboundP())) ? 0
                        : (new BigDecimal(data.getAmountinboundP())).doubleValue());
                celldata9.setCellStyle(styleC25);

                tempcount = count + i + 1;
            }

            //detail
            if ("detail".equalsIgnoreCase(data.getPage())) {
                //Total Pax
                HSSFRow rowtotal = sheetPax.createRow(tempcount);
                String totalPax = "SUM(C" + 10 + ":C" + (tempcount) + ")";
                String totalNet = "SUM(D" + 10 + ":D" + (tempcount) + ")";
                String totalTax = "SUM(E" + 10 + ":E" + (tempcount) + ")";
                String totalIns = "SUM(F" + 10 + ":F" + (tempcount) + ")";
                String totalComms = "SUM(G" + 10 + ":G" + (tempcount) + ")";
                String totalAmountWen = "SUM(H" + 10 + ":H" + (tempcount) + ")";
                String totalAmountOut = "SUM(I" + 10 + ":I" + (tempcount) + ")";
                String totalAmountIn = "SUM(J" + 10 + ":J" + (tempcount) + ")";

                HSSFCellStyle styleTotal = wb.createCellStyle();
                styleTotal.setFont(excelFunction.getHeaderTable(wb.createFont()));
                styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                styleTotal.setAlignment(styleC22.ALIGN_RIGHT);

                HSSFCell cellTotal0 = rowtotal.createCell(0);
                cellTotal0.setCellStyle(styleC29);
                HSSFCell cellTotal00 = rowtotal.createCell(1);
                cellTotal00.setCellValue("Total");
                cellTotal00.setCellStyle(styleTotal);
                HSSFCell cellTotal01 = rowtotal.createCell(2);
                cellTotal01.setCellFormula(totalPax);
                cellTotal01.setCellStyle(styleC26);
                HSSFCell cellTotal02 = rowtotal.createCell(3);
                cellTotal02.setCellFormula(totalNet);
                cellTotal02.setCellStyle(styleC25);
                HSSFCell cellTotal03 = rowtotal.createCell(4);
                cellTotal03.setCellFormula(totalTax);
                cellTotal03.setCellStyle(styleC25);
                HSSFCell cellTotal04 = rowtotal.createCell(5);
                cellTotal04.setCellFormula(totalIns);
                cellTotal04.setCellStyle(styleC25);
                HSSFCell cellTotal05 = rowtotal.createCell(6);
                cellTotal05.setCellFormula(totalComms);
                cellTotal05.setCellStyle(styleC25);
                HSSFCell cellTotal06 = rowtotal.createCell(7);
                cellTotal06.setCellFormula(totalAmountWen);
                cellTotal06.setCellStyle(styleC25);
                HSSFCell cellTotal07 = rowtotal.createCell(8);
                cellTotal07.setCellFormula(totalAmountOut);
                cellTotal07.setCellStyle(styleC25);
                HSSFCell cellTotal08 = rowtotal.createCell(9);
                cellTotal08.setCellFormula(totalAmountIn);
                cellTotal08.setCellStyle(styleC25);

                //                    if(tempcount != 0){
                //                        rowdetail = tempcount+3;
                //                    }

                HSSFRow row8 = sheetDetail.createRow(8);
                HSSFCell cell81 = row8.createCell(0);
                cell81.setCellValue("Invoice No");
                cell81.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(0);
                HSSFCell cell82 = row8.createCell(1);
                cell82.setCellValue("Invoice Date");
                cell82.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(1);
                HSSFCell cell83 = row8.createCell(2);
                cell83.setCellValue("Department");
                //                    sheetDetail.autoSizeColumn(2);
                cell83.setCellStyle(styleC3);
                HSSFCell cell84 = row8.createCell(3);
                cell84.setCellValue("Staff");
                cell84.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(3);
                HSSFCell cell85 = row8.createCell(4);
                cell85.setCellValue("Term Pay");
                cell85.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(4);
                HSSFCell cell86 = row8.createCell(5);
                cell86.setCellValue("Passenger");
                cell86.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(5);
                HSSFCell cell87 = row8.createCell(6);
                cell87.setCellValue("Type Payment");
                cell87.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(6);
                HSSFCell cell88 = row8.createCell(7);
                cell88.setCellValue("Type Routing");
                cell88.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(7);
                HSSFCell cell89 = row8.createCell(8);
                cell89.setCellValue("Routing");
                cell89.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(8);
                HSSFCell cell90 = row8.createCell(9);
                cell90.setCellValue("Pax");
                cell90.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(9);

                HSSFCell cell91 = row8.createCell(10);
                cell91.setCellValue("Air");
                cell91.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(10);
                HSSFCell cell92 = row8.createCell(11);
                cell92.setCellValue("Ticket No");
                cell92.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(11);
                HSSFCell cell93 = row8.createCell(12);
                cell93.setCellValue("Ref No.");
                cell93.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(12);
                HSSFCell cell94 = row8.createCell(13);
                cell94.setCellValue("Issue Date");
                cell94.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(13);
                HSSFCell cell95 = row8.createCell(14);
                cell95.setCellValue("Net Sales");
                cell95.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(14);
                HSSFCell cell96 = row8.createCell(15);
                cell96.setCellValue("Tax");
                cell96.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(15);
                HSSFCell cell97 = row8.createCell(16);
                cell97.setCellValue("Ins.");
                cell97.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(16);
                HSSFCell cell98 = row8.createCell(17);
                cell98.setCellValue("Comms");
                cell98.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(17);
                HSSFCell cell99 = row8.createCell(18);
                cell99.setCellValue("Amount Wendy");
                cell99.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(18);
                HSSFCell cell910 = row8.createCell(19);
                cell910.setCellValue("Amount Outbound");
                cell910.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(19);
                HSSFCell cell911 = row8.createCell(20);
                cell911.setCellValue("Amount Inbound");
                cell911.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(20);
                HSSFCell cell912 = row8.createCell(21);
                cell912.setCellValue("Amt No Invoice");
                cell912.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(21);
                HSSFCell cell913 = row8.createCell(22);
                cell913.setCellValue("Amt Business Trip");
                cell913.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(22);
                HSSFCell cell914 = row8.createCell(23);
                cell914.setCellValue("Amt Annual Leave");
                cell914.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(23);
                HSSFCell cell915 = row8.createCell(24);
                cell915.setCellValue("Amt Refund");
                cell915.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(24);
                HSSFCell cell916 = row8.createCell(25);
                cell916.setCellValue("Remarks");
                cell916.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(25);
                HSSFCell cell917 = row8.createCell(26);
                cell917.setCellValue("Diff");
                cell917.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(26);

                HSSFRow row = sheetDetail.createRow(count + x);
                HSSFCell celldata0 = row.createCell(0);

                celldata0.setCellValue(String.valueOf(data.getInvnoD()));
                celldata0.setCellStyle(styleC29);

                HSSFCell celldata1 = row.createCell(1);
                celldata1.setCellValue(String.valueOf(data.getInvdateD()));
                celldata1.setCellStyle(styleC30);

                HSSFCell celldata2 = row.createCell(2);
                celldata2.setCellValue(String.valueOf(data.getDepartmentD()));
                celldata2.setCellStyle(styleC29);

                HSSFCell celldata3 = row.createCell(3);
                celldata3.setCellValue(String.valueOf(data.getStaffD()));
                celldata3.setCellStyle(styleC29);

                HSSFCell celldata4 = row.createCell(4);
                celldata4.setCellValue(String.valueOf(data.getTermpayD()));
                celldata4.setCellStyle(styleC29);

                HSSFCell celldata5 = row.createCell(5);
                celldata5.setCellValue(String.valueOf(data.getPassengerD()));
                celldata5.setCellStyle(styleC29);

                HSSFCell celldata6 = row.createCell(6);
                celldata6.setCellValue(String.valueOf(data.getTypepaymentD()));
                celldata6.setCellStyle(styleC29);

                HSSFCell celldata7 = row.createCell(7);
                celldata7.setCellValue(String.valueOf(data.getTyperoutingD()));
                celldata7.setCellStyle(styleC29);

                HSSFCell celldata8 = row.createCell(8);
                celldata8.setCellValue(String.valueOf(data.getRoutingD()));
                celldata8.setCellStyle(styleC29);

                HSSFCell celldata9 = row.createCell(9);
                celldata9.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxD())) ? 0
                        : (new BigDecimal(data.getPaxD())).doubleValue());
                celldata9.setCellStyle(styleC26);

                HSSFCell celldata10 = row.createCell(10);
                celldata10.setCellValue(String.valueOf(data.getAirD()));
                celldata10.setCellStyle(styleC30);

                HSSFCell celldata11 = row.createCell(11);
                celldata11.setCellValue(String.valueOf(data.getTicketnoD()));
                celldata11.setCellStyle(styleC29);

                HSSFCell celldata12 = row.createCell(12);
                celldata12.setCellValue(String.valueOf(data.getRefnoD()));
                celldata12.setCellStyle(styleC29);

                HSSFCell celldata13 = row.createCell(13);
                celldata13.setCellValue(String.valueOf(data.getIssuedateD()));
                celldata13.setCellStyle(styleC29);

                HSSFCell celldata14 = row.createCell(14);
                celldata14.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNetsalesD())) ? 0
                        : (new BigDecimal(data.getNetsalesD())).doubleValue());
                celldata14.setCellStyle(styleC25);

                HSSFCell celldata15 = row.createCell(15);
                celldata15.setCellValue("".equalsIgnoreCase(String.valueOf(data.getTaxD())) ? 0
                        : (new BigDecimal(data.getTaxD())).doubleValue());
                celldata15.setCellStyle(styleC25);

                HSSFCell celldata16 = row.createCell(16);
                celldata16.setCellValue("".equalsIgnoreCase(String.valueOf(data.getInsD())) ? 0
                        : (new BigDecimal(data.getInsD())).doubleValue());
                celldata16.setCellStyle(styleC25);

                HSSFCell celldata17 = row.createCell(17);
                celldata17.setCellValue("".equalsIgnoreCase(String.valueOf(data.getCommsD())) ? 0
                        : (new BigDecimal(data.getCommsD())).doubleValue());
                celldata17.setCellStyle(styleC25);

                HSSFCell celldata18 = row.createCell(18);
                celldata18.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountwendyD())) ? 0
                        : (new BigDecimal(data.getAmountwendyD())).doubleValue());
                celldata18.setCellStyle(styleC25);

                HSSFCell celldata19 = row.createCell(19);
                celldata19.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountoutboundD())) ? 0
                        : (new BigDecimal(data.getAmountoutboundD())).doubleValue());
                celldata19.setCellStyle(styleC25);

                HSSFCell celldata20 = row.createCell(20);
                celldata20.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountinboundD())) ? 0
                        : (new BigDecimal(data.getAmountinboundD())).doubleValue());
                celldata20.setCellStyle(styleC25);

                HSSFCell celldata21 = row.createCell(21);
                celldata21.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmtnoinvoiceD())) ? 0
                        : (new BigDecimal(data.getAmtnoinvoiceD())).doubleValue());
                celldata21.setCellStyle(styleC25);

                HSSFCell celldata22 = row.createCell(22);
                celldata22.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmtbusinesstripD())) ? 0
                        : (new BigDecimal(data.getAmtbusinesstripD())).doubleValue());
                celldata22.setCellStyle(styleC25);

                HSSFCell celldata23 = row.createCell(23);
                celldata23.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmtannualleaveD())) ? 0
                        : (new BigDecimal(data.getAmtannualleaveD())).doubleValue());
                celldata23.setCellStyle(styleC25);

                HSSFCell celldata24 = row.createCell(24);
                celldata24.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmtrefundD())) ? 0
                        : (new BigDecimal(data.getAmtrefundD())).doubleValue());
                celldata24.setCellStyle(styleC25);

                HSSFCell celldata25 = row.createCell(25);
                celldata25.setCellValue(String.valueOf(data.getRemarksD()));
                celldata25.setCellStyle(styleC29);

                HSSFCell celldata26 = row.createCell(26);
                celldata26.setCellValue("".equalsIgnoreCase(String.valueOf(data.getDiffD())) ? 0
                        : (new BigDecimal(data.getDiffD())).doubleValue());
                celldata26.setCellStyle(styleC25);
                x++;
            }

            if ("routing".equalsIgnoreCase(data.getPage())) {
                tempcount2 = count + x;
                HSSFRow rowtotal = sheetDetail.createRow(tempcount2);
                String totalPax = "SUM(J" + 10 + ":J" + (tempcount2) + ")";
                String totalNet = "SUM(O" + 10 + ":O" + (tempcount2) + ")";
                String totalTax = "SUM(P" + 10 + ":P" + (tempcount2) + ")";
                String totalIns = "SUM(Q" + 10 + ":Q" + (tempcount2) + ")";
                String totalComms = "SUM(R" + 10 + ":R" + (tempcount2) + ")";
                String totalAmountWen = "SUM(S" + 10 + ":S" + (tempcount2) + ")";
                String totalAmountOut = "SUM(T" + 10 + ":T" + (tempcount2) + ")";
                String totalAmountIn = "SUM(U" + 10 + ":U" + (tempcount2) + ")";
                String totalAmountNoInv = "SUM(V" + 10 + ":V" + (tempcount2) + ")";
                String totalAmountBuss = "SUM(W" + 10 + ":W" + (tempcount2) + ")";
                String totalAmountAnn = "SUM(X" + 10 + ":X" + (tempcount2) + ")";
                String totalAmountRef = "SUM(Y" + 10 + ":Y" + (tempcount2) + ")";
                String totalAmountDiff = "SUM(AA" + 10 + ":AA" + (tempcount2) + ")";

                HSSFCellStyle styleTotal = wb.createCellStyle();
                styleTotal.setFont(excelFunction.getHeaderTable(wb.createFont()));
                styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                styleTotal.setAlignment(styleC22.ALIGN_RIGHT);

                HSSFCell cellTotal000 = rowtotal.createCell(0);
                cellTotal000.setCellStyle(stylebordertotalleft);

                HSSFCell cellTotal001 = rowtotal.createCell(1);
                cellTotal001.setCellStyle(stylebordertotal);
                HSSFCell cellTotal002 = rowtotal.createCell(2);
                cellTotal002.setCellStyle(stylebordertotal);
                HSSFCell cellTotal003 = rowtotal.createCell(3);
                cellTotal003.setCellStyle(stylebordertotal);
                HSSFCell cellTotal004 = rowtotal.createCell(4);
                cellTotal004.setCellStyle(stylebordertotal);
                HSSFCell cellTotal005 = rowtotal.createCell(5);
                cellTotal005.setCellStyle(stylebordertotal);
                HSSFCell cellTotal006 = rowtotal.createCell(6);
                cellTotal006.setCellStyle(stylebordertotal);
                HSSFCell cellTotal007 = rowtotal.createCell(7);
                cellTotal007.setCellStyle(stylebordertotal);
                HSSFCell cellTotal008 = rowtotal.createCell(10);
                cellTotal008.setCellStyle(stylebordertotal);
                HSSFCell cellTotal009 = rowtotal.createCell(11);
                cellTotal009.setCellStyle(stylebordertotal);
                HSSFCell cellTotal010 = rowtotal.createCell(12);
                cellTotal010.setCellStyle(stylebordertotal);
                HSSFCell cellTotal011 = rowtotal.createCell(13);
                cellTotal011.setCellStyle(stylebordertotal);
                HSSFCell cellTotal012 = rowtotal.createCell(25);
                cellTotal012.setCellStyle(stylebordertotal);

                HSSFCell cellTotal00 = rowtotal.createCell(8);
                cellTotal00.setCellValue("Total");
                cellTotal00.setCellStyle(styleTotal);
                HSSFCell cellTotal01 = rowtotal.createCell(9);
                cellTotal01.setCellFormula(totalPax);
                cellTotal01.setCellStyle(styleC26);
                HSSFCell cellTotal02 = rowtotal.createCell(14);
                cellTotal02.setCellFormula(totalNet);
                cellTotal02.setCellStyle(styleC25);
                HSSFCell cellTotal03 = rowtotal.createCell(15);
                cellTotal03.setCellFormula(totalTax);
                cellTotal03.setCellStyle(styleC25);
                HSSFCell cellTotal04 = rowtotal.createCell(16);
                cellTotal04.setCellFormula(totalIns);
                cellTotal04.setCellStyle(styleC25);
                HSSFCell cellTotal05 = rowtotal.createCell(17);
                cellTotal05.setCellFormula(totalComms);
                cellTotal05.setCellStyle(styleC25);
                HSSFCell cellTotal06 = rowtotal.createCell(18);
                cellTotal06.setCellFormula(totalAmountWen);
                cellTotal06.setCellStyle(styleC25);
                HSSFCell cellTotal07 = rowtotal.createCell(19);
                cellTotal07.setCellFormula(totalAmountOut);
                cellTotal07.setCellStyle(styleC25);
                HSSFCell cellTotal08 = rowtotal.createCell(20);
                cellTotal08.setCellFormula(totalAmountIn);
                cellTotal08.setCellStyle(styleC25);
                HSSFCell cellTotal09 = rowtotal.createCell(21);
                cellTotal09.setCellFormula(totalAmountNoInv);
                cellTotal09.setCellStyle(styleC25);
                HSSFCell cellTotal10 = rowtotal.createCell(22);
                cellTotal10.setCellFormula(totalAmountBuss);
                cellTotal10.setCellStyle(styleC25);
                HSSFCell cellTotal11 = rowtotal.createCell(23);
                cellTotal11.setCellFormula(totalAmountAnn);
                cellTotal11.setCellStyle(styleC25);
                HSSFCell cellTotal12 = rowtotal.createCell(24);
                cellTotal12.setCellFormula(totalAmountRef);
                cellTotal12.setCellStyle(styleC25);
                HSSFCell cellTotal13 = rowtotal.createCell(26);
                cellTotal13.setCellFormula(totalAmountDiff);
                cellTotal13.setCellStyle(styleC25);
                //                    if(tempcount2 != 0){
                //                        rowrouting = tempcount2+3;
                //                    }

                HSSFRow row8 = sheetRounting.createRow(8);
                HSSFCell cell81 = row8.createCell(0);
                cell81.setCellValue("Routing");
                cell81.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(0);
                HSSFCell cell82 = row8.createCell(1);
                cell82.setCellValue("Pax");
                cell82.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(1);
                HSSFCell cell83 = row8.createCell(2);
                cell83.setCellValue("Net Sales");
                //                    sheetRounting.autoSizeColumn(2);
                cell83.setCellStyle(styleC3);
                HSSFCell cell84 = row8.createCell(3);
                cell84.setCellValue("Tax");
                cell84.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(3);
                HSSFCell cell85 = row8.createCell(4);
                cell85.setCellValue("Ins.");
                cell85.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(4);
                HSSFCell cell86 = row8.createCell(5);
                cell86.setCellValue("Comms");
                cell86.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(5);
                HSSFCell cell87 = row8.createCell(6);
                cell87.setCellValue("Amount Wendy");
                cell87.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(6);
                HSSFCell cell88 = row8.createCell(7);
                cell88.setCellValue("Amount Outbound");
                cell88.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(7);
                HSSFCell cell89 = row8.createCell(8);
                cell89.setCellValue("Amount Inbound");
                cell89.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(8);
                HSSFCell cell90 = row8.createCell(9);
                cell90.setCellValue("Diff");
                cell90.setCellStyle(styleC3);
                //                    sheetRounting.autoSizeColumn(9);

                HSSFRow row = sheetRounting.createRow(count + y);

                HSSFCell celldata0 = row.createCell(0);
                celldata0.setCellValue(String.valueOf(data.getRoutingR()));
                celldata0.setCellStyle(styleC29);

                HSSFCell celldata1 = row.createCell(1);
                celldata1.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPaxR())) ? 0
                        : (new BigDecimal(data.getPaxR())).doubleValue());
                celldata1.setCellStyle(styleC26);

                HSSFCell celldata2 = row.createCell(2);
                celldata2.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNetsalesR())) ? 0
                        : (new BigDecimal(data.getNetsalesR())).doubleValue());
                celldata2.setCellStyle(styleC25);

                HSSFCell celldata3 = row.createCell(3);
                celldata3.setCellValue("".equalsIgnoreCase(String.valueOf(data.getTaxR())) ? 0
                        : (new BigDecimal(data.getTaxR())).doubleValue());
                celldata3.setCellStyle(styleC25);

                HSSFCell celldata4 = row.createCell(4);
                celldata4.setCellValue("".equalsIgnoreCase(String.valueOf(data.getInsR())) ? 0
                        : (new BigDecimal(data.getInsR())).doubleValue());
                celldata4.setCellStyle(styleC25);

                HSSFCell celldata5 = row.createCell(5);
                celldata5.setCellValue("".equalsIgnoreCase(String.valueOf(data.getCommsR())) ? 0
                        : (new BigDecimal(data.getCommsR())).doubleValue());
                celldata5.setCellStyle(styleC25);

                HSSFCell celldata6 = row.createCell(6);
                celldata6.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountwendyR())) ? 0
                        : (new BigDecimal(data.getAmountwendyR())).doubleValue());
                celldata6.setCellStyle(styleC25);

                HSSFCell celldata7 = row.createCell(7);
                celldata7.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountoutboundR())) ? 0
                        : (new BigDecimal(data.getAmountoutboundR())).doubleValue());
                celldata7.setCellStyle(styleC25);

                HSSFCell celldata8 = row.createCell(8);
                celldata8.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountinboundR())) ? 0
                        : (new BigDecimal(data.getAmountinboundR())).doubleValue());
                celldata8.setCellStyle(styleC25);

                HSSFCell celldata9 = row.createCell(9);
                celldata9.setCellValue("".equalsIgnoreCase(String.valueOf(data.getDiffR())) ? 0
                        : (new BigDecimal(data.getDiffR())).doubleValue());
                celldata9.setCellStyle(styleC25);
                y++;
            }

            if (i == (ticketSummaryAirline.size() - 1)) {
                tempcount3 = count + y;
                HSSFRow rowtotal = sheetRounting.createRow(tempcount3);
                String totalPax = "SUM(B" + 10 + ":B" + (tempcount3) + ")";
                String totalNet = "SUM(C" + 10 + ":C" + (tempcount3) + ")";
                String totalTax = "SUM(D" + 10 + ":D" + (tempcount3) + ")";
                String totalIns = "SUM(E" + 10 + ":E" + (tempcount3) + ")";
                String totalComms = "SUM(F" + 10 + ":F" + (tempcount3) + ")";
                String totalAmountWen = "SUM(G" + 10 + ":G" + (tempcount3) + ")";
                String totalAmountOut = "SUM(H" + 10 + ":H" + (tempcount3) + ")";
                String totalAmountIn = "SUM(I" + 10 + ":I" + (tempcount3) + ")";
                String totalAmountDiff = "SUM(J" + 10 + ":J" + (tempcount3) + ")";

                HSSFCellStyle styleTotal = wb.createCellStyle();
                styleTotal.setFont(excelFunction.getHeaderTable(wb.createFont()));
                styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                styleTotal.setAlignment(styleC22.ALIGN_RIGHT);

                HSSFCell cellTotal00 = rowtotal.createCell(0);
                cellTotal00.setCellValue("Total");
                cellTotal00.setCellStyle(styleTotal);
                HSSFCell cellTotal01 = rowtotal.createCell(1);
                cellTotal01.setCellFormula(totalPax);
                cellTotal01.setCellStyle(styleC26);
                HSSFCell cellTotal02 = rowtotal.createCell(2);
                cellTotal02.setCellFormula(totalNet);
                cellTotal02.setCellStyle(styleC25);
                HSSFCell cellTotal03 = rowtotal.createCell(3);
                cellTotal03.setCellFormula(totalTax);
                cellTotal03.setCellStyle(styleC25);
                HSSFCell cellTotal04 = rowtotal.createCell(4);
                cellTotal04.setCellFormula(totalIns);
                cellTotal04.setCellStyle(styleC25);
                HSSFCell cellTotal05 = rowtotal.createCell(5);
                cellTotal05.setCellFormula(totalComms);
                cellTotal05.setCellStyle(styleC25);
                HSSFCell cellTotal06 = rowtotal.createCell(6);
                cellTotal06.setCellFormula(totalAmountWen);
                cellTotal06.setCellStyle(styleC25);
                HSSFCell cellTotal07 = rowtotal.createCell(7);
                cellTotal07.setCellFormula(totalAmountOut);
                cellTotal07.setCellStyle(styleC25);
                HSSFCell cellTotal08 = rowtotal.createCell(8);
                cellTotal08.setCellFormula(totalAmountIn);
                cellTotal08.setCellStyle(styleC25);
                HSSFCell cellTotal09 = rowtotal.createCell(9);
                cellTotal09.setCellFormula(totalAmountDiff);
                cellTotal09.setCellStyle(styleC25);
            }
        }

    }
    for (int i = 0; i < 30; i++) {
        sheetPax.autoSizeColumn(i);
        sheetDetail.autoSizeColumn(i);
        sheetRounting.autoSizeColumn(i);
    }

    sheetDetail.setColumnWidth(15, 256 * 12);
    sheetDetail.setColumnWidth(16, 256 * 12);

    sheetPax.setColumnWidth(5, 256 * 12);

    sheetRounting.setColumnWidth(5, 256 * 12);
    sheetRounting.setColumnWidth(9, 256 * 12);
}

From source file:com.smi.travel.controller.excel.checking.airticket.AirlineSummary.java

public void genSummaryAirlinePaxReport(HSSFWorkbook wb, List summaryAirlinePax) {
    String sheetNameInv = "Invoice"; // name of sheet
    String sheetNameDetail = "Detail";
    HSSFSheet sheetInv = wb.createSheet(sheetNameInv);
    HSSFSheet sheetDetail = wb.createSheet(sheetNameDetail);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();

    SummaryAirlinePaxView dataheader = new SummaryAirlinePaxView();

    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);
    HSSFCellStyle styleC23 = wb.createCellStyle();
    styleC23.setAlignment(styleC22.ALIGN_CENTER);

    HSSFCellStyle styleC25 = wb.createCellStyle();
    styleC25.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC25.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC26 = wb.createCellStyle();
    styleC26.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC26.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC26.setDataFormat(currency.getFormat("#,##0"));
    styleC26.setAlignment(styleC22.ALIGN_CENTER);

    HSSFCellStyle styleC27 = wb.createCellStyle();
    styleC27.setAlignment(styleC27.ALIGN_RIGHT);
    styleC27.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleC28 = wb.createCellStyle();
    styleC28.setAlignment(styleC28.ALIGN_CENTER);
    styleC28.setDataFormat(currency.getFormat("#,##0"));

    HSSFCellStyle styleC29 = wb.createCellStyle();
    styleC29.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC29.setBorderBottom(HSSFCellStyle.BORDER_THIN);

    HSSFCellStyle styleC30 = wb.createCellStyle();
    styleC30.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC30.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC30.setAlignment(styleC22.ALIGN_CENTER);

    if (!summaryAirlinePax.isEmpty()) {
        dataheader = (SummaryAirlinePaxView) summaryAirlinePax.get(0);
        for (int x = 1; x < 4; x++) {
            if (x == 1) {
                // set Header Report (Row 1)
                HSSFCellStyle styleC1 = wb.createCellStyle();
                HSSFRow row1 = sheetInv.createRow(0);
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("List Summary Airline (Pax)");
                styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
                cell1.setCellStyle(styleC1);
                sheetInv.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));

                // Row 2
                HSSFRow row2 = sheetInv.createRow(1);
                HSSFCell cell21 = row2.createCell(0);
                cell21.setCellValue("Invoice Date : ");
                cell21.setCellStyle(styleC21);
                HSSFCell cell22 = row2.createCell(1);
                cell22.setCellValue(dataheader.getHeaderinvdatefrom());
                cell22.setCellStyle(styleC22);
                HSSFCell cell23 = row2.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderinvdateto())) {
                    cell23.setCellValue(" to " + dataheader.getHeaderinvdateto());
                    cell23.setCellStyle(styleC22);
                }/*from   w  w w.  j av  a2  s.c  om*/
                HSSFCell cell24 = row2.createCell(3);
                cell24.setCellValue("Print By : ");
                cell24.setCellStyle(styleC21);
                HSSFCell cell25 = row2.createCell(4);
                cell25.setCellValue(dataheader.getHeaderprintby());
                cell25.setCellStyle(styleC22);

                // Row 3
                HSSFRow row3 = sheetInv.createRow(2);
                HSSFCell cell31 = row3.createCell(0);
                cell31.setCellValue("Issue Date : ");
                cell31.setCellStyle(styleC21);
                HSSFCell cell32 = row3.createCell(1);
                cell32.setCellValue(dataheader.getHeaderissuedatefrom());
                cell32.setCellStyle(styleC22);
                HSSFCell cell33 = row3.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderissuedateto())) {
                    cell33.setCellValue(" to " + dataheader.getHeaderissuedateto());
                    cell33.setCellStyle(styleC22);
                }
                HSSFCell cell34 = row3.createCell(3);
                cell34.setCellValue("Print on : ");
                cell34.setCellStyle(styleC21);
                HSSFCell cell35 = row3.createCell(4);
                cell35.setCellValue(dataheader.getHeaderprinton());
                cell35.setCellStyle(styleC22);

                // Row 4
                HSSFRow row4 = sheetInv.createRow(3);
                HSSFCell cell41 = row4.createCell(0);
                cell41.setCellValue("Type Routing : ");
                cell41.setCellStyle(styleC21);
                HSSFCell cell42 = row4.createCell(1);
                cell42.setCellValue(dataheader.getHeadertyperouting());
                cell42.setCellStyle(styleC22);
                HSSFCell cell43 = row4.createCell(3);
                cell43.setCellValue("Routing Detail : ");
                cell43.setCellStyle(styleC21);
                HSSFCell cell44 = row4.createCell(4);
                cell44.setCellValue(dataheader.getHeaderroutingdetail());
                cell44.setCellStyle(styleC22);

                // Row 5
                HSSFRow row5 = sheetInv.createRow(4);
                HSSFCell cell51 = row5.createCell(0);
                cell51.setCellValue("Airline Code : ");
                cell51.setCellStyle(styleC21);
                HSSFCell cell52 = row5.createCell(1);
                cell52.setCellValue(dataheader.getHeaderair());
                cell52.setCellStyle(styleC22);
                HSSFCell cell53 = row5.createCell(3);
                cell53.setCellValue("Passenger : ");
                cell53.setCellStyle(styleC21);
                HSSFCell cell54 = row5.createCell(4);
                cell54.setCellValue(dataheader.getHeaderpassenger());
                cell54.setCellStyle(styleC22);

                // Row 6
                HSSFRow row6 = sheetInv.createRow(5);
                HSSFCell cell61 = row6.createCell(0);
                cell61.setCellValue("Agent Name : ");
                cell61.setCellStyle(styleC21);
                HSSFCell cell62 = row6.createCell(1);
                cell62.setCellValue(dataheader.getHeaderagentname());
                cell62.setCellStyle(styleC22);
                HSSFCell cell63 = row6.createCell(3);
                cell63.setCellValue("Department : ");
                cell63.setCellStyle(styleC21);
                HSSFCell cell64 = row6.createCell(4);
                cell64.setCellValue(dataheader.getHeaderdepartment());
                cell64.setCellStyle(styleC22);

                // Row 7
                HSSFRow row7 = sheetInv.createRow(6);
                HSSFCell cell71 = row7.createCell(0);
                cell71.setCellValue("Term Pay : ");
                cell71.setCellStyle(styleC21);
                HSSFCell cell72 = row7.createCell(1);
                cell72.setCellValue(dataheader.getHeadertermpay());
                cell72.setCellStyle(styleC22);
                HSSFCell cell73 = row7.createCell(3);
                cell73.setCellValue("Sale Staff : ");
                cell73.setCellStyle(styleC21);
                HSSFCell cell74 = row7.createCell(4);
                cell74.setCellValue(dataheader.getHeadersalestaff());
                cell74.setCellStyle(styleC22);
            }
            if (x == 2) {
                // set Header Report (Row 1)
                HSSFCellStyle styleC1 = wb.createCellStyle();
                HSSFRow row1 = sheetDetail.createRow(0);
                HSSFCell cell1 = row1.createCell(0);
                cell1.setCellValue("List Summary Airline (Pax)");
                styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
                cell1.setCellStyle(styleC1);
                sheetDetail.addMergedRegion(CellRangeAddress.valueOf("A1:E1"));

                // Row 2
                HSSFRow row2 = sheetDetail.createRow(1);
                HSSFCell cell21 = row2.createCell(0);
                cell21.setCellValue("Invoice Date : ");
                cell21.setCellStyle(styleC21);
                HSSFCell cell22 = row2.createCell(1);
                cell22.setCellValue(dataheader.getHeaderinvdatefrom());
                cell22.setCellStyle(styleC22);
                HSSFCell cell23 = row2.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderinvdateto())) {
                    cell23.setCellValue(" to " + dataheader.getHeaderinvdateto());
                    cell23.setCellStyle(styleC22);
                }
                HSSFCell cell24 = row2.createCell(3);
                cell24.setCellValue("Print By : ");
                cell24.setCellStyle(styleC21);
                HSSFCell cell25 = row2.createCell(4);
                cell25.setCellValue(dataheader.getHeaderprintby());
                cell25.setCellStyle(styleC22);

                // Row 3
                HSSFRow row3 = sheetDetail.createRow(2);
                HSSFCell cell31 = row3.createCell(0);
                cell31.setCellValue("Issue Date : ");
                cell31.setCellStyle(styleC21);
                HSSFCell cell32 = row3.createCell(1);
                cell32.setCellValue(dataheader.getHeaderissuedatefrom());
                cell32.setCellStyle(styleC22);
                HSSFCell cell33 = row3.createCell(2);
                if (!"".equalsIgnoreCase(dataheader.getHeaderissuedateto())) {
                    cell33.setCellValue(" to " + dataheader.getHeaderissuedateto());
                    cell33.setCellStyle(styleC22);
                }
                HSSFCell cell34 = row3.createCell(3);
                cell34.setCellValue("Print on : ");
                cell34.setCellStyle(styleC21);
                HSSFCell cell35 = row3.createCell(4);
                cell35.setCellValue(dataheader.getHeaderprinton());
                cell35.setCellStyle(styleC22);

                // Row 4
                HSSFRow row4 = sheetDetail.createRow(3);
                HSSFCell cell41 = row4.createCell(0);
                cell41.setCellValue("Type Routing : ");
                cell41.setCellStyle(styleC21);
                HSSFCell cell42 = row4.createCell(1);
                cell42.setCellValue(dataheader.getHeadertyperouting());
                cell42.setCellStyle(styleC22);
                HSSFCell cell43 = row4.createCell(3);
                cell43.setCellValue("Routing Detail : ");
                cell43.setCellStyle(styleC21);
                HSSFCell cell44 = row4.createCell(4);
                cell44.setCellValue(dataheader.getHeaderroutingdetail());
                cell44.setCellStyle(styleC22);

                // Row 5
                HSSFRow row5 = sheetDetail.createRow(4);
                HSSFCell cell51 = row5.createCell(0);
                cell51.setCellValue("Airline Code : ");
                cell51.setCellStyle(styleC21);
                HSSFCell cell52 = row5.createCell(1);
                cell52.setCellValue(dataheader.getHeaderair());
                cell52.setCellStyle(styleC22);
                HSSFCell cell53 = row5.createCell(3);
                cell53.setCellValue("Passenger : ");
                cell53.setCellStyle(styleC21);
                HSSFCell cell54 = row5.createCell(4);
                cell54.setCellValue(dataheader.getHeaderpassenger());
                cell54.setCellStyle(styleC22);

                // Row 6
                HSSFRow row6 = sheetDetail.createRow(5);
                HSSFCell cell61 = row6.createCell(0);
                cell61.setCellValue("Agent Name : ");
                cell61.setCellStyle(styleC21);
                HSSFCell cell62 = row6.createCell(1);
                cell62.setCellValue(dataheader.getHeaderagentname());
                cell62.setCellStyle(styleC22);
                HSSFCell cell63 = row6.createCell(3);
                cell63.setCellValue("Department : ");
                cell63.setCellStyle(styleC21);
                HSSFCell cell64 = row6.createCell(4);
                cell64.setCellValue(dataheader.getHeaderdepartment());
                cell64.setCellStyle(styleC22);

                // Row 7
                HSSFRow row7 = sheetDetail.createRow(6);
                HSSFCell cell71 = row7.createCell(0);
                cell71.setCellValue("Term Pay : ");
                cell71.setCellStyle(styleC21);
                HSSFCell cell72 = row7.createCell(1);
                cell72.setCellValue(dataheader.getHeadertermpay());
                cell72.setCellStyle(styleC22);
                HSSFCell cell73 = row7.createCell(3);
                cell73.setCellValue("Sale Staff : ");
                cell73.setCellStyle(styleC21);
                HSSFCell cell74 = row7.createCell(4);
                cell74.setCellValue(dataheader.getHeadersalestaff());
                cell74.setCellStyle(styleC22);
            }
        }
        // Header Table
        HSSFCellStyle styleC3 = wb.createCellStyle();
        styleC3.setFont(excelFunction.getHeaderTable(wb.createFont()));
        styleC3.setAlignment(styleC3.ALIGN_CENTER);
        styleC3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderRight(HSSFCellStyle.BORDER_THIN);
        styleC3.setBorderTop(HSSFCellStyle.BORDER_THIN);

        int count = 9;
        int tempcount = 0;
        int tempcount2 = 0;
        int rowdetail = 0;
        int rowrouting = 0;
        int x = 0;
        int y = 0;
        for (int i = 0; i < summaryAirlinePax.size(); i++) {
            SummaryAirlinePaxView data = (SummaryAirlinePaxView) summaryAirlinePax.get(i);

            if ("inv".equalsIgnoreCase(data.getPage())) {
                //inv
                HSSFRow row8 = sheetInv.createRow(8);
                HSSFCell cell81 = row8.createCell(0);
                cell81.setCellValue("INV No.");
                cell81.setCellStyle(styleC3);
                //                    sheetInv.autoSizeColumn(0);
                HSSFCell cell82 = row8.createCell(1);
                cell82.setCellValue("Amount Wendy");
                cell82.setCellStyle(styleC3);
                //                    sheetInv.autoSizeColumn(1);
                HSSFCell cell83 = row8.createCell(2);
                cell83.setCellValue("Amount Outbound");
                //                    sheetInv.autoSizeColumn(2);
                cell83.setCellStyle(styleC3);
                HSSFCell cell84 = row8.createCell(3);
                cell84.setCellValue("Amount Inbound");
                //                    sheetInv.autoSizeColumn(3);
                cell84.setCellStyle(styleC3);

                HSSFRow row = sheetInv.createRow(count + i);
                HSSFCell celldata0 = row.createCell(0);
                celldata0.setCellValue(String.valueOf(data.getInvnoPax()));
                celldata0.setCellStyle(styleC26);

                HSSFCell celldata1 = row.createCell(1);
                celldata1.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountwendy())) ? 0
                        : (new BigDecimal(data.getAmountwendy())).doubleValue());
                celldata1.setCellStyle(styleC25);

                HSSFCell celldata2 = row.createCell(2);
                celldata2.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountoutbound())) ? 0
                        : (new BigDecimal(data.getAmountoutbound())).doubleValue());
                celldata2.setCellStyle(styleC25);

                HSSFCell celldata3 = row.createCell(3);
                celldata3.setCellValue("".equalsIgnoreCase(String.valueOf(data.getAmountinbound())) ? 0
                        : (new BigDecimal(data.getAmountinbound())).doubleValue());
                celldata3.setCellStyle(styleC25);

                tempcount = count + i + 1;
            }
            //detail
            if ("detail".equalsIgnoreCase(data.getPage())) {
                //Total inv
                HSSFRow rowtotal = sheetInv.createRow(tempcount);
                String totalwendy = "SUM(B" + 10 + ":B" + (tempcount) + ")";
                String totaloutbound = "SUM(C" + 10 + ":C" + (tempcount) + ")";
                String totalinbound = "SUM(D" + 10 + ":D" + (tempcount) + ")";

                HSSFCellStyle styleTotal = wb.createCellStyle();
                styleTotal.setFont(excelFunction.getHeaderTable(wb.createFont()));
                styleTotal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderRight(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderTop(HSSFCellStyle.BORDER_THIN);
                styleTotal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                styleTotal.setAlignment(styleC22.ALIGN_RIGHT);

                HSSFCell cellTotal00 = rowtotal.createCell(0);
                cellTotal00.setCellValue("Total");
                cellTotal00.setCellStyle(styleTotal);
                HSSFCell cellTotal01 = rowtotal.createCell(1);
                cellTotal01.setCellFormula(totalwendy);
                cellTotal01.setCellStyle(styleC25);
                HSSFCell cellTotal02 = rowtotal.createCell(2);
                cellTotal02.setCellFormula(totaloutbound);
                cellTotal02.setCellStyle(styleC25);
                HSSFCell cellTotal03 = rowtotal.createCell(3);
                cellTotal03.setCellFormula(totalinbound);
                cellTotal03.setCellStyle(styleC25);

                //                    if(tempcount != 0){
                //                        rowdetail = tempcount+3;
                //                    }
                HSSFRow row8 = sheetDetail.createRow(8);
                HSSFCell cell81 = row8.createCell(0);
                cell81.setCellValue("Payment Type");
                cell81.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(0);
                HSSFCell cell82 = row8.createCell(1);
                cell82.setCellValue("Type Routing");
                cell82.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(1);
                HSSFCell cell83 = row8.createCell(2);
                cell83.setCellValue("Pax");
                //                    sheetDetail.autoSizeColumn(2);
                cell83.setCellStyle(styleC3);
                HSSFCell cell84 = row8.createCell(3);
                cell84.setCellValue("Air");
                cell84.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(3);
                HSSFCell cell85 = row8.createCell(4);
                cell85.setCellValue("Net Sales");
                cell85.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(4);
                HSSFCell cell86 = row8.createCell(5);
                cell86.setCellValue("Tax");
                cell86.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(5);
                HSSFCell cell87 = row8.createCell(6);
                cell87.setCellValue("Ins.");
                cell87.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(6);
                HSSFCell cell88 = row8.createCell(7);
                cell88.setCellValue("Comm");
                cell88.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(7);
                HSSFCell cell89 = row8.createCell(8);
                cell89.setCellValue("Inv. Amt");
                cell89.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(8);
                HSSFCell cell90 = row8.createCell(9);
                cell90.setCellValue("Cost");
                cell90.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(9);
                HSSFCell cell91 = row8.createCell(10);
                cell91.setCellValue("PF[LOSS]");
                cell91.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(10);
                HSSFCell cell92 = row8.createCell(11);
                cell92.setCellValue("No.Inv Amt");
                cell92.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(11);
                HSSFCell cell93 = row8.createCell(12);
                cell93.setCellValue("INV No.");
                cell93.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(12);
                HSSFCell cell94 = row8.createCell(13);
                cell94.setCellValue("Diff Vat");
                cell94.setCellStyle(styleC3);
                //                    sheetDetail.autoSizeColumn(13);

                HSSFRow row = sheetDetail.createRow(count + x);
                HSSFCell celldata0 = row.createCell(0);

                celldata0.setCellValue(String.valueOf(data.getTypepayment()));
                celldata0.setCellStyle(styleC29);

                HSSFCell celldata1 = row.createCell(1);
                celldata1.setCellValue(String.valueOf(data.getTyperounting()));
                celldata1.setCellStyle(styleC29);

                HSSFCell celldata2 = row.createCell(2);
                celldata2.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPax())) ? 0
                        : (new BigDecimal(data.getPax())).doubleValue());
                celldata2.setCellStyle(styleC26);

                HSSFCell celldata3 = row.createCell(3);
                celldata3.setCellValue(String.valueOf(data.getAir()));
                celldata3.setCellStyle(styleC26);

                HSSFCell celldata4 = row.createCell(4);
                celldata4.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNetsales())) ? 0
                        : (new BigDecimal(data.getNetsales())).doubleValue());
                celldata4.setCellStyle(styleC25);

                HSSFCell celldata5 = row.createCell(5);
                celldata5.setCellValue("".equalsIgnoreCase(String.valueOf(data.getTax())) ? 0
                        : (new BigDecimal(data.getTax())).doubleValue());
                celldata5.setCellStyle(styleC25);

                HSSFCell celldata6 = row.createCell(6);
                celldata6.setCellValue("".equalsIgnoreCase(String.valueOf(data.getIns())) ? 0
                        : (new BigDecimal(data.getIns())).doubleValue());
                celldata6.setCellStyle(styleC25);

                HSSFCell celldata7 = row.createCell(7);
                celldata7.setCellValue("".equalsIgnoreCase(String.valueOf(data.getComms())) ? 0
                        : (new BigDecimal(data.getComms())).doubleValue());
                celldata7.setCellStyle(styleC25);

                HSSFCell celldata8 = row.createCell(8);
                celldata8.setCellValue("".equalsIgnoreCase(String.valueOf(data.getInvamount())) ? 0
                        : (new BigDecimal(data.getInvamount())).doubleValue());
                celldata8.setCellStyle(styleC25);

                HSSFCell celldata9 = row.createCell(9);
                celldata9.setCellValue("".equalsIgnoreCase(String.valueOf(data.getCost())) ? 0
                        : (new BigDecimal(data.getCost())).doubleValue());
                celldata9.setCellStyle(styleC25);

                HSSFCell celldata10 = row.createCell(10);
                celldata10.setCellValue("".equalsIgnoreCase(String.valueOf(data.getPfloss())) ? 0
                        : (new BigDecimal(data.getPfloss())).doubleValue());
                celldata10.setCellStyle(styleC25);

                HSSFCell celldata11 = row.createCell(11); // No inv amount
                celldata11.setCellValue("".equalsIgnoreCase(String.valueOf(data.getNoinvamount())) ? 0
                        : (new BigDecimal(data.getNoinvamount())).doubleValue());
                celldata11.setCellStyle(styleC25);

                HSSFCell celldata12 = row.createCell(12);
                celldata12.setCellValue(String.valueOf(data.getInvno()));
                celldata12.setCellStyle(styleC29);

                HSSFCell celldata13 = row.createCell(13);
                celldata13.setCellValue("".equalsIgnoreCase(String.valueOf(data.getDiff())) ? 0
                        : (new BigDecimal(data.getDiff())).doubleValue());
                celldata13.setCellStyle(styleC25);
                //                    tempcount2 = count + i + 4;
                // set total last row
                if (i == (summaryAirlinePax.size() - 1)) {
                    HSSFRow rows = sheetDetail.createRow(count + x + 1);

                    String totalPax = "SUM(C" + 10 + ":C" + (count + x + 1) + ")";
                    String totalNet = "SUM(E" + 10 + ":E" + (count + x + 1) + ")";
                    String totalTax = "SUM(F" + 10 + ":F" + (count + x + 1) + ")";
                    String totalIns = "SUM(G" + 10 + ":G" + (count + x + 1) + ")";
                    String totalComm = "SUM(H" + 10 + ":H" + (count + x + 1) + ")";
                    String totalInvamt = "SUM(I" + 10 + ":I" + (count + x + 1) + ")";
                    String totalCost = "SUM(J" + 10 + ":J" + (count + x + 1) + ")";
                    String totalPfloss = "SUM(K" + 10 + ":K" + (count + x + 1) + ")";
                    String totalNoInvamt = "SUM(L" + 10 + ":L" + (count + x + 1) + ")";
                    String totalDiff = "SUM(N" + 10 + ":N" + (count + x + 1) + ")";

                    HSSFCell celldatas0 = rows.createCell(0);
                    celldatas0.setCellStyle(styleC29);
                    HSSFCell celldatas01 = rows.createCell(1);
                    celldatas01.setCellStyle(styleC29);
                    HSSFCell celldatas02 = rows.createCell(2);
                    celldatas02.setCellFormula(totalPax);
                    celldatas02.setCellStyle(styleC26);

                    HSSFCell celldatas03 = rows.createCell(4);
                    celldatas03.setCellFormula(totalNet);
                    celldatas03.setCellStyle(styleC25);
                    HSSFCell celldatas04 = rows.createCell(5);
                    celldatas04.setCellFormula(totalTax);
                    celldatas04.setCellStyle(styleC25);
                    HSSFCell celldatas05 = rows.createCell(6);
                    celldatas05.setCellFormula(totalIns);
                    celldatas05.setCellStyle(styleC25);
                    HSSFCell celldatas06 = rows.createCell(7);
                    celldatas06.setCellFormula(totalComm);
                    celldatas06.setCellStyle(styleC25);
                    HSSFCell celldatas07 = rows.createCell(8);
                    celldatas07.setCellFormula(totalInvamt);
                    celldatas07.setCellStyle(styleC25);
                    HSSFCell celldatas08 = rows.createCell(9);
                    celldatas08.setCellFormula(totalCost);
                    celldatas08.setCellStyle(styleC25);
                    HSSFCell celldatas09 = rows.createCell(10);
                    celldatas09.setCellFormula(totalPfloss);
                    celldatas09.setCellStyle(styleC25);
                    HSSFCell celldatas10 = rows.createCell(11);
                    celldatas10.setCellFormula(totalNoInvamt);
                    celldatas10.setCellStyle(styleC25);
                    HSSFCell celldatas11 = rows.createCell(13);
                    celldatas11.setCellFormula(totalDiff);
                    celldatas11.setCellStyle(styleC25);

                    HSSFCell celldatas12 = rows.createCell(3);
                    celldatas12.setCellStyle(styleC29);
                    HSSFCell celldatas13 = rows.createCell(12);
                    celldatas13.setCellStyle(styleC29);
                }
                x++;
            }

        }
        for (int j = 0; j < 30; j++) {
            sheetInv.autoSizeColumn(j);
            sheetDetail.autoSizeColumn(j);
        }

        sheetDetail.setColumnWidth(5, 256 * 12);
        sheetDetail.setColumnWidth(6, 256 * 12);
        sheetDetail.setColumnWidth(7, 256 * 12);
        sheetDetail.setColumnWidth(8, 256 * 12);
        sheetDetail.setColumnWidth(9, 256 * 12);
        sheetDetail.setColumnWidth(10, 256 * 12);
        sheetDetail.setColumnWidth(13, 256 * 12);
    }
}

From source file:com.smi.travel.controller.excel.checking.airticket.BillAirAgentSummary.java

public void getBillAirAgentReportSummary(HSSFWorkbook wb, List BillAirAgent) {
    List<ListBillAirAgent> listAirAgent = new ArrayList<ListBillAirAgent>();
    if (BillAirAgent != null && BillAirAgent.size() != 0) {
        listAirAgent = BillAirAgent;/*from   w  w w .  java2  s  .  co  m*/
    } else {
        listAirAgent = null;
    }
    List<BillAirAgent> listAgent = new ArrayList<BillAirAgent>();
    List<BillAirAgentRefund> listAgentRefund = new ArrayList<BillAirAgentRefund>();
    if (listAirAgent != null && listAirAgent.size() != 0) {
        listAgent = listAirAgent.get(0).getBillAirAgent();
        listAgentRefund = listAirAgent.get(0).getBillAirAgentRefund();
    } else {
        listAgent = null;
        listAgentRefund = null;
    }

    String sheetName = "Summary";// name of sheet
    String sheetName1 = "Detail";
    String sheetName2 = "Refund";
    HSSFSheet sheet = wb.createSheet(sheetName);
    HSSFSheet sheet1 = wb.createSheet(sheetName1);
    HSSFSheet sheet2 = wb.createSheet(sheetName2);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    HSSFRow row111 = sheet1.createRow(0);
    HSSFCell cell1111 = row111.createCell(0);
    cell1111.setCellValue("detail");

    // set Header Report (Row 1)
    HSSFCellStyle styleC1 = wb.createCellStyle();
    HSSFRow row1 = sheet.createRow(0);
    HSSFCell cell1 = row1.createCell(0);
    cell1.setCellValue("Bill Agent Air Summary");
    styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell1.setCellStyle(styleC1);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:F1"));

    // Set align Text
    HSSFCellStyle styleAlignRight = wb.createCellStyle(); // use
    styleAlignRight.setAlignment(styleAlignRight.ALIGN_RIGHT);
    HSSFCellStyle styleAlignLeft = wb.createCellStyle(); // use
    styleAlignLeft.setAlignment(styleAlignLeft.ALIGN_LEFT);
    HSSFCellStyle styleAlignCenter = wb.createCellStyle();
    styleAlignCenter.setAlignment(styleAlignCenter.ALIGN_CENTER);
    HSSFCellStyle styleBorderLeft = wb.createCellStyle();
    styleBorderLeft.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    HSSFCellStyle styleBorderRight = wb.createCellStyle();
    styleBorderRight.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    HSSFDataFormat currency = wb.createDataFormat();
    HSSFCellStyle styleNumber = wb.createCellStyle();
    styleNumber.setAlignment(styleNumber.ALIGN_RIGHT);
    styleNumber.setDataFormat(currency.getFormat("#,##0.00"));
    HSSFCellStyle styleNumberBorderRight = wb.createCellStyle();
    styleNumberBorderRight.setAlignment(styleNumberBorderRight.ALIGN_RIGHT);
    styleNumberBorderRight.setDataFormat(currency.getFormat("#,##0.00"));
    styleNumberBorderRight.setBorderRight(styleNumberBorderRight.BORDER_THIN);

    // line table
    HSSFCellStyle styleAlignLeftBorderTopRight = wb.createCellStyle(); // use
    styleAlignLeftBorderTopRight.setAlignment(styleAlignLeftBorderTopRight.ALIGN_LEFT);
    styleAlignLeftBorderTopRight.setBorderTop(styleAlignLeftBorderTopRight.BORDER_THIN);
    styleAlignLeftBorderTopRight.setBorderRight(styleAlignLeftBorderTopRight.BORDER_THIN);
    HSSFCellStyle styleAlignLeftBorderTopLeft = wb.createCellStyle(); // use
    styleAlignLeftBorderTopLeft.setAlignment(styleAlignLeftBorderTopLeft.ALIGN_LEFT);
    styleAlignLeftBorderTopLeft.setBorderTop(styleAlignLeftBorderTopLeft.BORDER_THIN);
    styleAlignLeftBorderTopLeft.setBorderLeft(styleAlignLeftBorderTopLeft.BORDER_THIN);
    HSSFCellStyle styleBorderTop = wb.createCellStyle(); // use
    styleBorderTop.setBorderTop(styleBorderTop.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderBottomRight = wb.createCellStyle();//use
    styleAlignRightBorderBottomRight.setAlignment(styleAlignRightBorderBottomRight.ALIGN_LEFT);
    styleAlignRightBorderBottomRight.setBorderBottom(styleAlignRightBorderBottomRight.BORDER_THIN);
    styleAlignRightBorderBottomRight.setBorderRight(styleAlignRightBorderBottomRight.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderBottomLeft = wb.createCellStyle();
    styleAlignRightBorderBottomLeft.setAlignment(styleAlignRightBorderBottomLeft.ALIGN_LEFT);
    styleAlignRightBorderBottomLeft.setBorderBottom(styleAlignRightBorderBottomLeft.BORDER_THIN);
    styleAlignRightBorderBottomLeft.setBorderLeft(styleAlignRightBorderBottomLeft.BORDER_THIN);
    HSSFCellStyle styleBorderBottom = wb.createCellStyle(); //use
    styleBorderBottom.setBorderBottom(styleBorderBottom.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderRight = wb.createCellStyle(); //use
    styleAlignRightBorderRight.setAlignment(styleAlignRightBorderRight.ALIGN_RIGHT);
    styleAlignRightBorderRight.setBorderRight(styleAlignRightBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignLeftBorderRight = wb.createCellStyle();
    styleAlignLeftBorderRight.setAlignment(styleAlignLeftBorderRight.ALIGN_LEFT);
    styleAlignLeftBorderRight.setBorderRight(styleAlignLeftBorderRight.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderLeft = wb.createCellStyle();//use
    styleAlignRightBorderLeft.setAlignment(styleAlignRightBorderLeft.ALIGN_RIGHT);
    styleAlignRightBorderLeft.setBorderLeft(styleAlignRightBorderLeft.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderTopBottom = wb.createCellStyle();
    styleAlignRightBorderTopBottom.setAlignment(styleAlignRightBorderTopBottom.ALIGN_RIGHT);
    styleAlignRightBorderTopBottom.setBorderTop(styleAlignRightBorderTopBottom.BORDER_THIN);
    styleAlignRightBorderTopBottom.setBorderBottom(styleAlignRightBorderTopBottom.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderTopBottomRight = wb.createCellStyle();
    styleAlignRightBorderTopBottomRight.setAlignment(styleAlignRightBorderTopBottomRight.ALIGN_RIGHT);
    styleAlignRightBorderTopBottomRight.setBorderTop(styleAlignRightBorderTopBottomRight.BORDER_THIN);
    styleAlignRightBorderTopBottomRight.setBorderBottom(styleAlignRightBorderTopBottomRight.BORDER_THIN);
    styleAlignRightBorderTopBottomRight.setBorderRight(styleAlignRightBorderTopBottomRight.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderAllHeaderTable = wb.createCellStyle();
    styleAlignRightBorderAllHeaderTable.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleAlignRightBorderAllHeaderTable.setAlignment(styleAlignRightBorderAllHeaderTable.ALIGN_CENTER);
    styleAlignRightBorderAllHeaderTable.setBorderTop(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderBottom(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderRight(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderLeft(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderAll = wb.createCellStyle();
    styleAlignRightBorderAll.setAlignment(styleAlignRightBorderAll.ALIGN_LEFT);
    styleAlignRightBorderAll.setBorderTop(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderBottom(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderRight(styleAlignRightBorderAll.BORDER_THIN);
    styleAlignRightBorderAll.setBorderLeft(styleAlignRightBorderAll.BORDER_THIN);
    HSSFCellStyle styleAlignRightBorderAllNumber = wb.createCellStyle();
    styleAlignRightBorderAllNumber.setAlignment(styleAlignRightBorderAllNumber.ALIGN_RIGHT);
    styleAlignRightBorderAllNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleAlignRightBorderAllNumber.setBorderTop(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderBottom(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderRight(styleAlignRightBorderAllNumber.BORDER_THIN);
    styleAlignRightBorderAllNumber.setBorderLeft(styleAlignRightBorderAllNumber.BORDER_THIN);
    HSSFCellStyle styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);
    HSSFCellStyle styleDetailTableNumber = wb.createCellStyle();
    styleDetailTableNumber.setAlignment(styleDetailTableNumber.ALIGN_RIGHT);
    styleDetailTableNumber.setBorderLeft(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setBorderRight(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    HSSFCellStyle styleDetailTableBorderBottom = wb.createCellStyle();
    styleDetailTableBorderBottom.setBorderTop(styleDetailTableBorderBottom.BORDER_THIN);

    BillAirAgent bil = new BillAirAgent();
    if ((listAgent != null) && (listAgent.size() != 0)) {
        bil = (BillAirAgent) listAgent.get(0);
    }
    // Row 2
    HSSFRow row2 = sheet.createRow(1);
    HSSFCell cell21 = row2.createCell(0);
    cell21.setCellValue("Agent : ");
    cell21.setCellStyle(styleAlignRight);
    HSSFCell cell22 = row2.createCell(1);
    cell22.setCellValue(bil.getAgentPage());
    cell22.setCellStyle(styleAlignLeft);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B2:D2"));
    HSSFCell cell23 = row2.createCell(4);
    cell23.setCellValue("Print By : ");
    cell23.setCellStyle(styleAlignRight);
    HSSFCell cell24 = row2.createCell(5);
    cell24.setCellValue(bil.getPrintbyPage());
    cell24.setCellStyle(styleAlignLeft);

    // Row 3
    HSSFRow row3 = sheet.createRow(2);
    HSSFCell cell31 = row3.createCell(0);
    cell31.setCellValue("Issue Date : ");
    cell31.setCellStyle(styleAlignRight);
    HSSFCell cell32 = row3.createCell(1);
    cell32.setCellValue(bil.getIssuedatePage());
    cell32.setCellStyle(styleAlignLeft);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
    HSSFCell cell33 = row3.createCell(4);
    cell33.setCellValue("Page : ");
    cell33.setCellStyle(styleAlignRight);
    HSSFCell cell34 = row3.createCell(5);
    cell34.setCellValue("1");
    cell34.setCellStyle(styleAlignLeft);

    // Row 4
    HSSFRow row4 = sheet.createRow(3);
    HSSFCell cell41 = row4.createCell(0);
    cell41.setCellValue("Invoice Date : ");
    cell41.setCellStyle(styleAlignRight);
    HSSFCell cell42 = row4.createCell(1);
    cell42.setCellValue(bil.getInvoicedatePage());
    cell42.setCellStyle(styleAlignLeft);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));

    // Row 5
    HSSFRow row5 = sheet.createRow(4);
    HSSFCell cell51 = row5.createCell(0);
    cell51.setCellValue("Payment Type : ");
    cell51.setCellStyle(styleAlignRight);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));
    HSSFCell cell52 = row5.createCell(1);
    cell52.setCellValue(bil.getPaymenttypePage());
    cell52.setCellStyle(styleAlignLeft);
    if (listAgent != null && listAgent.size() != 0) {
        // Body Table
        BigDecimal sumSalePrice = new BigDecimal(0);
        BigDecimal sumAmountAir = new BigDecimal(0);
        BigDecimal sumComPay = new BigDecimal(0);
        BigDecimal sumComReceive = new BigDecimal(0);
        BigDecimal sumTotalComRefundReceive = new BigDecimal(0);
        BigDecimal sumTotalPayment = new BigDecimal(0);
        BigDecimal sumTotalCompay = new BigDecimal(0);
        BigDecimal sumTotalCompaySub = new BigDecimal(0);
        BigDecimal sumPayRefundAmount = new BigDecimal(0);
        BigDecimal sumVatComPay = new BigDecimal(0);
        BigDecimal SumVatReceive = new BigDecimal(0);
        BigDecimal vatComPay = new BigDecimal(0);
        BigDecimal vatPay = new BigDecimal(0);
        BigDecimal vatReceive = new BigDecimal(0);
        BigDecimal totalCom = new BigDecimal(0);
        BigDecimal balancePayment = new BigDecimal(0);
        BigDecimal checkResult = new BigDecimal(0);
        BigDecimal midValue = new BigDecimal(0);
        BigDecimal withHoldingTax = new BigDecimal(0);
        String vatMDE = "";
        String whtMDE = "";

        for (int i = 0; i < listAgent.size(); i++) {
            sumSalePrice = sumSalePrice.add(new BigDecimal(listAgent.get(i).getSaleprice()));
            sumAmountAir = sumAmountAir.add(new BigDecimal(listAgent.get(i).getAmountair()));
            sumComPay = sumComPay.add(new BigDecimal(listAgent.get(i).getCompay()));
            sumVatComPay = sumVatComPay.add(new BigDecimal(listAgent.get(i).getCompayvat()));
            sumTotalComRefundReceive = sumTotalComRefundReceive
                    .add(new BigDecimal(listAgent.get(i).getAgentcomrefund()));

            System.out.println(
                    "Sale Price : " + listAgent.get(i).getSaleprice() + "  Sum Sale Price : " + sumSalePrice);
            System.out.println(
                    "Amount Air : " + listAgent.get(i).getAmountair() + "  Sum Amount Air : " + sumAmountAir);
            System.out.println("Com Pay : " + listAgent.get(i).getCompay() + "  Sum Com Pay : " + sumComPay);
            System.out.println("Com Reefund Receive : " + listAgent.get(i).getAgentcomrefund()
                    + "  Sum Reefund Receive : " + sumTotalComRefundReceive);
            System.out.println("Pay Refund Amount : " + listAgent.get(i).getPaycusrefund()
                    + "  Sum Refund Amount : " + sumPayRefundAmount);
        }
        for (int i = 0; i < listAgentRefund.size(); i++) {
            sumComReceive = sumComReceive.add(new BigDecimal(listAgentRefund.get(i).getComm_rec()));
            sumPayRefundAmount = sumPayRefundAmount.add(new BigDecimal(listAgentRefund.get(i).getAmountpay()));
            SumVatReceive = SumVatReceive.add(new BigDecimal(listAgentRefund.get(i).getVat()));
            //            System.out.println("Com Receive : " + listAgent.get(i).getAgentcom() + "  Sum Com Receive : " + sumComReceive);
        }
        vatMDE = listAgent.get(0).getVattemp();
        whtMDE = listAgent.get(0).getWhttemp();
        System.out.println("Vat : " + vatMDE + "Wht  :" + whtMDE);

        DecimalFormat df = new DecimalFormat("#,###.00");
        sumTotalPayment = sumSalePrice.add(sumComReceive);
        sumTotalCompay = sumComPay.subtract(sumComReceive);
        sumTotalCompaySub = sumComPay.multiply((BigDecimal.ZERO).subtract(BigDecimal.ONE));

        BigDecimal vatPa = new BigDecimal(vatMDE);
        vatComPay = sumTotalCompay.multiply(vatPa);
        vatComPay = vatComPay.divide(new BigDecimal(100), MathContext.DECIMAL128);
        vatPay = (vatComPay.add(SumVatReceive)).multiply((BigDecimal.ZERO).subtract(BigDecimal.ONE));

        //        vatReceive = sumComReceive.multiply(new BigDecimal(0.07));
        totalCom = sumTotalCompaySub.add(sumComReceive);
        sumPayRefundAmount = sumPayRefundAmount.multiply((BigDecimal.ZERO).subtract(BigDecimal.ONE));

        balancePayment = sumTotalPayment.add(vatPay);
        balancePayment = balancePayment.add(SumVatReceive);
        balancePayment = balancePayment
                .subtract(sumPayRefundAmount.multiply((BigDecimal.ZERO).subtract(BigDecimal.ONE)));

        checkResult = sumTotalCompay.add(vatComPay);

        midValue = checkResult.add(balancePayment);
        midValue = midValue.add(sumPayRefundAmount.multiply((BigDecimal.ZERO).subtract(BigDecimal.ONE)));

        withHoldingTax = sumTotalCompay.add(vatComPay);
        withHoldingTax = withHoldingTax.multiply(new BigDecimal(100));
        System.out.println("Vat :::: " + vatMDE + "Wht :::: " + whtMDE);
        BigDecimal vatTemp = new BigDecimal(vatMDE);
        BigDecimal whtTemp = new BigDecimal(whtMDE);
        vatTemp = vatTemp.add(new BigDecimal(100));
        whtTemp = whtTemp.divide(new BigDecimal(100), MathContext.DECIMAL128);
        withHoldingTax = withHoldingTax.divide(vatTemp, MathContext.DECIMAL128);
        withHoldingTax = withHoldingTax.multiply(whtTemp);

        System.out.println(">>>>>>>>>>> Total Sale Price : " + df.format(sumSalePrice));
        System.out.println(">>>>>>>>>>> Total Com Refund Receive : " + df.format(sumComReceive));
        System.out.println(">>>>>>>>>>> Total Payment : " + df.format(sumTotalPayment));
        System.out.println(">>>>>>>>>>> Com Pay (Less) : " + df.format(sumTotalCompaySub));
        System.out.println(">>>>>>>>>>> Com Receive (Less) : " + df.format(sumComReceive));
        System.out.println(">>>>>>>>>>> Total Com : " + df.format(totalCom));
        System.out.println(">>>>>>>>>>> Vat pay (Less) : " + df.format(vatPay));
        System.out.println(">>>>>>>>>>> Vat receive (Less) : " + df.format(SumVatReceive));
        System.out.println(">>>>>>>>>>> Pay Refund Amount (Less): " + df.format(sumPayRefundAmount));
        System.out.println(">>>>>>>>>>> Balance payment : " + df.format(balancePayment));
        System.out.println(">>>>>>>>>>> Amount Air Sale : " + df.format(sumAmountAir));
        System.out.println(">>>>>>>>>>> Com Pay : " + df.format(sumComPay));
        System.out.println(">>>>>>>>>>> Com Receive : " + df.format(sumComReceive));
        System.out.println(">>>>>>>>>>> Total Com Pay : " + df.format(sumTotalCompay));
        System.out.println(">>>>>>>>>>> Vat Com Pay : " + df.format(vatComPay));
        System.out.println(">>>>>>>>>>> With holding : " + df.format(withHoldingTax));
        System.out.println(">>>>>>>>>>> Mid Value : " + df.format(midValue));
        System.out.println(">>>>>>>>>>> Check Result : " + df.format(checkResult));

        HSSFRow row8 = sheet.createRow(7);
        HSSFCell cell81 = row8.createCell(0);
        row8.createCell(1).setCellStyle(styleBorderTop);
        row8.createCell(2).setCellStyle(styleBorderTop);
        row8.createCell(3).setCellStyle(styleBorderTop);
        row8.createCell(4).setCellStyle(styleBorderTop);
        row8.createCell(5).setCellStyle(styleBorderTop);
        row8.createCell(6).setCellStyle(styleBorderTop);
        row8.createCell(7).setCellStyle(styleAlignLeftBorderTopRight);
        cell81.setCellStyle(styleBorderTop);
        cell81.setCellValue("All");
        sheet.autoSizeColumn(0);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A8:H8"));
        HSSFCell cell82 = row8.createCell(9);
        cell82.setCellStyle(styleAlignLeftBorderTopLeft);
        cell82.setCellValue("Amount Air Sale      ");
        sheet.autoSizeColumn(9);
        row8.createCell(10).setCellStyle(styleBorderTop);
        HSSFCell cell83 = row8.createCell(11);
        cell83.setCellValue("Com Pay      ");
        cell83.setCellStyle(styleAlignLeftBorderTopRight);
        sheet.autoSizeColumn(11);
        HSSFRow row9 = sheet.createRow(8);
        HSSFCell cell91 = row9.createCell(0);
        cell91.setCellValue("Total Sale Price : ");
        cell91.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A9:E9"));
        sheet.autoSizeColumn(0);
        HSSFCell cell92 = row9.createCell(5);
        cell92.setCellValue(df.format(sumSalePrice));
        cell92.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F9:H9"));
        sheet.autoSizeColumn(5);
        row9.createCell(7).setCellStyle(styleAlignRightBorderRight);
        HSSFCell cell93 = row9.createCell(9);
        cell93.setCellStyle(styleAlignRightBorderLeft);
        cell93.setCellValue(df.format(sumAmountAir));
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell94 = row9.createCell(11);
        cell94.setCellValue(df.format(sumComPay));
        cell94.setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row10 = sheet.createRow(9);
        HSSFCell cell101 = row10.createCell(0);
        cell101.setCellValue("Total Com Refund Receive : ");
        cell101.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A10:E10"));
        sheet.autoSizeColumn(0);
        HSSFCell cell102 = row10.createCell(5);
        cell102.setCellValue(df.format(sumComReceive));
        cell102.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F10:H10"));
        sheet.autoSizeColumn(5);
        row10.createCell(7).setCellStyle(styleAlignRightBorderRight);
        HSSFCell cell103 = row10.createCell(9);
        cell103.setCellStyle(styleAlignRightBorderLeft);
        cell103.setCellValue("");
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell104 = row10.createCell(11);
        cell104.setCellValue("");
        cell104.setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row11 = sheet.createRow(10);
        HSSFCell cell111 = row11.createCell(0);
        cell111.setCellValue("Total Payment : ");
        cell111.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A11:E11"));
        sheet.autoSizeColumn(0);
        HSSFCell cell112 = row11.createCell(5);
        cell112.setCellValue(df.format(sumTotalPayment));
        cell112.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F11:H11"));
        sheet.autoSizeColumn(5);
        row11.createCell(7).setCellStyle(styleAlignRightBorderRight);
        HSSFCell cell113 = row11.createCell(9);
        cell113.setCellStyle(styleAlignRightBorderLeft);
        cell113.setCellValue("");
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell114 = row11.createCell(11);
        cell114.setCellValue("Com Receive       ");
        cell114.setCellStyle(styleAlignLeftBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row12 = sheet.createRow(11);
        HSSFCell cell121 = row12.createCell(0);
        row12.createCell(1).setCellStyle(styleBorderBottom);
        row12.createCell(2).setCellStyle(styleBorderBottom);
        row12.createCell(3).setCellStyle(styleBorderBottom);
        row12.createCell(4).setCellStyle(styleBorderBottom);
        row12.createCell(5).setCellStyle(styleBorderBottom);
        row12.createCell(6).setCellStyle(styleBorderBottom);
        row12.createCell(7).setCellStyle(styleAlignRightBorderBottomRight);
        cell121.setCellStyle(styleBorderBottom);
        sheet.autoSizeColumn(0);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A12:H12"));
        HSSFCell cell122 = row12.createCell(9);
        cell122.setCellStyle(styleAlignRightBorderLeft);
        cell122.setCellValue("");
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell123 = row12.createCell(11);
        cell123.setCellValue(df.format(sumComReceive));
        cell123.setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row13 = sheet.createRow(12);
        HSSFCell cell131 = row13.createCell(9);
        cell131.setCellStyle(styleAlignRightBorderLeft);
        cell131.setCellValue("");
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell132 = row13.createCell(11);
        cell132.setCellValue("Total Com Pay    ");
        cell132.setCellStyle(styleAlignLeftBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row14 = sheet.createRow(13);
        HSSFCell cell141 = row14.createCell(0);
        row14.createCell(1).setCellStyle(styleBorderTop);
        row14.createCell(2).setCellStyle(styleBorderTop);
        row14.createCell(3).setCellStyle(styleBorderTop);
        row14.createCell(4).setCellStyle(styleBorderTop);
        row14.createCell(5).setCellStyle(styleBorderTop);
        row14.createCell(6).setCellStyle(styleBorderTop);
        row14.createCell(7).setCellStyle(styleAlignLeftBorderTopRight);
        cell141.setCellStyle(styleBorderTop);
        cell141.setCellValue("Less");
        sheet.autoSizeColumn(0);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A12:H12"));
        HSSFCell cell143 = row14.createCell(9);
        cell143.setCellStyle(styleAlignRightBorderLeft);
        cell143.setCellValue("    ");
        sheet.autoSizeColumn(9);
        row14.createCell(10).setCellValue("");
        HSSFCell cell144 = row14.createCell(11);
        cell144.setCellValue(df.format(sumTotalCompay));
        cell144.setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row15 = sheet.createRow(14);
        HSSFCell cell151 = row15.createCell(0);
        cell151.setCellValue("Com Pay : ");
        cell151.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell1511 = row15.createCell(1);
        cell1511.setCellValue(df.format(sumTotalCompaySub));
        cell1511.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B15:D15"));
        sheet.autoSizeColumn(1);
        HSSFCell cell152 = row15.createCell(4);
        cell152.setCellValue("Vat Pay : ");
        cell152.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(4);
        HSSFCell cell1521 = row15.createCell(5);
        cell1521.setCellValue(df.format(vatPay));
        cell1521.setCellStyle(styleAlignRight);
        row15.createCell(7).setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(5);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F15:H15"));
        HSSFCell cell153 = row15.createCell(9);
        cell153.setCellStyle(styleAlignRightBorderLeft);
        cell153.setCellValue("    ");
        sheet.autoSizeColumn(9);
        row15.createCell(10).setCellValue("");
        HSSFCell cell154 = row15.createCell(11);
        cell154.setCellValue("    ");
        cell154.setCellStyle(styleAlignLeftBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row16 = sheet.createRow(15);
        HSSFCell cell161 = row16.createCell(0);
        cell161.setCellValue("Com Receive : ");
        cell161.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(0);
        HSSFCell cell1611 = row16.createCell(1);
        cell1611.setCellValue(df.format(sumComReceive));
        cell1611.setCellStyle(styleAlignRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B16:D16"));
        sheet.autoSizeColumn(1);
        HSSFCell cell162 = row16.createCell(4);
        cell162.setCellValue("Vat Receive : ");
        cell162.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(4);
        HSSFCell cell1621 = row16.createCell(5);
        cell1621.setCellValue(df.format(SumVatReceive));
        cell1621.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(5);
        row16.createCell(7).setCellStyle(styleAlignRightBorderRight);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F16:H16"));
        HSSFCell cell163 = row16.createCell(9);
        cell163.setCellStyle(styleAlignRightBorderLeft);
        cell163.setCellValue("    ");
        sheet.autoSizeColumn(9);
        row16.createCell(10).setCellValue("");
        HSSFCell cell164 = row16.createCell(11);
        cell164.setCellValue("Vat Com Pay    ");
        cell164.setCellStyle(styleAlignLeftBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row17 = sheet.createRow(16);
        HSSFCell cell171 = row17.createCell(4);
        cell171.setCellValue("Pay Refund Amount : ");
        cell171.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(4);
        //               sheet.addMergedRegion(CellRangeAddress.valueOf("A17:E17"));
        HSSFCell cell172 = row17.createCell(5);
        cell172.setCellValue(df.format(sumPayRefundAmount));
        cell172.setCellStyle(styleAlignRight);
        row17.createCell(7).setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(5);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F17:H17"));
        HSSFCell cell173 = row17.createCell(9);
        cell173.setCellStyle(styleAlignRightBorderLeft);
        cell173.setCellValue("");
        sheet.autoSizeColumn(9);
        row9.createCell(10).setCellValue("");
        HSSFCell cell174 = row17.createCell(11);
        cell174.setCellValue(df.format(vatComPay));
        cell174.setCellStyle(styleAlignRightBorderRight);
        sheet.autoSizeColumn(11);
        HSSFRow row18 = sheet.createRow(17);
        HSSFCell cell181 = row18.createCell(0);
        row18.createCell(1).setCellStyle(styleBorderBottom);
        row18.createCell(2).setCellStyle(styleBorderBottom);
        row18.createCell(3).setCellStyle(styleBorderBottom);
        row18.createCell(4).setCellStyle(styleBorderBottom);
        row18.createCell(5).setCellStyle(styleBorderBottom);
        row18.createCell(6).setCellStyle(styleBorderBottom);
        row18.createCell(7).setCellStyle(styleAlignRightBorderBottomRight);
        cell181.setCellStyle(styleBorderBottom);
        sheet.autoSizeColumn(0);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A18:H18"));
        HSSFCell cell182 = row18.createCell(9);
        cell182.setCellStyle(styleAlignRightBorderBottomLeft);
        cell182.setCellValue("");
        sheet.autoSizeColumn(9);
        row18.createCell(10).setCellStyle(styleBorderBottom);
        HSSFCell cell183 = row18.createCell(11);
        cell183.setCellValue("");
        cell183.setCellStyle(styleAlignRightBorderBottomRight);
        sheet.autoSizeColumn(11);
        HSSFRow row20 = sheet.createRow(19);
        HSSFCell cell201 = row20.createCell(0);
        cell201.setCellValue(" Total Com : ");
        cell201.setCellStyle(styleAlignRightBorderTopBottom);
        sheet.autoSizeColumn(0);
        HSSFCell cell1202 = row20.createCell(1);
        cell1202.setCellValue(df.format(totalCom));
        cell1202.setCellStyle(styleAlignRightBorderTopBottom);
        row20.createCell(2).setCellStyle(styleAlignRightBorderTopBottom);
        row20.createCell(3).setCellStyle(styleAlignRightBorderTopBottom);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B20:D20"));
        sheet.autoSizeColumn(1);
        HSSFCell cell1203 = row20.createCell(4);
        cell1203.setCellValue("Balance Payment : ");
        cell1203.setCellStyle(styleAlignRightBorderTopBottom);
        sheet.autoSizeColumn(4);
        HSSFCell cell1204 = row20.createCell(5);
        cell1204.setCellValue(df.format(balancePayment));
        cell1204.setCellStyle(styleAlignRightBorderTopBottom);
        sheet.autoSizeColumn(5);
        row20.createCell(6).setCellStyle(styleAlignRightBorderTopBottom);
        row20.createCell(7).setCellStyle(styleAlignRightBorderTopBottom);
        sheet.addMergedRegion(CellRangeAddress.valueOf("F20:H20"));
        HSSFCell cell1205 = row20.createCell(8);
        cell1205.setCellStyle(styleAlignRightBorderTopBottom);
        cell1205.setCellValue(df.format(midValue));
        sheet.autoSizeColumn(8);
        row20.createCell(9).setCellStyle(styleAlignRightBorderTopBottom);
        sheet.addMergedRegion(CellRangeAddress.valueOf("I20:J20"));
        HSSFCell cell206 = row20.createCell(10);
        cell206.setCellValue(df.format(checkResult));
        cell206.setCellStyle(styleAlignRightBorderTopBottom);
        sheet.autoSizeColumn(10);
        sheet.addMergedRegion(CellRangeAddress.valueOf("K20:L20"));
        row20.createCell(11).setCellStyle(styleAlignRightBorderTopBottomRight);
        HSSFRow row21 = sheet.createRow(20);
        HSSFCell cell1211 = row21.createCell(9);
        cell1211.setCellStyle(styleAlignRight);
        cell1211.setCellValue("Witholding Tax : ");
        sheet.autoSizeColumn(9);
        HSSFCell cell212 = row21.createCell(10);
        cell212.setCellValue(df.format(withHoldingTax));
        cell212.setCellStyle(styleAlignRight);
        sheet.autoSizeColumn(10);
        sheet.addMergedRegion(CellRangeAddress.valueOf("K21:L21"));
    }
    // Sheet Detail (2)************************************************************************************************
    // set Header Report (Row 1)
    HSSFCellStyle styleC11 = wb.createCellStyle();
    HSSFRow row01 = sheet1.createRow(0);
    HSSFCell cell01 = row01.createCell(0);
    cell01.setCellValue("Bill Agent Air");
    styleC11.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell01.setCellStyle(styleC11);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("A1:F1"));

    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);

    // Row 2
    HSSFRow row02 = sheet1.createRow(1);
    HSSFCell cell021 = row02.createCell(0);
    cell021.setCellValue("Agent : ");
    cell021.setCellStyle(styleC21);
    HSSFCell cell022 = row02.createCell(1);
    cell022.setCellValue(bil.getAgentPage());
    cell022.setCellStyle(styleC22);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("B2:D2"));
    HSSFCell cell023 = row02.createCell(4);
    cell023.setCellValue("Print By : ");
    cell023.setCellStyle(styleC21);
    HSSFCell cell024 = row02.createCell(5);
    cell024.setCellValue(bil.getPrintbyPage());
    cell024.setCellStyle(styleC22);

    // Row 3
    HSSFRow row03 = sheet1.createRow(2);
    HSSFCell cell031 = row03.createCell(0);
    cell031.setCellValue("Issue Date : ");
    cell031.setCellStyle(styleC21);
    HSSFCell cell032 = row03.createCell(1);
    cell032.setCellValue(bil.getIssuedatePage());
    cell032.setCellStyle(styleC22);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
    HSSFCell cell033 = row03.createCell(4);
    cell033.setCellValue("Page : ");
    cell033.setCellStyle(styleC21);
    HSSFCell cell034 = row03.createCell(5);
    cell034.setCellValue("1");
    cell034.setCellStyle(styleC22);

    // Row 4
    HSSFRow row04 = sheet1.createRow(3);
    HSSFCell cell041 = row04.createCell(0);
    cell041.setCellValue("Invoice Date : ");
    cell041.setCellStyle(styleC21);
    HSSFCell cell042 = row04.createCell(1);
    cell042.setCellValue(bil.getInvoicedatePage());
    cell042.setCellStyle(styleC22);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));

    // Row 5
    HSSFRow row05 = sheet1.createRow(4);
    HSSFCell cell051 = row05.createCell(0);
    cell051.setCellValue("Payment Type : ");
    cell051.setCellStyle(styleC21);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));
    HSSFCell cell052 = row05.createCell(1);
    cell052.setCellValue(bil.getPaymenttypePage());
    cell052.setCellStyle(styleC22);

    // Header Table
    HSSFRow row6 = sheet1.createRow(8);
    HSSFCell cell61 = row6.createCell(0);
    cell61.setCellValue("Invoice No.");
    cell61.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(0);
    HSSFCell cell62 = row6.createCell(1);
    cell62.setCellValue("Invoice Date");
    cell62.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(1);
    HSSFCell cell63 = row6.createCell(2);
    cell63.setCellValue("Customer");
    sheet1.autoSizeColumn(2);
    cell63.setCellStyle(styleAlignRightBorderAllHeaderTable);
    HSSFCell cell64 = row6.createCell(3);
    cell64.setCellValue("Ticket No.");
    cell64.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(3);
    HSSFCell cell65 = row6.createCell(4);
    cell65.setCellValue("Rounting");
    cell65.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(4);
    HSSFCell cell66 = row6.createCell(5);
    cell66.setCellValue("Sale Price");
    cell66.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(5);
    HSSFCell cell67 = row6.createCell(6);
    cell67.setCellValue("Net");
    cell67.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(6);
    HSSFCell cell68 = row6.createCell(7);
    cell68.setCellValue("Service");
    cell68.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(7);
    HSSFCell cell69 = row6.createCell(8);
    cell69.setCellValue("Vat");
    cell69.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(8);
    HSSFCell cell70 = row6.createCell(9);
    cell70.setCellValue("Amount Air");
    cell70.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(9);
    HSSFCell cell71 = row6.createCell(10);
    cell71.setCellValue("Com pay");
    cell71.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(10);
    HSSFCell cell72 = row6.createCell(11);
    cell72.setCellValue("    Vat    ");
    cell72.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(11);
    HSSFCell cell73 = row6.createCell(12);
    cell73.setCellValue("    Receive    ");
    cell73.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(11);

    //Detail of Table
    for (int r = 0; r < listAgent.size(); r++) {
        System.out.println("Size " + (r) + " : " + listAgent.get(r).getAgentname());
    }

    int count = 9 + listAgent.size();
    int start = 11;
    int end = 0;
    int num = 0;
    if (listAgent != null && listAgent.size() != 0) {
        for (int r = 9; r < count; r++) {
            if (num <= (listAgent.size() - 1)) {
                if (num != 0) { // Check not row first
                    String temp = listAgent.get(num - 1).getAgentname();
                    if (temp.equals(listAgent.get(num).getAgentname())) { // equal type   
                        //                        System.out.println("Num : " + num + " Last Row : " + (listAgent.size()-1));
                        if (num != (listAgent.size() - 1)) { // check not last row
                            HSSFRow row = sheet1.createRow(r);
                            createCell(row, listAgent, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll);
                            sheet1.autoSizeColumn(13);
                            num++;
                        } else { // last row
                            end = r + 1;
                            //                            System.out.println("Num : " + num + " Last Row : " + (listAgent.size()-1));
                            //                            System.out.println("Start : " + start +  " End  : " + end);
                            //                            System.out.println("Last");
                            HSSFRow row = sheet1.createRow(r);
                            createCell(row, listAgent, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll);
                            sheet1.autoSizeColumn(13);
                            num++;

                            // total
                            int rowstart = r + 1;
                            int rowend = r + 2;
                            variableTotal(start, end, rowstart, rowend, sheet1, styleNumber,
                                    styleNumberBorderRight);
                            HSSFRow rowT = sheet1.createRow(r + 3);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleAlignRightBorderBottomRight);
                        }
                    } else { // not equal type
                        if (num == (listAgent.size() - 1)) { // check  last row
                            end = r + 1;
                            //                            System.out.println("Num : " + num + " Last Row : " + (listAgent.size()-1));
                            //                            System.out.println("Start : " + start +  " End  : " + end);
                            //                            System.out.println("Last");
                            HSSFRow row = sheet1.createRow(r);
                            createCell(row, listAgent, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll);
                            sheet1.autoSizeColumn(13);
                            num++;
                            // total
                            int rowstart = r + 1;
                            int rowend = r + 2;
                            variableTotal(start, end, rowstart, rowend, sheet1, styleNumber,
                                    styleNumberBorderRight);
                            end = r + 1;
                            HSSFRow rowT = sheet1.createRow(r + 3);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleAlignRightBorderBottomRight);
                        } else {
                            end = r;
                            //                                System.out.println("Start : " + start +  " End  : " + end);
                            //                                System.out.println("Num : " + num + " Last Row : " + (listAgent.size()-1));
                            // total
                            int rowstart = r;
                            int rowend = r + 1;
                            variableTotal(start, end, rowstart, rowend, sheet1, styleNumber,
                                    styleNumberBorderRight);
                            HSSFRow rowT = sheet1.createRow(r + 2);
                            rowT.createCell(0).setCellStyle(styleBorderBottom);
                            rowT.createCell(1).setCellStyle(styleBorderBottom);
                            rowT.createCell(2).setCellStyle(styleBorderBottom);
                            rowT.createCell(3).setCellStyle(styleBorderBottom);
                            rowT.createCell(4).setCellStyle(styleBorderBottom);
                            rowT.createCell(5).setCellStyle(styleBorderBottom);
                            rowT.createCell(6).setCellStyle(styleBorderBottom);
                            rowT.createCell(7).setCellStyle(styleBorderBottom);
                            rowT.createCell(8).setCellStyle(styleBorderBottom);
                            rowT.createCell(9).setCellStyle(styleBorderBottom);
                            rowT.createCell(10).setCellStyle(styleBorderBottom);
                            rowT.createCell(11).setCellStyle(styleBorderBottom);
                            rowT.createCell(12).setCellStyle(styleAlignRightBorderBottomRight);
                            // Start New Row (Group)
                            start = end + 5;
                            HSSFRow row0 = sheet1.createRow(r + 3);
                            HSSFCell cell = row0.createCell(0);
                            cell.setCellValue(listAgent.get(num).getAgentname());
                            //                                    cell.setCellStyle(styleAlignRightBorderAll);
                            row0.createCell(12).setCellStyle(styleAlignRightBorderAll);
                            String add = "A" + (r + 4) + ":M" + (r + 4) + "";
                            //                                System.out.println("Add : " + add);
                            sheet1.addMergedRegion(CellRangeAddress.valueOf(add));
                            HSSFRow row122 = sheet1.createRow(r + 4);
                            createCell(row122, listAgent, num, styleAlignRightBorderAllNumber,
                                    styleAlignRightBorderAll);
                            sheet1.autoSizeColumn(13);
                            num++;
                            count = count + 4;
                            r = r + 4;
                        }
                    }
                } else { // row first
                    //                        System.out.println("Num : " + num + " Last Row : " + (listAgent.size()-1));

                    HSSFRow row0 = sheet1.createRow(r);
                    HSSFCell cell = row0.createCell(0);
                    cell.setCellValue(listAgent.get(num).getAgentname());
                    //                            cell.setCellStyle(styleAlignRightBorderAll);
                    row0.createCell(12).setCellStyle(styleAlignRightBorderAll);
                    String add = "A" + (r + 1) + ":M" + (r + 1) + "";
                    //                        System.out.println("Add : " + add);
                    sheet1.addMergedRegion(CellRangeAddress.valueOf(add));

                    HSSFRow row = sheet1.createRow(r + 1);
                    createCell(row, listAgent, num, styleAlignRightBorderAllNumber, styleAlignRightBorderAll);
                    sheet1.autoSizeColumn(13);
                    num = num + 1;
                    count = count + 1;
                    r = r + 1;
                }
            }
            for (int i = 0; i < listAgent.size(); i++) {
                sheet1.autoSizeColumn(i);
            }
        }
    }

    //****************************************************************************************************************      
    // set Header Report (Row 1)
    HSSFCellStyle styleHeader03 = wb.createCellStyle();
    HSSFRow row311 = sheet2.createRow(0);
    HSSFCell cell311 = row311.createCell(0);
    cell311.setCellValue("Refund");
    styleHeader03.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell311.setCellStyle(styleHeader03);
    sheet2.addMergedRegion(CellRangeAddress.valueOf("A1:M1"));

    BillAirAgentRefund bill = new BillAirAgentRefund();
    if ((listAgentRefund != null) && (listAgentRefund.size() != 0)) {
        bill = (BillAirAgentRefund) listAgentRefund.get(0);
    }
    // Row 2
    HSSFRow row32 = sheet2.createRow(1);
    HSSFCell cell321 = row32.createCell(0);
    cell321.setCellValue("Agent : ");
    cell321.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell322 = row32.createCell(1);
    cell322.setCellValue(bill.getAgentPage());
    cell322.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell323 = row32.createCell(2);
    cell323.setCellValue("Print : ");
    cell323.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell324 = row32.createCell(3);
    cell324.setCellValue(bill.getPrintbyPage());
    cell324.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);

    // Row 3
    HSSFRow row33 = sheet2.createRow(2);
    HSSFCell cell331 = row33.createCell(0);
    cell331.setCellValue("Refund Payment Date : ");
    cell331.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell332 = row33.createCell(1);
    cell332.setCellValue(bill.getRefunddatePage());
    cell332.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell333 = row33.createCell(2);
    cell333.setCellValue("Page : ");
    cell333.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell334 = row33.createCell(3);
    cell334.setCellValue("1");
    cell334.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);

    // Header Table
    HSSFRow row39 = sheet2.createRow(4);

    HSSFCell cell396 = row39.createCell(0);
    cell396.setCellValue("Refund No");
    cell396.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(0);

    HSSFCell cell399 = row39.createCell(1);
    cell399.setCellValue("Date Receive");
    cell399.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(1);

    HSSFCell cell3104 = row39.createCell(2);
    cell3104.setCellValue("Passenger");
    cell3104.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(2);

    HSSFCell cell3105 = row39.createCell(3);
    cell3105.setCellValue("Air");
    cell3105.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(3);

    HSSFCell cell3106 = row39.createCell(4);
    cell3106.setCellValue("Doc No");
    cell3106.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(4);

    HSSFCell cell3107 = row39.createCell(5);
    cell3107.setCellValue("Ref No");
    cell3107.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(5);

    HSSFCell cell3108 = row39.createCell(6);
    cell3108.setCellValue("Amount Receive");
    cell3108.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(6);

    HSSFCell cell3109 = row39.createCell(7);
    cell3109.setCellValue("Refund Change");
    cell3109.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(7);

    HSSFCell cell3110 = row39.createCell(8);
    cell3110.setCellValue("Amount_pay");
    cell3110.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(8);

    HSSFCell cell3111 = row39.createCell(9);
    cell3111.setCellValue("Comm Rcc");
    cell3111.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(9);

    HSSFCell cell3116 = row39.createCell(10);
    cell3116.setCellValue("  Vat    ");
    cell3116.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(10);

    int count2 = 4 + listAgentRefund.size();
    int startrefund = listAgentRefund.size();
    int endrefund = 5 + listAgentRefund.size();
    //            System.out.println("Start Refund : " + startrefund + " End Refund : " + endrefund +" Size : " + listAgentRefund.size() );

    if (listAgentRefund != null && listAgentRefund.size() != 0) {
        for (int r = 5; r <= count2; r++) {
            HSSFRow row = sheet2.createRow(r);
            HSSFCell cell00 = row.createCell(0);
            cell00.setCellValue(listAgentRefund.get(r - 5).getRefundno());
            cell00.setCellStyle(styleDetailTable);
            HSSFCell cell2 = row.createCell(1);
            cell2.setCellValue(listAgentRefund.get(r - 5).getReceivedate());
            cell2.setCellStyle(styleDetailTable);
            HSSFCell cell13 = row.createCell(2);
            cell13.setCellValue(listAgentRefund.get(r - 5).getPassenger());
            cell13.setCellStyle(styleDetailTable);
            HSSFCell cell14 = row.createCell(3);
            cell14.setCellValue(listAgentRefund.get(r - 5).getAir());
            cell14.setCellStyle(styleDetailTable);
            HSSFCell cell15 = row.createCell(4);
            cell15.setCellValue(listAgentRefund.get(r - 5).getDocno());
            cell15.setCellStyle(styleDetailTable);
            HSSFCell cell16 = row.createCell(5);
            cell16.setCellValue(listAgentRefund.get(r - 5).getRefno());
            cell16.setCellStyle(styleDetailTable);
            HSSFCell cell17 = row.createCell(6);
            BigDecimal amountreceive = new BigDecimal(
                    "".equals(listAgentRefund.get(r - 5).getAmount_receive()) ? "0"
                            : listAgentRefund.get(r - 5).getAmount_receive());
            cell17.setCellValue(
                    (amountreceive != null) ? amountreceive.doubleValue() : new BigDecimal("0").doubleValue());
            cell17.setCellStyle(styleDetailTableNumber);
            HSSFCell cell18 = row.createCell(7);
            BigDecimal refundchange = new BigDecimal(
                    "".equals(listAgentRefund.get(r - 5).getRefundchange()) ? "0"
                            : listAgentRefund.get(r - 5).getRefundchange());
            cell18.setCellValue(
                    (refundchange != null) ? refundchange.doubleValue() : new BigDecimal("0").doubleValue());
            cell18.setCellStyle(styleDetailTableNumber);
            HSSFCell cell19 = row.createCell(8);
            BigDecimal amountpay = new BigDecimal("".equals(listAgentRefund.get(r - 5).getAmountpay()) ? "0"
                    : listAgentRefund.get(r - 5).getAmountpay());
            cell19.setCellValue(
                    (amountpay != null) ? amountpay.doubleValue() : new BigDecimal("0").doubleValue());
            cell19.setCellStyle(styleDetailTableNumber);
            HSSFCell cell20 = row.createCell(9);
            BigDecimal comrec = new BigDecimal("".equals(listAgentRefund.get(r - 5).getComm_rec()) ? "0"
                    : listAgentRefund.get(r - 5).getComm_rec());
            cell20.setCellValue((comrec != null) ? comrec.doubleValue() : new BigDecimal("0").doubleValue());
            cell20.setCellStyle(styleDetailTableNumber);
            HSSFCell cell2205 = row.createCell(10);
            BigDecimal vat = new BigDecimal(
                    "".equals(listAgentRefund.get(r - 5).getVat()) ? "0" : listAgentRefund.get(r - 5).getVat());
            cell2205.setCellValue((vat != null) ? vat.doubleValue() : new BigDecimal("0").doubleValue());
            cell2205.setCellStyle(styleDetailTableNumber);
            for (int i = 0; i < 20; i++) {
                sheet2.autoSizeColumn(i);
            }
        }
        String sumAmountReceive = "SUM(G" + startrefund + ":G" + endrefund + ")";
        String sumRefundChange = "SUM(H" + startrefund + ":H" + endrefund + ")";
        String sumAmount_pay = "SUM(I" + startrefund + ":I" + endrefund + ")";
        String sumCommRcc = "SUM(J" + startrefund + ":J" + endrefund + ")";
        String sumVat = "SUM(K" + startrefund + ":K" + endrefund + ")";

        HSSFRow rowTotalRefund = sheet2.createRow(count2 + 1);
        rowTotalRefund.createCell(0).setCellStyle(styleAlignRightBorderAll);
        rowTotalRefund.createCell(1).setCellStyle(styleAlignRightBorderAll);
        rowTotalRefund.createCell(2).setCellStyle(styleAlignRightBorderAll);
        rowTotalRefund.createCell(3).setCellStyle(styleAlignRightBorderAll);
        rowTotalRefund.createCell(4).setCellStyle(styleAlignRightBorderAll);
        HSSFCell cell4 = rowTotalRefund.createCell(5);
        cell4.setCellValue("TOTAL");
        cell4.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet2.autoSizeColumn(5);
        HSSFCell cell5 = rowTotalRefund.createCell(6);
        cell5.setCellFormula(sumAmountReceive);
        cell5.setCellStyle(styleAlignRightBorderAllNumber);
        sheet2.autoSizeColumn(6);
        HSSFCell cell7 = rowTotalRefund.createCell(7);
        cell7.setCellFormula(sumRefundChange);
        cell7.setCellStyle(styleAlignRightBorderAllNumber);
        sheet2.autoSizeColumn(7);
        HSSFCell cell9 = rowTotalRefund.createCell(8);
        cell9.setCellFormula(sumAmount_pay);
        cell9.setCellStyle(styleAlignRightBorderAllNumber);
        sheet2.autoSizeColumn(8);
        HSSFCell cell11 = rowTotalRefund.createCell(9);
        cell11.setCellFormula(sumCommRcc);
        cell11.setCellStyle(styleAlignRightBorderAllNumber);
        sheet2.autoSizeColumn(9);
        HSSFCell cell13 = rowTotalRefund.createCell(10);
        cell13.setCellFormula(sumVat);
        cell13.setCellStyle(styleAlignRightBorderAllNumber);
        sheet2.autoSizeColumn(10);

    } else {
        HSSFRow row55 = sheet2.createRow(5);

        HSSFCell cell55 = row55.createCell(0);
        cell55.setCellValue("No Data");
        sheet2.autoSizeColumn(0);
    }
}

From source file:com.smi.travel.controller.excel.checking.airticket.CheckingAirOthersummary.java

private void genTicketProfitLossReport(HSSFWorkbook wb, List ticketProfitLoss) {
    String sheetName = "Sheet1";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);

    TicketProfitLoss dataheader = new TicketProfitLoss();
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    HSSFDataFormat currency = wb.createDataFormat();
    // Set align Text
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);

    System.out.println(" ticketProfitLoss.size() " + ticketProfitLoss.size());
    if (ticketProfitLoss != null && ticketProfitLoss.size() != 0) {
        dataheader = (TicketProfitLoss) ticketProfitLoss.get(0);

        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cellStart = row1.createCell(0);
        cellStart.setCellValue("Ticket Profit Loss");
        styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
        cellStart.setCellStyle(styleC1);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A1:F1"));

        // Row 2/*from   w ww . j ava 2  s.  co m*/
        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("Invoice Date From : " + dataheader.getInvoicedatefrom() + " To : "
                + dataheader.getInvoicedateto());
        cell21.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A2:F2"));

        // Row 3
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Print by : " + dataheader.getPrintby());
        cell31.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A3:F3"));
        //        HSSFCell cell32 = row3.createCell(4);
        //        cell32.setCellValue("Print on : "+dataheader.getPrinton());
        //        cell32.setCellStyle(styleC22);
        //        sheet.addMergedRegion(CellRangeAddress.valueOf("C3:D3"));
        //        HSSFCell cell33 = row3.createCell(4);
        //        cell33.setCellValue("Print on : ");
        //        cell33.setCellStyle(styleC21);
        //        HSSFCell cell34 = row3.createCell(5);
        //        cell34.setCellValue(dataheader.getPrinton());
        //        cell34.setCellStyle(styleC22);
        //        sheet.addMergedRegion(CellRangeAddress.valueOf("E3:F3"));

        //Row 4
        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Print on : " + dataheader.getPrinton());
        cell41.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("A4:F4"));

        // Header Table
        HSSFCellStyle styleC3Center = wb.createCellStyle();
        styleC3Center.setFont(excelFunction.getHeaderTable(wb.createFont()));
        styleC3Center.setAlignment(styleC3Center.ALIGN_CENTER);
        styleC3Center.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        styleC3Center.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        styleC3Center.setBorderRight(HSSFCellStyle.BORDER_THIN);
        styleC3Center.setBorderTop(HSSFCellStyle.BORDER_THIN);
        HSSFRow row6 = sheet.createRow(5);
        HSSFCell cell61 = row6.createCell(0);
        cell61.setCellValue("");
        cell61.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(0);
        HSSFCell cell62 = row6.createCell(1);
        cell62.setCellValue("Inv No.");
        cell62.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(1);
        HSSFCell cell63 = row6.createCell(2);
        cell63.setCellValue("Date");
        cell63.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(2);
        HSSFCell cell64 = row6.createCell(3);
        cell64.setCellValue("Dep");
        cell64.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(3);
        HSSFCell cell651 = row6.createCell(4);
        cell651.setCellValue("Agent Name");
        cell651.setCellStyle(styleC3Center);
        sheet.addMergedRegion(CellRangeAddress.valueOf("E6:H6"));
        HSSFCell cell652 = row6.createCell(5);
        cell652.setCellStyle(styleC3Center);
        HSSFCell cell653 = row6.createCell(6);
        cell653.setCellStyle(styleC3Center);
        HSSFCell cell654 = row6.createCell(7);
        cell654.setCellStyle(styleC3Center);
        HSSFCell cell66 = row6.createCell(8);
        cell66.setCellValue("Type");
        cell66.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(8);
        HSSFCell cell67 = row6.createCell(9);
        cell67.setCellValue("Rou");
        cell67.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(9);
        HSSFCell cell68 = row6.createCell(10);
        cell68.setCellValue("Pax");
        cell68.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(10);
        HSSFCell cell69 = row6.createCell(11);
        cell69.setCellValue("Air");
        cell69.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(11);
        HSSFCell cell610 = row6.createCell(12);
        cell610.setCellValue("Doc No.");
        cell610.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(12);
        HSSFCell cell611 = row6.createCell(13);
        cell611.setCellValue("Issue Date");
        cell611.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(13);
        HSSFCell cell612 = row6.createCell(14);
        cell612.setCellValue("Comm");
        cell612.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(14);
        HSSFCell cell613 = row6.createCell(15);
        cell613.setCellValue("Vat");
        cell613.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(15);
        HSSFCell cell614 = row6.createCell(16);
        cell614.setCellValue("Total");
        cell614.setCellStyle(styleC3Center);
        sheet.autoSizeColumn(16);
    }
    //Detail of Table
    int count = 6;
    HSSFCellStyle styleC23 = wb.createCellStyle();
    styleC23.setAlignment(styleC22.ALIGN_CENTER);
    styleC23.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC23.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC23.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC23.setWrapText(true);
    styleC23.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    HSSFCellStyle styleC24 = wb.createCellStyle();
    styleC24.setAlignment(styleC24.ALIGN_LEFT);
    styleC24.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC24.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC24.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC24.setWrapText(true);
    styleC24.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    HSSFCellStyle styleC25 = wb.createCellStyle();
    styleC25.setAlignment(styleC25.ALIGN_RIGHT);
    styleC25.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC25.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC25.setDataFormat(currency.getFormat("#,##0.00"));
    styleC25.setWrapText(true);
    styleC25.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    for (int i = 0; i < ticketProfitLoss.size(); i++) {
        TicketProfitLoss data = (TicketProfitLoss) ticketProfitLoss.get(i);
        HSSFRow row = sheet.createRow(count + i);
        HSSFCell cell0 = row.createCell(0);
        cell0.setCellValue(data.getNo());
        cell0.setCellStyle(styleC23);
        sheet.autoSizeColumn(0);
        HSSFCell cell1 = row.createCell(1);
        cell1.setCellValue(data.getInvno());
        cell1.setCellStyle(styleC23);
        sheet.autoSizeColumn(1);
        HSSFCell cell2 = row.createCell(2);
        cell2.setCellValue(data.getDate());
        cell2.setCellStyle(styleC23);
        sheet.autoSizeColumn(2);
        HSSFCell cell3 = row.createCell(3);
        cell3.setCellValue(data.getDepartment());
        cell3.setCellStyle(styleC23);
        sheet.autoSizeColumn(3);
        //             String air = data.getDocno().substring(0, 4);
        //             String doc = data.getDocno().substring(4);
        //             System.out.println("Air : " + air + "  Doc : " + doc);
        HSSFCell cell4 = row.createCell(4);
        cell4.setCellValue(data.getAgentname());
        cell4.setCellStyle(styleC24);
        sheet.addMergedRegion(CellRangeAddress.valueOf("E" + (count + i + 1) + ":H" + (count + i + 1)));
        HSSFCell cell5 = row.createCell(5);
        cell5.setCellStyle(styleC24);
        HSSFCell cell6 = row.createCell(6);
        cell6.setCellStyle(styleC24);
        HSSFCell cell7 = row.createCell(7);
        cell7.setCellStyle(styleC24);
        HSSFCell cell18 = row.createCell(8);
        cell18.setCellValue(data.getType());
        cell18.setCellStyle(styleC23);
        sheet.autoSizeColumn(8);
        HSSFCell cell9 = row.createCell(9);
        cell9.setCellValue(data.getRount());
        cell9.setCellStyle(styleC23);
        sheet.autoSizeColumn(9);
        HSSFCell cell10 = row.createCell(10);
        cell10.setCellValue(data.getPax());
        cell10.setCellStyle(styleC25);
        sheet.autoSizeColumn(10);
        HSSFCell cell11 = row.createCell(11);
        cell11.setCellValue(data.getAir());
        cell11.setCellStyle(styleC25);
        sheet.autoSizeColumn(11);
        HSSFCell cell12 = row.createCell(12);
        cell12.setCellValue((data.getDocno()).replaceAll(",", "\n"));
        cell12.setCellStyle(styleC23);
        sheet.autoSizeColumn(12);
        row.setHeightInPoints(
                (((((data.getDocno()).split(",")).length) + 1) * sheet.getDefaultRowHeightInPoints()));
        HSSFCell cell13 = row.createCell(13);
        cell13.setCellValue(data.getIssuedate());
        cell13.setCellStyle(styleC23);
        sheet.autoSizeColumn(13);
        HSSFCell cell14 = row.createCell(14);
        cell14.setCellValue(
                !"".equalsIgnoreCase(data.getLittlecomm()) ? new BigDecimal(data.getLittlecomm()).doubleValue()
                        : 0);
        cell14.setCellStyle(styleC25);
        sheet.autoSizeColumn(14);
        HSSFCell cell15 = row.createCell(15);
        cell15.setCellValue(
                !"".equalsIgnoreCase(data.getVat()) ? new BigDecimal(data.getVat()).doubleValue() : 0);
        cell15.setCellStyle(styleC25);
        sheet.autoSizeColumn(15);
        HSSFCell cell16 = row.createCell(16);
        cell16.setCellValue(
                !"".equalsIgnoreCase(data.getTotal()) ? new BigDecimal(data.getTotal()).doubleValue() : 0);
        cell16.setCellStyle(styleC25);
        sheet.autoSizeColumn(16);

        if (i == (ticketProfitLoss.size() - 1)) {
            row = sheet.createRow(count + i + 1);
            int count2 = count + i + 1;

            HSSFRow rowtotal = sheet.createRow(count2);
            String sumComm = "SUM(O" + 7 + ":O" + (count2) + ")";
            String sumVat = "SUM(P" + 7 + ":P" + (count2) + ")";
            String sumTotal = "SUM(Q" + 7 + ":Q" + (count2) + ")";
            sheet.addMergedRegion(CellRangeAddress.valueOf("A" + (count2 + 1) + ":N" + (count2 + 1)));
            HSSFCell cellTotal0 = rowtotal.createCell(0);
            cellTotal0.setCellValue("Total");
            cellTotal0.setCellStyle(styleC25);
            HSSFCell cellTotal = rowtotal.createCell(14);
            cellTotal.setCellFormula(sumComm);
            cellTotal.setCellStyle(styleC25);
            HSSFCell cellTotal2 = rowtotal.createCell(15);
            cellTotal2.setCellFormula(sumVat);
            cellTotal2.setCellStyle(styleC25);
            HSSFCell cellTotal3 = rowtotal.createCell(16);
            cellTotal3.setCellFormula(sumTotal);
            cellTotal3.setCellStyle(styleC25);
            for (int k = 1; k < 14; k++) {
                HSSFCell cellTotal1 = rowtotal.createCell(k);
                cellTotal1.setCellStyle(styleC25);
            }
            //                for(int k=0;k<16;k++){
            //                    HSSFCellStyle styleSum = wb.createCellStyle();
            //                    styleSum.setBorderTop(HSSFCellStyle.BORDER_THIN);
            //                    HSSFCell cellSum = row.createCell(k);                   
            //                    cellSum.setCellStyle(styleSum);
            //                }
        }
        //            for(int j =0;j<15;j++){
        //                if(j==4){
        //                    sheet.addMergedRegion(CellRangeAddress.valueOf("E"+(count + i)+":G"+(count + i))); 
        //                }else{
        //                    sheet.autoSizeColumn(j); 
        //                }
        //                 
        //            }
    }

}

From source file:com.smi.travel.controller.excel.checking.airticket.CheckingAirOthersummary.java

private void getTicketSummaryCommission(HSSFWorkbook wb, List listTicketummaryCommission) {
    String sheetName = "Ticket_commission_detail_summary";// name of sheet
    String sheetName1 = "Ticket_commission_air_summary";
    String sheetName2 = "Ticket_commission_agent_summary";
    HSSFSheet sheet = wb.createSheet(sheetName);
    HSSFSheet sheet1 = wb.createSheet(sheetName1);
    HSSFSheet sheet2 = wb.createSheet(sheetName2);

    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    // Set align Text
    HSSFCellStyle styleAlignRight = wb.createCellStyle();
    styleAlignRight.setAlignment(styleAlignRight.ALIGN_RIGHT);
    HSSFCellStyle styleAlignLeft = wb.createCellStyle();
    styleAlignLeft.setAlignment(styleAlignLeft.ALIGN_LEFT);

    HSSFDataFormat currency = wb.createDataFormat();
    HSSFCellStyle styleNumber = wb.createCellStyle();
    styleNumber.setAlignment(styleNumber.ALIGN_RIGHT);
    styleNumber.setDataFormat(currency.getFormat("#,##0.00"));

    HSSFCellStyle styleNumberBorderRight = wb.createCellStyle();
    styleNumberBorderRight.setAlignment(styleNumberBorderRight.ALIGN_RIGHT);
    styleNumberBorderRight.setDataFormat(currency.getFormat("#,##0.00"));
    styleNumberBorderRight.setBorderRight(styleNumberBorderRight.BORDER_THIN);

    HSSFCellStyle styleBorderTop = wb.createCellStyle();
    styleBorderTop.setBorderTop(styleBorderTop.BORDER_THIN);

    HSSFCellStyle styleAlignRightBorderAllHeaderTable = wb.createCellStyle();
    styleAlignRightBorderAllHeaderTable.setFont(excelFunction.getHeaderTable(wb.createFont()));
    styleAlignRightBorderAllHeaderTable.setAlignment(styleAlignRightBorderAllHeaderTable.ALIGN_CENTER);
    styleAlignRightBorderAllHeaderTable.setBorderTop(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderBottom(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderRight(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    styleAlignRightBorderAllHeaderTable.setBorderLeft(styleAlignRightBorderAllHeaderTable.BORDER_THIN);
    // Header Table
    HSSFCellStyle styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);

    HSSFCellStyle styleDetailTableNumber = wb.createCellStyle();
    styleDetailTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleDetailTableNumber.setAlignment(styleDetailTableNumber.ALIGN_RIGHT);
    styleDetailTableNumber.setBorderLeft(styleDetailTableNumber.BORDER_THIN);
    styleDetailTableNumber.setBorderRight(styleDetailTableNumber.BORDER_THIN);

    HSSFCellStyle styleTotalTableNumber = wb.createCellStyle();
    styleTotalTableNumber.setDataFormat(currency.getFormat("#,##0.00"));
    styleTotalTableNumber.setAlignment(styleTotalTableNumber.ALIGN_RIGHT);
    styleTotalTableNumber.setBorderTop(styleTotalTableNumber.BORDER_THIN);
    styleTotalTableNumber.setBorderBottom(styleTotalTableNumber.BORDER_THIN);
    styleTotalTableNumber.setBorderRight(styleTotalTableNumber.BORDER_THIN);
    styleTotalTableNumber.setBorderLeft(styleTotalTableNumber.BORDER_THIN);

    HSSFCellStyle stylePaxNumber = wb.createCellStyle();
    stylePaxNumber.setDataFormat(currency.getFormat("#,##0"));
    stylePaxNumber.setAlignment(stylePaxNumber.ALIGN_CENTER);
    stylePaxNumber.setBorderRight(stylePaxNumber.BORDER_THIN);
    stylePaxNumber.setBorderLeft(stylePaxNumber.BORDER_THIN);

    HSSFCellStyle stylePaxNumberTotal = wb.createCellStyle();
    stylePaxNumberTotal.setDataFormat(currency.getFormat("#,##0"));
    stylePaxNumberTotal.setAlignment(stylePaxNumberTotal.ALIGN_CENTER);
    stylePaxNumberTotal.setBorderTop(stylePaxNumberTotal.BORDER_THIN);
    stylePaxNumberTotal.setBorderBottom(stylePaxNumberTotal.BORDER_THIN);
    stylePaxNumberTotal.setBorderRight(stylePaxNumberTotal.BORDER_THIN);
    stylePaxNumberTotal.setBorderLeft(stylePaxNumberTotal.BORDER_THIN);

    // set Header Report (Row 1)
    HSSFCellStyle styleHeader01 = wb.createCellStyle();
    HSSFRow row01 = sheet.createRow(0);//from ww w .  ja v a  2s. c om
    HSSFCell cell01 = row01.createCell(0);
    cell01.setCellValue("List summary commission");
    styleHeader01.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell01.setCellStyle(styleHeader01);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:M1"));

    List<ListTicketSummaryCommission> listSummaryCommission = listTicketummaryCommission;

    List<TicketSummaryCommissionView> listDetail = listSummaryCommission.get(0)
            .getTicketCommissionDetailSummary();
    List<TicketSummaryCommissionView> listAir = listSummaryCommission.get(0).getTicketCommissionAirSummary();
    List<TicketSummaryCommissionView> listAgent = listSummaryCommission.get(0)
            .getTicketCommissionAgentSummary();
    TicketSummaryCommissionView ticketDetail = (listDetail.size() > 0 ? listDetail.get(0)
            : new TicketSummaryCommissionView());
    TicketSummaryCommissionView ticketAir = (listAir.size() > 0 ? listAir.get(0)
            : new TicketSummaryCommissionView());
    TicketSummaryCommissionView ticketAgent = (listAgent.size() > 0 ? listAgent.get(0)
            : new TicketSummaryCommissionView());
    // Row 2
    HSSFRow row02 = sheet.createRow(1);
    HSSFCell cell021 = row02.createCell(0);
    cell021.setCellValue("Agent Name : ");
    cell021.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell022 = row02.createCell(1);
    cell022.setCellValue(ticketDetail.getAgentNamePage() != null && !"".equals(ticketDetail.getAgentNamePage())
            ? ticketDetail.getAgentNamePage()
            : "ALL");
    cell022.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    HSSFCell cell023 = row02.createCell(2);
    cell023.setCellValue("Issue date : ");
    cell023.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(2);
    HSSFCell cell024 = row02.createCell(3);
    cell024.setCellValue(
            ticketDetail.getIssuefromdatePage() != null && !"".equals(ticketDetail.getIssuefromdatePage())
                    ? ticketDetail.getIssuefromdatePage()
                    : "ALL");
    cell024.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(3);
    HSSFCell cell025 = row02.createCell(4);
    cell025.setCellValue("Print By : ");
    cell025.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell026 = row02.createCell(5);
    cell026.setCellValue(ticketDetail.getPrintbyPage() != null && !"".equals(ticketDetail.getPrintbyPage())
            ? ticketDetail.getPrintbyPage()
            : "ALL");
    cell026.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 3
    HSSFRow row03 = sheet.createRow(2);
    HSSFCell cell031 = row03.createCell(0);
    cell031.setCellValue("Type Routing : ");
    cell031.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell032 = row03.createCell(1);
    cell032.setCellValue(
            ticketDetail.getTypeRoutingPage() != null && !"".equals(ticketDetail.getTypeRoutingPage())
                    ? ticketDetail.getTypeRoutingPage()
                    : "ALL");
    cell032.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    HSSFCell cell033 = row03.createCell(2);
    cell033.setCellValue("Over Comm Date : ");
    cell033.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(2);
    HSSFCell cell034 = row03.createCell(3);
    cell034.setCellValue(
            ticketDetail.getOverfromdatePage() != null && !"".equals(ticketDetail.getOverfromdatePage())
                    ? ticketDetail.getOverfromdatePage()
                    : "ALL");
    cell034.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(3);
    HSSFCell cell035 = row03.createCell(4);
    cell035.setCellValue("Add Pay Date : ");
    cell035.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell036 = row03.createCell(5);
    cell036.setCellValue(
            ticketDetail.getAddpayfromdatePage() != null && !"".equals(ticketDetail.getAddpayfromdatePage())
                    ? ticketDetail.getAddpayfromdatePage()
                    : "ALL");
    cell036.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 4
    HSSFRow row04 = sheet.createRow(3);
    HSSFCell cell041 = row04.createCell(0);
    cell041.setCellValue("Air : ");
    cell041.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell042 = row04.createCell(1);
    cell042.setCellValue(
            ticketDetail.getAirlineCodePage() != null && !"".equals(ticketDetail.getAirlineCodePage())
                    ? ticketDetail.getAirlineCodePage()
                    : "ALL");
    cell042.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    HSSFCell cell043 = row04.createCell(2);
    cell043.setCellValue("Little Comm date : ");
    cell043.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(2);
    HSSFCell cell044 = row04.createCell(3);
    cell044.setCellValue(
            ticketDetail.getLittlefromdatePage() != null && !"".equals(ticketDetail.getLittlefromdatePage())
                    ? ticketDetail.getLittlefromdatePage()
                    : "ALL");
    cell044.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(3);
    HSSFCell cell045 = row04.createCell(4);
    cell045.setCellValue("Decrease Pay Date : ");
    cell045.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell046 = row04.createCell(5);
    cell046.setCellValue(ticketDetail.getDecreasepayfromdatePage() != null
            && !"".equals(ticketDetail.getDecreasepayfromdatePage()) ? ticketDetail.getDecreasepayfromdatePage()
                    : "ALL");
    cell046.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 5
    HSSFRow row05 = sheet.createRow(4);
    HSSFCell cell051 = row05.createCell(0);
    cell051.setCellValue("Routing Detail : ");
    cell051.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(0);
    HSSFCell cell052 = row05.createCell(1);
    cell052.setCellValue(
            ticketDetail.getRoutingDetailPage() != null && !"".equals(ticketDetail.getRoutingDetailPage())
                    ? ticketDetail.getRoutingDetailPage()
                    : "ALL");
    cell052.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(1);
    HSSFCell cell053 = row05.createCell(2);
    cell053.setCellValue("Agent Comm Rev Date : ");
    cell053.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(2);
    HSSFCell cell054 = row05.createCell(3);
    cell054.setCellValue(ticketDetail.getAgemtcomreceivefromdatePage() != null
            && !"".equals(ticketDetail.getAgemtcomreceivefromdatePage())
                    ? ticketDetail.getAgemtcomreceivefromdatePage()
                    : "ALL");
    cell054.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(3);
    HSSFCell cell055 = row05.createCell(4);
    cell055.setCellValue("Ticket No : ");
    cell055.setCellStyle(styleAlignRight);
    sheet.autoSizeColumn(4);
    HSSFCell cell056 = row05.createCell(5);
    cell056.setCellValue(
            ticketDetail.getTicketnoPagePage() != null && !"".equals(ticketDetail.getTicketnoPagePage())
                    ? ticketDetail.getTicketnoPagePage()
                    : "ALL");
    cell056.setCellStyle(styleAlignLeft);
    sheet.autoSizeColumn(5);

    // Row 6
    HSSFRow row06 = sheet.createRow(5);
    HSSFCell cell061 = row06.createCell(0);
    cell061.setCellValue("Sale Staff : ");
    cell061.setCellStyle(styleAlignRight);
    HSSFCell cell062 = row06.createCell(1);
    cell062.setCellValue(
            ticketDetail.getSalebyNamePage() != null && !"".equals(ticketDetail.getSalebyNamePage())
                    ? ticketDetail.getSalebyNamePage()
                    : "ALL");
    cell062.setCellStyle(styleAlignLeft);
    HSSFCell cell063 = row06.createCell(2);
    cell063.setCellValue("Refund Comm Date : ");
    cell063.setCellStyle(styleAlignRight);
    HSSFCell cell064 = row06.createCell(3);
    cell064.setCellValue(ticketDetail.getComrefundfromdatePage() != null
            && !"".equals(ticketDetail.getComrefundfromdatePage()) ? ticketDetail.getComrefundfromdatePage()
                    : "ALL");
    cell064.setCellStyle(styleAlignLeft);
    HSSFCell cell065 = row06.createCell(4);
    cell065.setCellValue("Ticket Comm Date : ");
    cell065.setCellStyle(styleAlignRight);
    HSSFCell cell066 = row06.createCell(5);
    cell066.setCellValue(ticketDetail.getTicketcomfromdatePage() != null
            && !"".equals(ticketDetail.getTicketcomfromdatePage()) ? ticketDetail.getTicketcomfromdatePage()
                    : "ALL");
    cell066.setCellStyle(styleAlignLeft);

    // Row 7
    HSSFRow row07 = sheet.createRow(6);
    HSSFCell cell071 = row07.createCell(0);
    cell071.setCellValue("Department : ");
    cell071.setCellStyle(styleAlignRight);
    HSSFCell cell072 = row07.createCell(1);
    cell072.setCellValue(
            ticketDetail.getDepartmentPage() != null && !"".equals(ticketDetail.getDepartmentPage())
                    ? ticketDetail.getDepartmentPage()
                    : "ALL");
    cell072.setCellStyle(styleAlignLeft);
    HSSFCell cell073 = row07.createCell(2);
    cell073.setCellValue("Invoice Date : ");
    cell073.setCellStyle(styleAlignRight);
    HSSFCell cell074 = row07.createCell(3);
    cell074.setCellValue(
            ticketDetail.getInvoicefromdatePage() != null && !"".equals(ticketDetail.getInvoicefromdatePage())
                    ? ticketDetail.getInvoicefromdatePage()
                    : "ALL");
    cell074.setCellStyle(styleAlignLeft);
    HSSFCell cell075 = row07.createCell(4);
    cell075.setCellValue("Print on : ");
    cell075.setCellStyle(styleAlignRight);
    HSSFCell cell076 = row07.createCell(5);
    cell076.setCellValue(ticketDetail.getPrintonPage() != null && !"".equals(ticketDetail.getPrintonPage())
            ? ticketDetail.getPrintonPage()
            : "ALL");
    cell076.setCellStyle(styleAlignLeft);

    // Row 8
    HSSFRow row08 = sheet.createRow(7);
    HSSFCell cell081 = row08.createCell(0);
    cell081.setCellValue("Term Pay : ");
    cell081.setCellStyle(styleAlignRight);
    HSSFCell cell082 = row08.createCell(1);
    cell082.setCellValue(ticketDetail.getTermPayPage() != null && !"".equals(ticketDetail.getTermPayPage())
            ? ticketDetail.getTermPayPage()
            : "ALL");
    cell082.setCellStyle(styleAlignLeft);
    HSSFCell cell083 = row08.createCell(2);
    cell083.setCellValue("Page : ");
    cell083.setCellStyle(styleAlignRight);
    HSSFCell cell084 = row08.createCell(3);
    cell084.setCellValue("1 ");
    cell084.setCellStyle(styleAlignLeft);

    // Header Table
    HSSFRow row09 = sheet.createRow(9);
    HSSFCell cell091 = row09.createCell(0);
    cell091.setCellValue("Inv No");
    cell091.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(0);

    HSSFCell cell092 = row09.createCell(1);
    cell092.setCellValue("Inv Date");
    cell092.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(1);

    HSSFCell cell093 = row09.createCell(2);
    cell093.setCellValue("Department");
    cell093.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(2);

    HSSFCell cell094 = row09.createCell(3);
    cell094.setCellValue("Staff");
    cell094.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(3);

    HSSFCell cell095 = row09.createCell(4);
    cell095.setCellValue("Term Pay");
    cell095.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(4);

    HSSFCell cell096 = row09.createCell(5);
    cell096.setCellValue("Agent");
    cell096.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(5);

    HSSFCell cell097 = row09.createCell(6);
    cell097.setCellValue("Type");
    cell097.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(6);

    HSSFCell cell0097 = row09.createCell(7);
    cell0097.setCellValue("Type Routing");
    cell0097.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(7);

    HSSFCell cell098 = row09.createCell(8);
    cell098.setCellValue("Buy");
    cell098.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(8);

    HSSFCell cell099 = row09.createCell(9);
    cell099.setCellValue("Pax");
    cell099.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(9);

    HSSFCell cell0100 = row09.createCell(10);
    cell0100.setCellValue("air");
    cell0100.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(10);

    HSSFCell cell0101 = row09.createCell(11);
    cell0101.setCellValue("Doc No");
    cell0101.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(11);

    HSSFCell cell0102 = row09.createCell(12);
    cell0102.setCellValue("Ref No");
    cell0102.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(12);

    HSSFCell cell103 = row09.createCell(13);
    cell103.setCellValue("Issue Date");
    cell103.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(13);

    HSSFCell cell0104 = row09.createCell(14);
    cell0104.setCellValue("Amount Wendy");
    cell0104.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(14);

    HSSFCell cell0105 = row09.createCell(15);
    cell0105.setCellValue("Amount Outbound");
    cell0105.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(15);

    HSSFCell cell0106 = row09.createCell(16);
    cell0106.setCellValue("Amount Inbound");
    cell0106.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(16);

    HSSFCell cell0107 = row09.createCell(17);
    cell0107.setCellValue("Amount Refund");
    cell0107.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(17);

    HSSFCell cell0108 = row09.createCell(18);
    cell0108.setCellValue("Amount Business Trip");
    cell0108.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(18);

    HSSFCell cell0109 = row09.createCell(19);
    cell0109.setCellValue("Amount Annual Leave");
    cell0109.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(19);

    HSSFCell cell0110 = row09.createCell(20);
    cell0110.setCellValue("Amount No Inv");
    cell0110.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(20);

    HSSFCell cell0111 = row09.createCell(21);
    cell0111.setCellValue("Sale");
    cell0111.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(21);

    HSSFCell cell0116 = row09.createCell(22);
    cell0116.setCellValue("Cost");
    cell0116.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(22);

    HSSFCell cell0112 = row09.createCell(23);
    cell0112.setCellValue("Over");
    cell0112.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(23);

    HSSFCell cell0113 = row09.createCell(24);
    cell0113.setCellValue("Add");
    cell0113.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(24);

    HSSFCell cell0114 = row09.createCell(25);
    cell0114.setCellValue("Dres");
    cell0114.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(25);

    HSSFCell cell0115 = row09.createCell(26);
    cell0115.setCellValue("Profit");
    cell0115.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(26);

    HSSFCell cell0117 = row09.createCell(27);
    cell0117.setCellValue("Comm");
    cell0117.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(27);

    HSSFCell cell0118 = row09.createCell(28);
    cell0118.setCellValue("Little");
    cell0118.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(28);

    HSSFCell cell0119 = row09.createCell(29);
    cell0119.setCellValue("Agent[Comm] Pay");
    cell0119.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(29);

    HSSFCell cell0130 = row09.createCell(30);
    cell0130.setCellValue("Agent[Comm] Receive");
    cell0130.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(30);

    HSSFCell cell0131 = row09.createCell(31);
    cell0131.setCellValue("Pay");
    cell0131.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(31);

    HSSFCell cell0132 = row09.createCell(32);
    cell0132.setCellValue("Net Comm Receive");
    cell0132.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet.autoSizeColumn(32);

    int count = 10 + listDetail.size();
    //        System.out.println(" listDetail.size() " + listDetail.size());
    //        System.out.println(" count " + count);
    if (listDetail != null && listDetail.size() != 0) {
        for (int r = 10; r < count; r++) {
            HSSFRow row = sheet.createRow(r);
            HSSFCell cell1 = row.createCell(0);
            cell1.setCellValue(listDetail.get(r - 10).getInvno());
            cell1.setCellStyle(styleDetailTable);
            HSSFCell cell2 = row.createCell(1);
            cell2.setCellValue(listDetail.get(r - 10).getInvdate());
            cell2.setCellStyle(styleDetailTable);
            HSSFCell cell3 = row.createCell(2);
            cell3.setCellValue(listDetail.get(r - 10).getDepartment());
            cell3.setCellStyle(styleDetailTable);
            HSSFCell cell4 = row.createCell(3);
            cell4.setCellValue(listDetail.get(r - 10).getOwner());
            cell4.setCellStyle(styleDetailTable);
            HSSFCell cell55 = row.createCell(4);
            cell55.setCellValue(listDetail.get(r - 10).getTermpay());
            cell55.setCellStyle(styleDetailTable);
            HSSFCell cell5 = row.createCell(5);
            cell5.setCellValue(listDetail.get(r - 10).getAgent());
            cell5.setCellStyle(styleDetailTable);
            HSSFCell cell6 = row.createCell(6);
            cell6.setCellValue(listDetail.get(r - 10).getType());
            cell6.setCellStyle(stylePaxNumber);
            HSSFCell cell07 = row.createCell(7);
            cell07.setCellValue(listDetail.get(r - 10).getRounting());
            cell07.setCellStyle(stylePaxNumber);
            HSSFCell cell7 = row.createCell(8);
            cell7.setCellValue(listDetail.get(r - 10).getBuy());
            cell7.setCellStyle(stylePaxNumber);
            HSSFCell cell8 = row.createCell(9);
            BigDecimal pax = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getPax()) ? "0" : listDetail.get(r - 10).getPax());
            cell8.setCellValue((pax != null) ? pax.doubleValue() : new BigDecimal("0").doubleValue());
            cell8.setCellStyle(stylePaxNumber);
            HSSFCell cell9 = row.createCell(10);
            cell9.setCellValue(listDetail.get(r - 10).getAir());
            cell9.setCellStyle(stylePaxNumber);
            HSSFCell cell10 = row.createCell(11);
            cell10.setCellValue(listDetail.get(r - 10).getDocno());
            cell10.setCellStyle(styleDetailTable);
            HSSFCell cell11 = row.createCell(12);
            cell11.setCellValue(listDetail.get(r - 10).getRefno());
            cell11.setCellStyle(styleDetailTable);
            HSSFCell cell12 = row.createCell(13);
            cell12.setCellValue(listDetail.get(r - 10).getIssuedate());
            cell12.setCellStyle(stylePaxNumber);
            HSSFCell cell13 = row.createCell(14);
            BigDecimal amountwendy = new BigDecimal("".equals(listDetail.get(r - 10).getAmountwendy()) ? "0"
                    : listDetail.get(r - 10).getAmountwendy());
            cell13.setCellValue(
                    (amountwendy != null) ? amountwendy.doubleValue() : new BigDecimal("0").doubleValue());
            cell13.setCellStyle(styleDetailTableNumber);
            HSSFCell cell14 = row.createCell(15);
            BigDecimal amountoutbound = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getAmountoutbound()) ? "0"
                            : listDetail.get(r - 10).getAmountoutbound());
            cell14.setCellValue((amountoutbound != null) ? amountoutbound.doubleValue()
                    : new BigDecimal("0").doubleValue());
            cell14.setCellStyle(styleDetailTableNumber);
            HSSFCell cell27 = row.createCell(16);
            BigDecimal amountinbound = new BigDecimal("".equals(listDetail.get(r - 10).getAmountinbound()) ? "0"
                    : listDetail.get(r - 10).getAmountinbound());
            cell27.setCellValue(
                    (amountinbound != null) ? amountinbound.doubleValue() : new BigDecimal("0").doubleValue());
            cell27.setCellStyle(styleDetailTableNumber);
            HSSFCell cell28 = row.createCell(17);
            BigDecimal amountref = new BigDecimal("".equals(listDetail.get(r - 10).getAmountrefund()) ? "0"
                    : listDetail.get(r - 10).getAmountrefund());
            cell28.setCellValue(
                    (amountref != null) ? amountref.doubleValue() : new BigDecimal("0").doubleValue());
            cell28.setCellStyle(styleDetailTableNumber);
            HSSFCell cell29 = row.createCell(18);
            BigDecimal amountbus = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getAmountbusinesstrip()) ? "0"
                            : listDetail.get(r - 10).getAmountbusinesstrip());
            cell29.setCellValue(
                    (amountbus != null) ? amountbus.doubleValue() : new BigDecimal("0").doubleValue());
            cell29.setCellStyle(styleDetailTableNumber);
            HSSFCell cell30 = row.createCell(19);
            BigDecimal amountann = new BigDecimal("".equals(listDetail.get(r - 10).getAmountannualleave()) ? "0"
                    : listDetail.get(r - 10).getAmountannualleave());
            cell30.setCellValue(
                    (amountann != null) ? amountann.doubleValue() : new BigDecimal("0").doubleValue());
            cell30.setCellStyle(styleDetailTableNumber);
            HSSFCell cell31 = row.createCell(20);
            BigDecimal amountnoinv = new BigDecimal("".equals(listDetail.get(r - 10).getAmountnoinvoice()) ? "0"
                    : listDetail.get(r - 10).getAmountnoinvoice());
            cell31.setCellValue(
                    (amountnoinv != null) ? amountnoinv.doubleValue() : new BigDecimal("0").doubleValue());
            cell31.setCellStyle(styleDetailTableNumber);
            HSSFCell cell15 = row.createCell(21);
            BigDecimal sale = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getSale()) ? "0" : listDetail.get(r - 10).getSale());
            cell15.setCellValue((sale != null) ? sale.doubleValue() : new BigDecimal("0").doubleValue());
            cell15.setCellStyle(styleDetailTableNumber);
            HSSFCell cell16 = row.createCell(22);
            BigDecimal cost = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getCost()) ? "0" : listDetail.get(r - 10).getCost());
            cell16.setCellValue((cost != null) ? cost.doubleValue() : new BigDecimal("0").doubleValue());
            cell16.setCellStyle(styleDetailTableNumber);
            HSSFCell cell17 = row.createCell(23);
            BigDecimal over = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getOver()) ? "0" : listDetail.get(r - 10).getOver());
            cell17.setCellValue((over != null) ? over.doubleValue() : new BigDecimal("0").doubleValue());
            cell17.setCellStyle(styleDetailTableNumber);
            HSSFCell cell18 = row.createCell(24);
            BigDecimal add = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getAdd()) ? "0" : listDetail.get(r - 10).getAdd());
            cell18.setCellValue((add != null) ? add.doubleValue() : new BigDecimal("0").doubleValue());
            cell18.setCellStyle(styleDetailTableNumber);
            HSSFCell cell19 = row.createCell(25);
            BigDecimal dres = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getDres()) ? "0" : listDetail.get(r - 10).getDres());
            cell19.setCellValue((dres != null) ? dres.doubleValue() : new BigDecimal("0").doubleValue());
            cell19.setCellStyle(styleDetailTableNumber);
            HSSFCell cell20 = row.createCell(26);
            BigDecimal profit = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getProfit()) ? "0" : listDetail.get(r - 10).getProfit());
            cell20.setCellValue((profit != null) ? profit.doubleValue() : new BigDecimal("0").doubleValue());
            cell20.setCellStyle(styleDetailTableNumber);
            HSSFCell cell25 = row.createCell(27);
            BigDecimal ticcom = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getTiccomm()) ? "0" : listDetail.get(r - 10).getTiccomm());
            cell25.setCellValue((ticcom != null) ? ticcom.doubleValue() : new BigDecimal("0").doubleValue());
            cell25.setCellStyle(styleDetailTableNumber);
            HSSFCell cell21 = row.createCell(28);
            BigDecimal little = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getLittle()) ? "0" : listDetail.get(r - 10).getLittle());
            cell21.setCellValue((little != null) ? little.doubleValue() : new BigDecimal("0").doubleValue());
            cell21.setCellStyle(styleDetailTableNumber);
            HSSFCell cell22 = row.createCell(29);
            BigDecimal agentcommpay = new BigDecimal("".equals(listDetail.get(r - 10).getAgentcommpay()) ? "0"
                    : listDetail.get(r - 10).getAgentcommpay());
            cell22.setCellValue(
                    (agentcommpay != null) ? agentcommpay.doubleValue() : new BigDecimal("0").doubleValue());
            cell22.setCellStyle(styleDetailTableNumber);
            HSSFCell cell23 = row.createCell(30);
            BigDecimal agentcommrec = new BigDecimal("".equals(listDetail.get(r - 10).getAgentcommrec()) ? "0"
                    : listDetail.get(r - 10).getAgentcommrec());
            cell23.setCellValue(
                    (agentcommrec != null) ? agentcommrec.doubleValue() : new BigDecimal("0").doubleValue());
            cell23.setCellStyle(styleDetailTableNumber);
            HSSFCell cell24 = row.createCell(31);
            BigDecimal pay = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getPay()) ? "0" : listDetail.get(r - 10).getPay());
            cell24.setCellValue((pay != null) ? pay.doubleValue() : new BigDecimal("0").doubleValue());
            cell24.setCellStyle(styleDetailTableNumber);
            HSSFCell cell26 = row.createCell(32);
            BigDecimal comm = new BigDecimal(
                    "".equals(listDetail.get(r - 10).getComm()) ? "0" : listDetail.get(r - 10).getComm());
            cell26.setCellValue((comm != null) ? comm.doubleValue() : new BigDecimal("0").doubleValue());
            cell26.setCellStyle(styleDetailTableNumber);

        }
        for (int i = 0; i < 33; i++) {
            sheet.autoSizeColumn(i);
        }
    } else {
        HSSFRow row = sheet.createRow(12);
        HSSFCell cell1 = row.createCell(0);
        cell1.setCellValue("No Data");
    }

    HSSFRow rowtotalDetail = sheet.createRow(count);
    String sumtotalpaxDetail = "SUM(J" + 11 + ":J" + (count) + ")";
    String sumtotalamountwenDetail = "SUM(O" + 11 + ":O" + (count) + ")";
    String sumtotalamountoutDetail = "SUM(P" + 11 + ":P" + (count) + ")";
    String sumtotalamountinDetail = "SUM(Q" + 11 + ":Q" + (count) + ")";
    String sumtotalamountreDetail = "SUM(R" + 11 + ":R" + (count) + ")";
    String sumtotalamountbusDetail = "SUM(S" + 11 + ":S" + (count) + ")";
    String sumtotalamountanDetail = "SUM(T" + 11 + ":T" + (count) + ")";
    String sumtotalamountinvDetail = "SUM(U" + 11 + ":U" + (count) + ")";
    String sumtotalsaleDetail = "SUM(V" + 11 + ":V" + (count) + ")";
    String sumtotalcostDetail = "SUM(W" + 11 + ":W" + (count) + ")";
    String sumtotaloverDetail = "SUM(X" + 11 + ":X" + (count) + ")";
    String sumtotaladdDetail = "SUM(Y" + 11 + ":Y" + (count) + ")";
    String sumtotaldresDetail = "SUM(Z" + 11 + ":Z" + (count) + ")";
    String sumtotalprofitDetail = "SUM(AA" + 11 + ":AA" + (count) + ")";
    String sumtotalticketcommDetail = "SUM(AB" + 11 + ":AB" + (count) + ")";
    String sumtotallittleDetail = "SUM(AC" + 11 + ":AC" + (count) + ")";
    String sumtotalagentcommpayDetail = "SUM(AD" + 11 + ":AD" + (count) + ")";
    String sumtotalagentcommrecDetail = "SUM(AE" + 11 + ":AE" + (count) + ")";
    String sumtotalpayDetail = "SUM(AF" + 11 + ":AF" + (count) + ")";
    String sumtotalnetcommDetail = "SUM(AG" + 11 + ":AG" + (count) + ")";
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("A"+(count + x + 2)+":B"+(count + x + 2)));
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("D"+(count + x + 2)+":E"+(count + x + 2)));
    HSSFCell cellTotalSumDetail0 = rowtotalDetail.createCell(0);
    cellTotalSumDetail0.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail1 = rowtotalDetail.createCell(1);
    cellTotalSumDetail1.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail2 = rowtotalDetail.createCell(3);
    cellTotalSumDetail2.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail3 = rowtotalDetail.createCell(2);
    cellTotalSumDetail3.setCellStyle(stylePaxNumberTotal);
    HSSFCell cellTotalSumDetail4 = rowtotalDetail.createCell(4);
    cellTotalSumDetail4.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail5 = rowtotalDetail.createCell(5);
    cellTotalSumDetail5.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail6 = rowtotalDetail.createCell(6);
    cellTotalSumDetail6.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail7 = rowtotalDetail.createCell(7);
    cellTotalSumDetail7.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail9 = rowtotalDetail.createCell(8);
    cellTotalSumDetail9.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail8 = rowtotalDetail.createCell(9);
    cellTotalSumDetail8.setCellFormula(sumtotalpaxDetail);
    cellTotalSumDetail8.setCellStyle(stylePaxNumberTotal);
    HSSFCell cellTotalSumDetail10 = rowtotalDetail.createCell(10);
    cellTotalSumDetail10.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail11 = rowtotalDetail.createCell(11);
    cellTotalSumDetail11.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail12 = rowtotalDetail.createCell(12);
    cellTotalSumDetail12.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail122 = rowtotalDetail.createCell(13);
    cellTotalSumDetail122.setCellStyle(styleTotalTableNumber);

    HSSFCell cellTotalSumDetail13 = rowtotalDetail.createCell(14);
    cellTotalSumDetail13.setCellFormula(sumtotalamountwenDetail);
    cellTotalSumDetail13.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail14 = rowtotalDetail.createCell(15);
    cellTotalSumDetail14.setCellFormula(sumtotalamountoutDetail);
    cellTotalSumDetail14.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail15 = rowtotalDetail.createCell(16);
    cellTotalSumDetail15.setCellFormula(sumtotalamountinDetail);
    cellTotalSumDetail15.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail16 = rowtotalDetail.createCell(17);
    cellTotalSumDetail16.setCellFormula(sumtotalamountreDetail);
    cellTotalSumDetail16.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail17 = rowtotalDetail.createCell(18);
    cellTotalSumDetail17.setCellFormula(sumtotalamountbusDetail);
    cellTotalSumDetail17.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail18 = rowtotalDetail.createCell(19);
    cellTotalSumDetail18.setCellFormula(sumtotalamountanDetail);
    cellTotalSumDetail18.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail19 = rowtotalDetail.createCell(20);
    cellTotalSumDetail19.setCellFormula(sumtotalamountinvDetail);
    cellTotalSumDetail19.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail20 = rowtotalDetail.createCell(21);
    cellTotalSumDetail20.setCellFormula(sumtotalsaleDetail);
    cellTotalSumDetail20.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail21 = rowtotalDetail.createCell(22);
    cellTotalSumDetail21.setCellFormula(sumtotalcostDetail);
    cellTotalSumDetail21.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail22 = rowtotalDetail.createCell(23);
    cellTotalSumDetail22.setCellFormula(sumtotaloverDetail);
    cellTotalSumDetail22.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail23 = rowtotalDetail.createCell(24);
    cellTotalSumDetail23.setCellFormula(sumtotaladdDetail);
    cellTotalSumDetail23.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail24 = rowtotalDetail.createCell(25);
    cellTotalSumDetail24.setCellFormula(sumtotaldresDetail);
    cellTotalSumDetail24.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail25 = rowtotalDetail.createCell(26);
    cellTotalSumDetail25.setCellFormula(sumtotalprofitDetail);
    cellTotalSumDetail25.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail26 = rowtotalDetail.createCell(27);
    cellTotalSumDetail26.setCellFormula(sumtotalticketcommDetail);
    cellTotalSumDetail26.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail27 = rowtotalDetail.createCell(28);
    cellTotalSumDetail27.setCellFormula(sumtotallittleDetail);
    cellTotalSumDetail27.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail28 = rowtotalDetail.createCell(29);
    cellTotalSumDetail28.setCellFormula(sumtotalagentcommpayDetail);
    cellTotalSumDetail28.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail29 = rowtotalDetail.createCell(30);
    cellTotalSumDetail29.setCellFormula(sumtotalagentcommrecDetail);
    cellTotalSumDetail29.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail30 = rowtotalDetail.createCell(31);
    cellTotalSumDetail30.setCellFormula(sumtotalpayDetail);
    cellTotalSumDetail30.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumDetail31 = rowtotalDetail.createCell(32);
    cellTotalSumDetail31.setCellFormula(sumtotalnetcommDetail);
    cellTotalSumDetail31.setCellStyle(styleTotalTableNumber);

    //        System.out.println(count);
    //        HSSFRow rowL = sheet.createRow(count);
    //        rowL.createCell(0).setCellStyle(styleBorderTop);
    //        rowL.createCell(1).setCellStyle(styleBorderTop);
    //        rowL.createCell(2).setCellStyle(styleBorderTop);
    //        rowL.createCell(3).setCellStyle(styleBorderTop);
    //        rowL.createCell(4).setCellStyle(styleBorderTop);
    //        rowL.createCell(5).setCellStyle(styleBorderTop);
    //        rowL.createCell(6).setCellStyle(styleBorderTop);
    //        rowL.createCell(7).setCellStyle(styleBorderTop);
    //        rowL.createCell(8).setCellStyle(styleBorderTop);
    //        rowL.createCell(9).setCellStyle(styleBorderTop);
    //        rowL.createCell(10).setCellStyle(styleBorderTop);
    //        rowL.createCell(11).setCellStyle(styleBorderTop);
    //        rowL.createCell(12).setCellStyle(styleBorderTop);
    //        rowL.createCell(13).setCellStyle(styleBorderTop);
    //        rowL.createCell(14).setCellStyle(styleBorderTop);
    //        rowL.createCell(15).setCellStyle(styleBorderTop);
    //        rowL.createCell(16).setCellStyle(styleBorderTop);
    //        rowL.createCell(17).setCellStyle(styleBorderTop);
    //        rowL.createCell(18).setCellStyle(styleBorderTop);
    //        rowL.createCell(19).setCellStyle(styleBorderTop);
    //        rowL.createCell(20).setCellStyle(styleBorderTop);
    //        rowL.createCell(21).setCellStyle(styleBorderTop);
    //        rowL.createCell(22).setCellStyle(styleBorderTop);
    //        rowL.createCell(23).setCellStyle(styleBorderTop);
    //        rowL.createCell(24).setCellStyle(styleBorderTop);
    //        rowL.createCell(25).setCellStyle(styleBorderTop);
    //        rowL.createCell(26).setCellStyle(styleBorderTop);
    //        rowL.createCell(27).setCellStyle(styleBorderTop);
    //        rowL.createCell(28).setCellStyle(styleBorderTop);
    //        rowL.createCell(29).setCellStyle(styleBorderTop);
    //        rowL.createCell(30).setCellStyle(styleBorderTop);
    //        rowL.createCell(31).setCellStyle(styleBorderTop);
    //**********************************************************************************************************************
    // set Header Report (Row 1)
    HSSFCellStyle styleHeader02 = wb.createCellStyle();
    HSSFRow row21 = sheet1.createRow(0);
    HSSFCell cell21 = row21.createCell(0);
    cell21.setCellValue("List summary commission");
    styleHeader02.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell21.setCellStyle(styleHeader02);
    sheet1.addMergedRegion(CellRangeAddress.valueOf("A1:M1"));

    // Row 2
    HSSFRow row22 = sheet1.createRow(1);
    HSSFCell cell221 = row22.createCell(0);
    cell221.setCellValue("Agent Name : ");
    cell221.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(0);
    HSSFCell cell222 = row22.createCell(1);
    cell222.setCellValue(ticketAir.getAgentNamePage() != null && !"".equals(ticketDetail.getAgentNamePage())
            ? ticketDetail.getAgentNamePage()
            : "ALL");
    cell222.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(1);
    HSSFCell cell223 = row22.createCell(2);
    cell223.setCellValue("Issue date : ");
    cell223.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(2);
    HSSFCell cell224 = row22.createCell(3);
    cell224.setCellValue(
            ticketAir.getIssuefromdatePage() != null && !"".equals(ticketDetail.getIssuefromdatePage())
                    ? ticketDetail.getIssuefromdatePage()
                    : "ALL");
    cell224.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(3);
    HSSFCell cell225 = row22.createCell(4);
    cell225.setCellValue("Print By : ");
    cell225.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(4);
    HSSFCell cell226 = row22.createCell(5);
    cell226.setCellValue(ticketAir.getPrintbyPage() != null && !"".equals(ticketDetail.getPrintbyPage())
            ? ticketDetail.getPrintbyPage()
            : "ALL");
    cell226.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(5);

    // Row 3
    HSSFRow row23 = sheet1.createRow(2);
    HSSFCell cell231 = row23.createCell(0);
    cell231.setCellValue("Type Routing : ");
    cell231.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(0);
    HSSFCell cell232 = row23.createCell(1);
    cell232.setCellValue(ticketAir.getTypeRoutingPage() != null && !"".equals(ticketDetail.getTypeRoutingPage())
            ? ticketDetail.getTypeRoutingPage()
            : "ALL");
    cell232.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(1);
    HSSFCell cell233 = row23.createCell(2);
    cell233.setCellValue("Over Comm Date : ");
    cell233.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(2);
    HSSFCell cell234 = row23.createCell(3);
    cell234.setCellValue(
            ticketAir.getOverfromdatePage() != null && !"".equals(ticketDetail.getOverfromdatePage())
                    ? ticketDetail.getOverfromdatePage()
                    : "ALL");
    cell234.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(3);
    HSSFCell cell235 = row23.createCell(4);
    cell235.setCellValue("Add Pay Date : ");
    cell235.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(4);
    HSSFCell cell236 = row23.createCell(5);
    cell236.setCellValue(
            ticketAir.getAddpayfromdatePage() != null && !"".equals(ticketDetail.getAddpayfromdatePage())
                    ? ticketDetail.getAddpayfromdatePage()
                    : "ALL");
    cell236.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(5);

    // Row 4
    HSSFRow row24 = sheet1.createRow(3);
    HSSFCell cell241 = row24.createCell(0);
    cell241.setCellValue("Air : ");
    cell241.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(0);
    HSSFCell cell242 = row24.createCell(1);
    cell242.setCellValue(ticketAir.getAirlineCodePage() != null && !"".equals(ticketDetail.getAirlineCodePage())
            ? ticketDetail.getAirlineCodePage()
            : "ALL");
    cell242.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(1);
    HSSFCell cell243 = row24.createCell(2);
    cell243.setCellValue("Little Comm date : ");
    cell243.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(2);
    HSSFCell cell244 = row24.createCell(3);
    cell244.setCellValue(
            ticketAir.getLittlefromdatePage() != null && !"".equals(ticketDetail.getLittlefromdatePage())
                    ? ticketDetail.getLittlefromdatePage()
                    : "ALL");
    cell244.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(3);
    HSSFCell cell245 = row24.createCell(4);
    cell245.setCellValue("Decrease Pay Date : ");
    cell245.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(4);
    HSSFCell cell246 = row24.createCell(5);
    cell246.setCellValue(ticketAir.getDecreasepayfromdatePage() != null
            && !"".equals(ticketDetail.getDecreasepayfromdatePage()) ? ticketDetail.getDecreasepayfromdatePage()
                    : "ALL");
    cell246.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(5);

    // Row 5
    HSSFRow row25 = sheet1.createRow(4);
    HSSFCell cell251 = row25.createCell(0);
    cell251.setCellValue("Routing Detail : ");
    cell251.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(0);
    HSSFCell cell252 = row25.createCell(1);
    cell252.setCellValue(
            ticketAir.getRoutingDetailPage() != null && !"".equals(ticketDetail.getRoutingDetailPage())
                    ? ticketDetail.getRoutingDetailPage()
                    : "ALL");
    cell252.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(1);
    HSSFCell cell253 = row25.createCell(2);
    cell253.setCellValue("Agent Comm Rev Date : ");
    cell253.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(2);
    HSSFCell cell254 = row25.createCell(3);
    cell254.setCellValue(ticketAir.getAgemtcomreceivefromdatePage() != null
            && !"".equals(ticketDetail.getAgemtcomreceivefromdatePage())
                    ? ticketDetail.getAgemtcomreceivefromdatePage()
                    : "ALL");
    cell254.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(3);
    HSSFCell cell255 = row25.createCell(4);
    cell255.setCellValue("Ticket No : ");
    cell255.setCellStyle(styleAlignRight);
    sheet1.autoSizeColumn(4);
    HSSFCell cell256 = row25.createCell(5);
    cell256.setCellValue(
            ticketAir.getTicketcomfromdatePage() != null && !"".equals(ticketDetail.getTicketcomfromdatePage())
                    ? ticketDetail.getTicketcomfromdatePage()
                    : "ALL");
    cell256.setCellStyle(styleAlignLeft);
    sheet1.autoSizeColumn(5);

    // Row 6
    HSSFRow row26 = sheet1.createRow(5);
    HSSFCell cell261 = row26.createCell(0);
    cell261.setCellValue("Sale Staff : ");
    cell261.setCellStyle(styleAlignRight);
    HSSFCell cell262 = row26.createCell(1);
    cell262.setCellValue(ticketAir.getSalebyNamePage() != null && !"".equals(ticketDetail.getSalebyNamePage())
            ? ticketDetail.getSalebyNamePage()
            : "ALL");
    cell262.setCellStyle(styleAlignLeft);
    HSSFCell cell263 = row26.createCell(2);
    cell263.setCellValue("Refund Comm Date : ");
    cell263.setCellStyle(styleAlignRight);
    HSSFCell cell264 = row26.createCell(3);
    cell264.setCellValue(
            ticketAir.getComrefundfromdatePage() != null && !"".equals(ticketDetail.getComrefundfromdatePage())
                    ? ticketDetail.getComrefundfromdatePage()
                    : "ALL");
    cell264.setCellStyle(styleAlignLeft);
    HSSFCell cell265 = row26.createCell(4);
    cell265.setCellValue("Ticket Comm Date : ");
    cell265.setCellStyle(styleAlignRight);
    HSSFCell cell266 = row26.createCell(5);
    cell266.setCellValue(
            ticketAir.getTicketcomfromdatePage() != null && !"".equals(ticketDetail.getTicketcomfromdatePage())
                    ? ticketDetail.getTicketcomfromdatePage()
                    : "ALL");
    cell266.setCellStyle(styleAlignLeft);

    // Row 7
    HSSFRow row27 = sheet1.createRow(6);
    HSSFCell cell271 = row27.createCell(0);
    cell271.setCellValue("Department : ");
    cell271.setCellStyle(styleAlignRight);
    HSSFCell cell272 = row27.createCell(1);
    cell272.setCellValue(ticketAir.getDepartmentPage() != null && !"".equals(ticketDetail.getDepartmentPage())
            ? ticketDetail.getDepartmentPage()
            : "ALL");
    cell272.setCellStyle(styleAlignLeft);
    HSSFCell cell273 = row27.createCell(2);
    cell273.setCellValue("Invoice Date : ");
    cell273.setCellStyle(styleAlignRight);
    HSSFCell cell274 = row27.createCell(3);
    cell274.setCellValue(
            ticketAir.getInvoicefromdatePage() != null && !"".equals(ticketDetail.getInvoicefromdatePage())
                    ? ticketDetail.getInvoicefromdatePage()
                    : "ALL");
    cell274.setCellStyle(styleAlignLeft);
    HSSFCell cell275 = row27.createCell(4);
    cell275.setCellValue("Print on : ");
    cell275.setCellStyle(styleAlignRight);
    HSSFCell cell276 = row27.createCell(5);
    cell276.setCellValue(ticketAir.getPrintonPage() != null && !"".equals(ticketDetail.getPrintonPage())
            ? ticketDetail.getPrintonPage()
            : "ALL");
    cell276.setCellStyle(styleAlignLeft);

    // Row 8
    HSSFRow row28 = sheet1.createRow(7);
    HSSFCell cell281 = row28.createCell(0);
    cell281.setCellValue("Term Pay : ");
    cell281.setCellStyle(styleAlignRight);
    HSSFCell cell282 = row28.createCell(1);
    cell282.setCellValue(ticketAir.getTermPayPage() != null && !"".equals(ticketDetail.getTermPayPage())
            ? ticketDetail.getTermPayPage()
            : "ALL");
    cell282.setCellStyle(styleAlignLeft);
    HSSFCell cell283 = row28.createCell(2);
    cell283.setCellValue("Page : ");
    cell283.setCellStyle(styleAlignRight);
    HSSFCell cell284 = row28.createCell(3);
    cell284.setCellValue("1 ");
    cell284.setCellStyle(styleAlignLeft);

    // Header Table
    HSSFRow row29 = sheet1.createRow(9);
    HSSFCell cell291 = row29.createCell(0);
    cell291.setCellValue("Type Pay");
    cell291.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(0);

    HSSFCell cell292 = row29.createCell(1);
    cell292.setCellValue("Type Route");
    cell292.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(1);

    HSSFCell cell293 = row29.createCell(2);
    cell293.setCellValue("Pax");
    cell293.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(2);

    HSSFCell cell294 = row29.createCell(3);
    cell294.setCellValue("Air");
    cell294.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(3);

    HSSFCell cell295 = row29.createCell(4);
    cell295.setCellValue("Amount Wendy");
    cell295.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(4);

    HSSFCell cell296 = row29.createCell(5);
    cell296.setCellValue("Amount Outbound");
    cell296.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(5);

    HSSFCell cell2110 = row29.createCell(6);
    cell2110.setCellValue("Amount Inbound");
    cell2110.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(6);

    HSSFCell cell297 = row29.createCell(7);
    cell297.setCellValue("Sale Price");
    cell297.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(7);

    HSSFCell cell298 = row29.createCell(8);
    cell298.setCellValue("Cost");
    cell298.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(8);

    HSSFCell cell299 = row29.createCell(9);
    cell299.setCellValue("Over Comm");
    cell299.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(9);

    HSSFCell cell2100 = row29.createCell(10);
    cell2100.setCellValue("Add Pay");
    cell2100.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(10);

    HSSFCell cell2101 = row29.createCell(11);
    cell2101.setCellValue("Drecrease Pay");
    cell2101.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(11);

    HSSFCell cell2103 = row29.createCell(12);
    cell2103.setCellValue("Profit");
    cell2103.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(12);

    HSSFCell cell2104 = row29.createCell(13);
    cell2104.setCellValue("Comm");
    cell2104.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(13);

    HSSFCell cell2105 = row29.createCell(14);
    cell2105.setCellValue("Little Comm");
    cell2105.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(14);

    HSSFCell cell2106 = row29.createCell(15);
    cell2106.setCellValue("Agent[Comm] Pay");
    cell2106.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(15);

    HSSFCell cell2107 = row29.createCell(16);
    cell2107.setCellValue("Agent[Comm] Receive");
    cell2107.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(16);

    HSSFCell cell2108 = row29.createCell(17);
    cell2108.setCellValue("Pay Comm Refund");
    cell2108.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(17);

    HSSFCell cell2109 = row29.createCell(18);
    cell2109.setCellValue("Comm Receive");
    cell2109.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet1.autoSizeColumn(18);

    int count1 = 10 + listAir.size();
    if (listAir != null) {
        for (int r = 10; r < count1; r++) {
            HSSFRow row = sheet1.createRow(r);
            HSSFCell cell1 = row.createCell(0);
            cell1.setCellValue(listAir.get(r - 10).getTypepayment());
            cell1.setCellStyle(styleDetailTable);
            HSSFCell cell2 = row.createCell(1);
            cell2.setCellValue(listAir.get(r - 10).getTyperounting());
            cell2.setCellStyle(stylePaxNumber);
            HSSFCell cell3 = row.createCell(2);
            BigDecimal pax = new BigDecimal(
                    "".equals(listAir.get(r - 10).getPax()) ? "0" : listAir.get(r - 10).getPax());
            cell3.setCellValue((pax != null) ? pax.doubleValue() : new BigDecimal("0").doubleValue());
            cell3.setCellStyle(stylePaxNumber);
            HSSFCell cell4 = row.createCell(3);
            cell4.setCellValue(listAir.get(r - 10).getAir());
            cell4.setCellStyle(stylePaxNumber);
            HSSFCell cell5 = row.createCell(4);
            BigDecimal amountwendy = new BigDecimal("".equals(listAir.get(r - 10).getAmountwendy()) ? "0"
                    : listAir.get(r - 10).getAmountwendy());
            cell5.setCellValue(
                    (amountwendy != null) ? amountwendy.doubleValue() : new BigDecimal("0").doubleValue());
            cell5.setCellStyle(styleDetailTableNumber);
            HSSFCell cell19 = row.createCell(5);
            BigDecimal amountoutbound = new BigDecimal(
                    "null".equals(String.valueOf(listAir.get(r - 10).getAmountoutbound())) ? "0"
                            : listAir.get(r - 10).getAmountoutbound());
            cell19.setCellValue((amountoutbound != null) ? amountoutbound.doubleValue()
                    : new BigDecimal("0").doubleValue());
            cell19.setCellStyle(styleDetailTableNumber);
            HSSFCell cell6 = row.createCell(6);
            BigDecimal amountinbound = new BigDecimal(
                    "null".equals(String.valueOf(listAir.get(r - 10).getAmountinbound())) ? "0"
                            : listAir.get(r - 10).getAmountinbound());
            cell6.setCellValue(
                    (amountinbound != null) ? amountinbound.doubleValue() : new BigDecimal("0").doubleValue());
            cell6.setCellStyle(styleDetailTableNumber);
            HSSFCell cell7 = row.createCell(7);
            BigDecimal sale = new BigDecimal(
                    "".equals(listAir.get(r - 10).getSale()) ? "0" : listAir.get(r - 10).getSale());
            cell7.setCellValue((sale != null) ? sale.doubleValue() : new BigDecimal("0").doubleValue());
            cell7.setCellStyle(styleDetailTableNumber);
            HSSFCell cell8 = row.createCell(8);
            BigDecimal cost = new BigDecimal(
                    "".equals(listAir.get(r - 10).getCost()) ? "0" : listAir.get(r - 10).getCost());
            cell8.setCellValue((cost != null) ? cost.doubleValue() : new BigDecimal("0").doubleValue());
            cell8.setCellStyle(styleDetailTableNumber);
            HSSFCell cell9 = row.createCell(9);
            BigDecimal over = new BigDecimal(
                    "".equals(listAir.get(r - 10).getOver()) ? "0" : listAir.get(r - 10).getOver());
            cell9.setCellValue((over != null) ? over.doubleValue() : new BigDecimal("0").doubleValue());
            cell9.setCellStyle(styleDetailTableNumber);
            HSSFCell cell10 = row.createCell(10);
            BigDecimal add = new BigDecimal(
                    "".equals(listAir.get(r - 10).getAdd()) ? "0" : listAir.get(r - 10).getAdd());
            cell10.setCellValue((add != null) ? add.doubleValue() : new BigDecimal("0").doubleValue());
            cell10.setCellStyle(styleDetailTableNumber);
            HSSFCell cell11 = row.createCell(11);
            BigDecimal dres = new BigDecimal(
                    "".equals(listAir.get(r - 10).getDres()) ? "0" : listAir.get(r - 10).getDres());
            cell11.setCellValue((dres != null) ? dres.doubleValue() : new BigDecimal("0").doubleValue());
            cell11.setCellStyle(styleDetailTableNumber);
            HSSFCell cell12 = row.createCell(12);
            BigDecimal profit = new BigDecimal(
                    "".equals(listAir.get(r - 10).getProfit()) ? "0" : listAir.get(r - 10).getProfit());
            cell12.setCellValue((profit != null) ? profit.doubleValue() : new BigDecimal("0").doubleValue());
            cell12.setCellStyle(styleDetailTableNumber);
            HSSFCell cell13 = row.createCell(13);
            BigDecimal ticcom = new BigDecimal(
                    "".equals(listAir.get(r - 10).getTiccomm()) ? "0" : listAir.get(r - 10).getTiccomm());
            cell13.setCellValue((ticcom != null) ? ticcom.doubleValue() : new BigDecimal("0").doubleValue());
            cell13.setCellStyle(styleDetailTableNumber);
            HSSFCell cell14 = row.createCell(14);
            BigDecimal little = new BigDecimal(
                    "".equals(listAir.get(r - 10).getLittle()) ? "0" : listAir.get(r - 10).getLittle());
            cell14.setCellValue((little != null) ? little.doubleValue() : new BigDecimal("0").doubleValue());
            cell14.setCellStyle(styleDetailTableNumber);
            HSSFCell cell15 = row.createCell(15);
            BigDecimal agentcommpay = new BigDecimal("".equals(listAir.get(r - 10).getAgentcommpay()) ? "0"
                    : listAir.get(r - 10).getAgentcommpay());
            cell15.setCellValue(
                    (agentcommpay != null) ? agentcommpay.doubleValue() : new BigDecimal("0").doubleValue());
            cell15.setCellStyle(styleDetailTableNumber);
            HSSFCell cell16 = row.createCell(16);
            BigDecimal agentcommrec = new BigDecimal("".equals(listAir.get(r - 10).getAgentcommrec()) ? "0"
                    : listAir.get(r - 10).getAgentcommrec());
            cell16.setCellValue(
                    (agentcommrec != null) ? agentcommrec.doubleValue() : new BigDecimal("0").doubleValue());
            cell16.setCellStyle(styleDetailTableNumber);
            HSSFCell cell17 = row.createCell(17);
            BigDecimal pay = new BigDecimal(
                    "".equals(listAir.get(r - 10).getPay()) ? "0" : listAir.get(r - 10).getPay());
            cell17.setCellValue((pay != null) ? pay.doubleValue() : new BigDecimal("0").doubleValue());
            cell17.setCellStyle(styleDetailTableNumber);
            HSSFCell cell18 = row.createCell(18);
            BigDecimal comm = new BigDecimal(
                    "".equals(listAir.get(r - 10).getComm()) ? "0" : listAir.get(r - 10).getComm());
            cell18.setCellValue((comm != null) ? comm.doubleValue() : new BigDecimal("0").doubleValue());
            cell18.setCellStyle(styleDetailTableNumber);

        }
        for (int i = 0; i < 25; i++) {
            sheet1.autoSizeColumn(i);
        }
    }

    HSSFRow rowtotal = sheet1.createRow(count1);
    String sumtotalpax = "SUM(C" + 11 + ":C" + (count1) + ")";
    String sumtotalamountwen = "SUM(E" + 11 + ":E" + (count1) + ")";
    String sumtotalamountout = "SUM(F" + 11 + ":F" + (count1) + ")";
    String sumtotalamountin = "SUM(G" + 11 + ":G" + (count1) + ")";
    String sumtotalsale = "SUM(H" + 11 + ":H" + (count1) + ")";
    String sumtotalcost = "SUM(I" + 11 + ":I" + (count1) + ")";
    String sumtotalover = "SUM(J" + 11 + ":J" + (count1) + ")";
    String sumtotaladd = "SUM(K" + 11 + ":K" + (count1) + ")";
    String sumtotaldres = "SUM(L" + 11 + ":L" + (count1) + ")";
    String sumtotalprofit = "SUM(M" + 11 + ":M" + (count1) + ")";
    String sumtotalticketcomm = "SUM(N" + 11 + ":N" + (count1) + ")";
    String sumtotallittle = "SUM(O" + 11 + ":O" + (count1) + ")";
    String sumtotalagentcommpay = "SUM(P" + 11 + ":P" + (count1) + ")";
    String sumtotalagentcommrec = "SUM(Q" + 11 + ":Q" + (count1) + ")";
    String sumtotalpay = "SUM(R" + 11 + ":R" + (count1) + ")";
    String sumtotalcomm = "SUM(S" + 11 + ":S" + (count1) + ")";
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("A"+(count + x + 2)+":B"+(count + x + 2)));
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("D"+(count + x + 2)+":E"+(count + x + 2)));
    HSSFCell cellTotalSum00 = rowtotal.createCell(0);
    cellTotalSum00.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum16 = rowtotal.createCell(1);
    cellTotalSum16.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum17 = rowtotal.createCell(3);
    cellTotalSum17.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum01 = rowtotal.createCell(2);
    cellTotalSum01.setCellFormula(sumtotalpax);
    cellTotalSum01.setCellStyle(stylePaxNumberTotal);
    HSSFCell cellTotalSum18 = rowtotal.createCell(4);
    cellTotalSum18.setCellFormula(sumtotalamountwen);
    cellTotalSum18.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum02 = rowtotal.createCell(5);
    cellTotalSum02.setCellFormula(sumtotalamountout);
    cellTotalSum02.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum03 = rowtotal.createCell(6);
    cellTotalSum03.setCellFormula(sumtotalamountin);
    cellTotalSum03.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum04 = rowtotal.createCell(7);
    cellTotalSum04.setCellFormula(sumtotalsale);
    cellTotalSum04.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum05 = rowtotal.createCell(8);
    cellTotalSum05.setCellFormula(sumtotalcost);
    cellTotalSum05.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum06 = rowtotal.createCell(9);
    cellTotalSum06.setCellFormula(sumtotalover);
    cellTotalSum06.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum07 = rowtotal.createCell(10);
    cellTotalSum07.setCellFormula(sumtotaladd);
    cellTotalSum07.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum08 = rowtotal.createCell(11);
    cellTotalSum08.setCellFormula(sumtotaldres);
    cellTotalSum08.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum09 = rowtotal.createCell(12);
    cellTotalSum09.setCellFormula(sumtotalprofit);
    cellTotalSum09.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum10 = rowtotal.createCell(13);
    cellTotalSum10.setCellFormula(sumtotalticketcomm);
    cellTotalSum10.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum11 = rowtotal.createCell(14);
    cellTotalSum11.setCellFormula(sumtotallittle);
    cellTotalSum11.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum12 = rowtotal.createCell(15);
    cellTotalSum12.setCellFormula(sumtotalagentcommpay);
    cellTotalSum12.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum13 = rowtotal.createCell(16);
    cellTotalSum13.setCellFormula(sumtotalagentcommrec);
    cellTotalSum13.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum14 = rowtotal.createCell(17);
    cellTotalSum14.setCellFormula(sumtotalpay);
    cellTotalSum14.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSum15 = rowtotal.createCell(18);
    cellTotalSum15.setCellFormula(sumtotalcomm);
    cellTotalSum15.setCellStyle(styleTotalTableNumber);

    //                       
    //        HSSFRow rowLL = sheet1.createRow(count1+1);
    //         rowLL.createCell(0).setCellStyle(styleBorderTop);
    //         rowLL.createCell(1).setCellStyle(styleBorderTop);
    //         rowLL.createCell(2).setCellStyle(styleBorderTop);
    //         rowLL.createCell(3).setCellStyle(styleBorderTop);
    //         rowLL.createCell(4).setCellStyle(styleBorderTop);
    //         rowLL.createCell(5).setCellStyle(styleBorderTop);
    //         rowLL.createCell(6).setCellStyle(styleBorderTop);
    //         rowLL.createCell(7).setCellStyle(styleBorderTop);
    //         rowLL.createCell(8).setCellStyle(styleBorderTop);
    //         rowLL.createCell(9).setCellStyle(styleBorderTop);
    //         rowLL.createCell(10).setCellStyle(styleBorderTop);
    //         rowLL.createCell(11).setCellStyle(styleBorderTop);
    //         rowLL.createCell(12).setCellStyle(styleBorderTop);
    //         rowLL.createCell(13).setCellStyle(styleBorderTop);
    //         rowLL.createCell(14).setCellStyle(styleBorderTop);
    //         rowLL.createCell(15).setCellStyle(styleBorderTop);
    //         rowLL.createCell(16).setCellStyle(styleBorderTop);
    //         rowLL.createCell(17).setCellStyle(styleBorderTop);

    //****************************************************************************************************************      
    // set Header Report (Row 1)
    HSSFCellStyle styleHeader03 = wb.createCellStyle();
    HSSFRow row31 = sheet2.createRow(0);
    HSSFCell cell31 = row31.createCell(0);
    cell31.setCellValue("List summary commission");
    styleHeader03.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell31.setCellStyle(styleHeader03);
    sheet2.addMergedRegion(CellRangeAddress.valueOf("A1:M1"));

    // Row 2
    HSSFRow row32 = sheet2.createRow(1);
    HSSFCell cell321 = row32.createCell(0);
    cell321.setCellValue("Agent Name : ");
    cell321.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell322 = row32.createCell(1);
    cell322.setCellValue(ticketAgent.getAgentNamePage() != null && !"".equals(ticketAgent.getAgentNamePage())
            ? ticketAgent.getAgentNamePage()
            : "ALL");
    cell322.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell323 = row32.createCell(2);
    cell323.setCellValue("Issue date : ");
    cell323.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell324 = row32.createCell(3);
    cell324.setCellValue(
            ticketAgent.getIssuefromdatePage() != null && !"".equals(ticketAgent.getIssuefromdatePage())
                    ? ticketAgent.getIssuefromdatePage()
                    : "ALL");
    cell324.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);
    HSSFCell cell325 = row32.createCell(4);
    cell325.setCellValue("Print By : ");
    cell325.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(4);
    HSSFCell cell326 = row32.createCell(5);
    cell326.setCellValue(ticketAgent.getPrintbyPage() != null && !"".equals(ticketAgent.getPrintbyPage())
            ? ticketAgent.getPrintbyPage()
            : "ALL");
    cell326.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(5);

    // Row 3
    HSSFRow row33 = sheet2.createRow(2);
    HSSFCell cell331 = row33.createCell(0);
    cell331.setCellValue("Type Routing : ");
    cell331.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell332 = row33.createCell(1);
    cell332.setCellValue(
            ticketAgent.getTypeRoutingPage() != null && !"".equals(ticketAgent.getTypeRoutingPage())
                    ? ticketAgent.getTypeRoutingPage()
                    : "ALL");
    cell332.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell333 = row33.createCell(2);
    cell333.setCellValue("Over Comm Date : ");
    cell333.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell334 = row33.createCell(3);
    cell334.setCellValue(
            ticketAgent.getOverfromdatePage() != null && !"".equals(ticketAgent.getOverfromdatePage())
                    ? ticketAgent.getOverfromdatePage()
                    : "ALL");
    cell334.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);
    HSSFCell cell335 = row33.createCell(4);
    cell335.setCellValue("Add Pay Date : ");
    cell335.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(4);
    HSSFCell cell336 = row33.createCell(5);
    cell336.setCellValue(
            ticketAgent.getAddpayfromdatePage() != null && !"".equals(ticketAgent.getAddpayfromdatePage())
                    ? ticketAgent.getAddpayfromdatePage()
                    : "ALL");
    cell336.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(5);

    // Row 4
    HSSFRow row34 = sheet2.createRow(3);
    HSSFCell cell341 = row34.createCell(0);
    cell341.setCellValue("Air : ");
    cell341.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell342 = row34.createCell(1);
    cell342.setCellValue(
            ticketAgent.getAirlineCodePage() != null && !"".equals(ticketAgent.getAirlineCodePage())
                    ? ticketAgent.getAirlineCodePage()
                    : "ALL");
    cell342.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell343 = row34.createCell(2);
    cell343.setCellValue("Little Comm date : ");
    cell343.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell344 = row34.createCell(3);
    cell344.setCellValue(
            ticketAgent.getLittlefromdatePage() != null && !"".equals(ticketAgent.getLittlefromdatePage())
                    ? ticketAgent.getLittlefromdatePage()
                    : "ALL");
    cell344.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);
    HSSFCell cell345 = row34.createCell(4);
    cell345.setCellValue("Decrease Pay Date : ");
    cell345.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(4);
    HSSFCell cell346 = row34.createCell(5);
    cell346.setCellValue(ticketAgent.getDecreasepayfromdatePage() != null
            && !"".equals(ticketAgent.getDecreasepayfromdatePage()) ? ticketAgent.getDecreasepayfromdatePage()
                    : "ALL");
    cell346.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(5);

    // Row 5
    HSSFRow row35 = sheet2.createRow(4);
    HSSFCell cell351 = row35.createCell(0);
    cell351.setCellValue("Routing Detail : ");
    cell351.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(0);
    HSSFCell cell352 = row35.createCell(1);
    cell352.setCellValue(
            ticketAgent.getRoutingDetailPage() != null && !"".equals(ticketAgent.getRoutingDetailPage())
                    ? ticketAgent.getRoutingDetailPage()
                    : "ALL");
    cell352.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(1);
    HSSFCell cell353 = row35.createCell(2);
    cell353.setCellValue("Agent Comm Rev Date : ");
    cell353.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(2);
    HSSFCell cell354 = row35.createCell(3);
    cell354.setCellValue(
            ticketAgent.getAgentcomfromdatePage() != null && !"".equals(ticketAgent.getAgentcomfromdatePage())
                    ? ticketAgent.getAgentcomfromdatePage()
                    : "ALL");
    cell354.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(3);
    HSSFCell cell355 = row35.createCell(4);
    cell355.setCellValue("Ticket No : ");
    cell355.setCellStyle(styleAlignRight);
    sheet2.autoSizeColumn(4);
    HSSFCell cell356 = row35.createCell(5);
    cell356.setCellValue(
            ticketAgent.getTicketnoPagePage() != null && !"".equals(ticketAgent.getTicketnoPagePage())
                    ? ticketAgent.getTicketnoPagePage()
                    : "ALL");
    cell356.setCellStyle(styleAlignLeft);
    sheet2.autoSizeColumn(5);

    // Row 6
    HSSFRow row36 = sheet2.createRow(5);
    HSSFCell cell361 = row36.createCell(0);
    cell361.setCellValue("Sale Staff : ");
    cell361.setCellStyle(styleAlignRight);
    HSSFCell cell362 = row36.createCell(1);
    cell362.setCellValue(ticketAgent.getSalebyNamePage() != null && !"".equals(ticketAgent.getSalebyNamePage())
            ? ticketAgent.getSalebyNamePage()
            : "ALL");
    cell362.setCellStyle(styleAlignLeft);
    HSSFCell cell363 = row36.createCell(2);
    cell363.setCellValue("Refund Comm Date : ");
    cell363.setCellStyle(styleAlignRight);
    HSSFCell cell364 = row36.createCell(3);
    cell364.setCellValue(
            ticketAgent.getComrefundfromdatePage() != null && !"".equals(ticketAgent.getComrefundfromdatePage())
                    ? ticketAgent.getComrefundfromdatePage()
                    : "ALL");
    cell364.setCellStyle(styleAlignLeft);
    HSSFCell cell365 = row36.createCell(4);
    cell365.setCellValue("Ticket Comm Date : ");
    cell365.setCellStyle(styleAlignRight);
    HSSFCell cell366 = row36.createCell(5);
    cell366.setCellValue(
            ticketAgent.getTicketcomfromdatePage() != null && !"".equals(ticketAgent.getTicketcomfromdatePage())
                    ? ticketAgent.getTicketcomfromdatePage()
                    : "ALL");
    cell366.setCellStyle(styleAlignLeft);

    // Row 7
    HSSFRow row37 = sheet2.createRow(6);
    HSSFCell cell371 = row37.createCell(0);
    cell371.setCellValue("Department : ");
    cell371.setCellStyle(styleAlignRight);
    HSSFCell cell372 = row37.createCell(1);
    cell372.setCellValue(ticketAgent.getDepartmentPage() != null && !"".equals(ticketAgent.getDepartmentPage())
            ? ticketAgent.getDepartmentPage()
            : "ALL");
    cell372.setCellStyle(styleAlignLeft);
    HSSFCell cell373 = row37.createCell(2);
    cell373.setCellValue("Invoice Date : ");
    cell373.setCellStyle(styleAlignRight);
    HSSFCell cell374 = row37.createCell(3);
    cell374.setCellValue(
            ticketAgent.getInvoicefromdatePage() != null && !"".equals(ticketAgent.getInvoicefromdatePage())
                    ? ticketAgent.getInvoicefromdatePage()
                    : "ALL");
    cell374.setCellStyle(styleAlignLeft);
    HSSFCell cell375 = row37.createCell(4);
    cell375.setCellValue("Print on : ");
    cell375.setCellStyle(styleAlignRight);
    HSSFCell cell376 = row37.createCell(5);
    cell376.setCellValue(ticketAgent.getPrintonPage() != null && !"".equals(ticketAgent.getPrintonPage())
            ? ticketAgent.getPrintonPage()
            : "ALL");
    cell376.setCellStyle(styleAlignLeft);

    // Row 8
    HSSFRow row38 = sheet2.createRow(7);
    HSSFCell cell381 = row38.createCell(0);
    cell381.setCellValue("Term Pay : ");
    cell381.setCellStyle(styleAlignRight);
    HSSFCell cell382 = row38.createCell(1);
    cell382.setCellValue(ticketAgent.getTermPayPage() != null && !"".equals(ticketAgent.getTermPayPage())
            ? ticketAgent.getTermPayPage()
            : "ALL");
    cell382.setCellStyle(styleAlignLeft);
    HSSFCell cell383 = row38.createCell(2);
    cell383.setCellValue("Page : ");
    cell383.setCellStyle(styleAlignRight);
    HSSFCell cell384 = row38.createCell(3);
    cell384.setCellValue("1 ");
    cell384.setCellStyle(styleAlignLeft);

    // Header Table
    HSSFRow row39 = sheet2.createRow(9);

    HSSFCell cell396 = row39.createCell(0);
    cell396.setCellValue("Agent");
    cell396.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(0);

    HSSFCell cell399 = row39.createCell(1);
    cell399.setCellValue("Pax");
    cell399.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(1);

    HSSFCell cell3104 = row39.createCell(2);
    cell3104.setCellValue("Amount Wendy");
    cell3104.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(2);

    HSSFCell cell3105 = row39.createCell(3);
    cell3105.setCellValue("Amount Outbound");
    cell3105.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(3);

    HSSFCell cell3106 = row39.createCell(4);
    cell3106.setCellValue("Amount Inbound");
    cell3106.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(4);

    HSSFCell cell3107 = row39.createCell(5);
    cell3107.setCellValue("Sale");
    cell3107.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(5);

    HSSFCell cell3108 = row39.createCell(6);
    cell3108.setCellValue("Cost");
    cell3108.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(6);

    HSSFCell cell3109 = row39.createCell(7);
    cell3109.setCellValue("Over Comm");
    cell3109.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(7);

    HSSFCell cell3110 = row39.createCell(8);
    cell3110.setCellValue("Add Pay");
    cell3110.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(8);

    HSSFCell cell3111 = row39.createCell(9);
    cell3111.setCellValue("Drecrease Pay");
    cell3111.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(9);

    HSSFCell cell3116 = row39.createCell(10);
    cell3116.setCellValue("Profit");
    cell3116.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(10);

    HSSFCell cell3112 = row39.createCell(11);
    cell3112.setCellValue("Comm");
    cell3112.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(11);

    HSSFCell cell3113 = row39.createCell(12);
    cell3113.setCellValue("Little Comm");
    cell3113.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(12);

    HSSFCell cell3114 = row39.createCell(13);
    cell3114.setCellValue("Agent[Comm] Pay");
    cell3114.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(13);

    HSSFCell cell3115 = row39.createCell(14);
    cell3115.setCellValue("Agent[Comm] Receive");
    cell3115.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(14);

    HSSFCell cell3117 = row39.createCell(15);
    cell3117.setCellValue("Pay");
    cell3117.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(15);

    HSSFCell cell3118 = row39.createCell(16);
    cell3118.setCellValue("Net Comm Receive");
    cell3118.setCellStyle(styleAlignRightBorderAllHeaderTable);
    sheet2.autoSizeColumn(16);

    int count2 = 10 + listAgent.size();

    if (listAgent != null) {
        for (int r = 10; r < count2; r++) {
            HSSFRow row = sheet2.createRow(r);
            HSSFCell cell1 = row.createCell(0);
            cell1.setCellValue(listAgent.get(r - 10).getAgentname());
            cell1.setCellStyle(styleDetailTable);
            HSSFCell cell2 = row.createCell(1);
            BigDecimal pax = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getPax()) ? "0" : listAgent.get(r - 10).getPax());
            cell2.setCellValue((pax != null) ? pax.doubleValue() : new BigDecimal("0").doubleValue());
            cell2.setCellStyle(stylePaxNumber);
            HSSFCell cell13 = row.createCell(2);
            BigDecimal amountwendy = new BigDecimal("".equals(listAgent.get(r - 10).getAmountwendy()) ? "0"
                    : listAgent.get(r - 10).getAmountwendy());
            cell13.setCellValue(
                    (amountwendy != null) ? amountwendy.doubleValue() : new BigDecimal("0").doubleValue());
            cell13.setCellStyle(styleDetailTableNumber);
            HSSFCell cell26 = row.createCell(3);
            BigDecimal amountout = new BigDecimal("".equals(listAgent.get(r - 10).getAmountoutbound()) ? "0"
                    : listAgent.get(r - 10).getAmountoutbound());
            cell26.setCellValue(
                    (amountout != null) ? amountout.doubleValue() : new BigDecimal("0").doubleValue());
            cell26.setCellStyle(styleDetailTableNumber);
            HSSFCell cell14 = row.createCell(4);
            BigDecimal amountin = new BigDecimal("".equals(listAgent.get(r - 10).getAmountinbound()) ? "0"
                    : listAgent.get(r - 10).getAmountinbound());
            cell14.setCellValue(
                    (amountin != null) ? amountin.doubleValue() : new BigDecimal("0").doubleValue());
            cell14.setCellStyle(styleDetailTableNumber);
            HSSFCell cell15 = row.createCell(5);
            BigDecimal sale = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getSale()) ? "0" : listAgent.get(r - 10).getSale());
            cell15.setCellValue((sale != null) ? sale.doubleValue() : new BigDecimal("0").doubleValue());
            cell15.setCellStyle(styleDetailTableNumber);
            HSSFCell cell16 = row.createCell(6);
            BigDecimal cost = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getCost()) ? "0" : listAgent.get(r - 10).getCost());
            cell16.setCellValue((cost != null) ? cost.doubleValue() : new BigDecimal("0").doubleValue());
            cell16.setCellStyle(styleDetailTableNumber);
            HSSFCell cell17 = row.createCell(7);
            BigDecimal over = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getOver()) ? "0" : listAgent.get(r - 10).getOver());
            cell17.setCellValue((over != null) ? over.doubleValue() : new BigDecimal("0").doubleValue());
            cell17.setCellStyle(styleDetailTableNumber);
            HSSFCell cell18 = row.createCell(8);
            BigDecimal add = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getAdd()) ? "0" : listAgent.get(r - 10).getAdd());
            cell18.setCellValue((add != null) ? add.doubleValue() : new BigDecimal("0").doubleValue());
            cell18.setCellStyle(styleDetailTableNumber);
            HSSFCell cell19 = row.createCell(9);
            BigDecimal dres = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getDres()) ? "0" : listAgent.get(r - 10).getDres());
            cell19.setCellValue((dres != null) ? dres.doubleValue() : new BigDecimal("0").doubleValue());
            cell19.setCellStyle(styleDetailTableNumber);
            HSSFCell cell20 = row.createCell(10);
            BigDecimal profit = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getProfit()) ? "0" : listAgent.get(r - 10).getProfit());
            cell20.setCellValue((profit != null) ? profit.doubleValue() : new BigDecimal("0").doubleValue());
            cell20.setCellStyle(styleDetailTableNumber);
            HSSFCell cell2205 = row.createCell(11);
            BigDecimal ticcom = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getTiccomm()) ? "0" : listAgent.get(r - 10).getTiccomm());
            cell2205.setCellValue((ticcom != null) ? ticcom.doubleValue() : new BigDecimal("0").doubleValue());
            cell2205.setCellStyle(styleDetailTableNumber);
            HSSFCell cell212 = row.createCell(12);
            BigDecimal little = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getLittle()) ? "0" : listAgent.get(r - 10).getLittle());
            cell212.setCellValue((little != null) ? little.doubleValue() : new BigDecimal("0").doubleValue());
            cell212.setCellStyle(styleDetailTableNumber);
            HSSFCell cell22 = row.createCell(13);
            BigDecimal agentcommpay = new BigDecimal("".equals(listAgent.get(r - 10).getAgentcommpay()) ? "0"
                    : listAgent.get(r - 10).getAgentcommpay());
            cell22.setCellValue(
                    (agentcommpay != null) ? agentcommpay.doubleValue() : new BigDecimal("0").doubleValue());
            cell22.setCellStyle(styleDetailTableNumber);
            HSSFCell cell23 = row.createCell(14);
            BigDecimal agentcommrec = new BigDecimal("".equals(listAgent.get(r - 10).getAgentcommrec()) ? "0"
                    : listAgent.get(r - 10).getAgentcommrec());
            cell23.setCellValue(
                    (agentcommrec != null) ? agentcommrec.doubleValue() : new BigDecimal("0").doubleValue());
            cell23.setCellStyle(styleDetailTableNumber);
            HSSFCell cell24 = row.createCell(15);
            BigDecimal pay = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getPay()) ? "0" : listAgent.get(r - 10).getPay());
            cell24.setCellValue((pay != null) ? pay.doubleValue() : new BigDecimal("0").doubleValue());
            cell24.setCellStyle(styleDetailTableNumber);
            HSSFCell cell25 = row.createCell(16);
            BigDecimal comm = new BigDecimal(
                    "".equals(listAgent.get(r - 10).getComm()) ? "0" : listAgent.get(r - 10).getComm());
            cell25.setCellValue((comm != null) ? comm.doubleValue() : new BigDecimal("0").doubleValue());
            cell25.setCellStyle(styleDetailTableNumber);

        }
        for (int i = 0; i < 25; i++) {
            sheet2.autoSizeColumn(i);
        }
    }

    for (int i = 0; i < 30; i++) {
        sheet.autoSizeColumn(i);
        sheet1.autoSizeColumn(i);
        sheet2.autoSizeColumn(i);
    }

    HSSFRow rowtotalAgent = sheet2.createRow(count2);
    String sumtotalpaxAgent = "SUM(B" + 11 + ":B" + (count2) + ")";
    String sumtotalamountwenAgent = "SUM(C" + 11 + ":C" + (count2) + ")";
    String sumtotalamountoutAgent = "SUM(D" + 11 + ":D" + (count2) + ")";
    String sumtotalamountinAgent = "SUM(E" + 11 + ":E" + (count2) + ")";
    String sumtotalsaleAgent = "SUM(F" + 11 + ":F" + (count2) + ")";
    String sumtotalcostAgent = "SUM(G" + 11 + ":G" + (count2) + ")";
    String sumtotaloverAgent = "SUM(H" + 11 + ":H" + (count2) + ")";
    String sumtotaladdAgent = "SUM(I" + 11 + ":I" + (count2) + ")";
    String sumtotaldresAgent = "SUM(J" + 11 + ":J" + (count2) + ")";
    String sumtotalprofitAgent = "SUM(K" + 11 + ":K" + (count2) + ")";
    String sumtotalticketcommAgent = "SUM(L" + 11 + ":L" + (count2) + ")";
    String sumtotallittleAgent = "SUM(M" + 11 + ":M" + (count2) + ")";
    String sumtotalagentcommpayAgent = "SUM(N" + 11 + ":N" + (count2) + ")";
    String sumtotalagentcommrecAgent = "SUM(O" + 11 + ":O" + (count2) + ")";
    String sumtotalpayAgent = "SUM(P" + 11 + ":P" + (count2) + ")";
    String sumtotalcommAgent = "SUM(Q" + 11 + ":Q" + (count2) + ")";
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("A"+(count + x + 2)+":B"+(count + x + 2)));
    //            sheetIncSum.addMergedRegion(CellRangeAddress.valueOf("D"+(count + x + 2)+":E"+(count + x + 2)));
    HSSFCell cellTotalSumAgent0 = rowtotalAgent.createCell(0);
    cellTotalSumAgent0.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent1 = rowtotalAgent.createCell(1);
    cellTotalSumAgent1.setCellFormula(sumtotalpaxAgent);
    cellTotalSumAgent1.setCellStyle(stylePaxNumberTotal);
    HSSFCell cellTotalSumAgent2 = rowtotalAgent.createCell(2);
    cellTotalSumAgent2.setCellFormula(sumtotalamountwenAgent);
    cellTotalSumAgent2.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent3 = rowtotalAgent.createCell(3);
    cellTotalSumAgent3.setCellFormula(sumtotalamountoutAgent);
    cellTotalSumAgent3.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent4 = rowtotalAgent.createCell(4);
    cellTotalSumAgent4.setCellFormula(sumtotalamountinAgent);
    cellTotalSumAgent4.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent5 = rowtotalAgent.createCell(5);
    cellTotalSumAgent5.setCellFormula(sumtotalsaleAgent);
    cellTotalSumAgent5.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent6 = rowtotalAgent.createCell(6);
    cellTotalSumAgent6.setCellFormula(sumtotalcostAgent);
    cellTotalSumAgent6.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent7 = rowtotalAgent.createCell(7);
    cellTotalSumAgent7.setCellFormula(sumtotaloverAgent);
    cellTotalSumAgent7.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent8 = rowtotalAgent.createCell(8);
    cellTotalSumAgent8.setCellFormula(sumtotaladdAgent);
    cellTotalSumAgent8.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent9 = rowtotalAgent.createCell(9);
    cellTotalSumAgent9.setCellFormula(sumtotaldresAgent);
    cellTotalSumAgent9.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent10 = rowtotalAgent.createCell(10);
    cellTotalSumAgent10.setCellFormula(sumtotalprofitAgent);
    cellTotalSumAgent10.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent11 = rowtotalAgent.createCell(11);
    cellTotalSumAgent11.setCellFormula(sumtotalticketcommAgent);
    cellTotalSumAgent11.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent12 = rowtotalAgent.createCell(12);
    cellTotalSumAgent12.setCellFormula(sumtotallittleAgent);
    cellTotalSumAgent12.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent13 = rowtotalAgent.createCell(13);
    cellTotalSumAgent13.setCellFormula(sumtotalagentcommpayAgent);
    cellTotalSumAgent13.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent14 = rowtotalAgent.createCell(14);
    cellTotalSumAgent14.setCellFormula(sumtotalagentcommrecAgent);
    cellTotalSumAgent14.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent15 = rowtotalAgent.createCell(15);
    cellTotalSumAgent15.setCellFormula(sumtotalpayAgent);
    cellTotalSumAgent15.setCellStyle(styleTotalTableNumber);
    HSSFCell cellTotalSumAgent16 = rowtotalAgent.createCell(16);
    cellTotalSumAgent16.setCellFormula(sumtotalcommAgent);
    cellTotalSumAgent16.setCellStyle(styleTotalTableNumber);

    //        HSSFRow rowLLL = sheet2.createRow(count2);
    //         rowLLL.createCell(0).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(1).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(2).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(3).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(4).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(5).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(6).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(7).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(8).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(9).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(10).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(11).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(12).setCellStyle(styleBorderTop);
    //         rowLLL.createCell(13).setCellStyle(styleBorderTop);
    //    rowLLL.createCell(14).setCellStyle(styleBorderTop);    
    //         rowLLL.createCell(15).setCellStyle(styleBorderTop);  
    //         rowLLL.createCell(16).setCellStyle(styleBorderTop); 

    sheet.setColumnWidth(5, 256 * 40);
    sheet.setColumnWidth(30, 256 * 12);
    sheet1.setColumnWidth(13, 256 * 12);
    sheet2.setColumnWidth(0, 256 * 40);
}