Example usage for org.apache.poi.hssf.usermodel HSSFCellStyle setVerticalAlignment

List of usage examples for org.apache.poi.hssf.usermodel HSSFCellStyle setVerticalAlignment

Introduction

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

Prototype

@Override
public void setVerticalAlignment(VerticalAlignment align) 

Source Link

Document

set the type of vertical alignment for the cell

Usage

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

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

    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(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"));
    styleC25.setAlignment(styleC25.ALIGN_RIGHT);
    styleC25.setWrapText(true);/*  w  w  w .j a  v  a 2  s .  co m*/
    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(styleC22.ALIGN_CENTER);
    styleC26.setWrapText(true);
    styleC26.setVerticalAlignment(styleC26.VERTICAL_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);
    styleC29.setWrapText(true);
    styleC29.setVerticalAlignment(styleC29.VERTICAL_CENTER);

    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(styleC30.ALIGN_CENTER);
    styleC30.setWrapText(true);
    styleC30.setVerticalAlignment(styleC30.VERTICAL_CENTER);
    if (!listBooking.isEmpty()) {
        dataheader = (BookingNonInvoiceView) listBooking.get(0);

        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cell1 = row1.createCell(0);
        cell1.setCellValue("Booking Non Invoice 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.getHeaderinvoicesup());
        cell24.setCellStyle(styleC22);

        // Row 3
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Booking Date : ");
        cell31.setCellStyle(styleC21);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(dataheader.getHeaderbookingdate());
        cell32.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
        HSSFCell cell33 = row3.createCell(4);
        cell33.setCellValue("Pay Date : ");
        cell33.setCellStyle(styleC21);
        HSSFCell cell34 = row3.createCell(5);
        cell34.setCellValue(dataheader.getHeaderpaydate());
        cell34.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);

    // Detail of Table
    String temp = "";
    int count = 4;
    int ktemp = 7;

    for (int i = 0; i < listBooking.size(); i++) {
        BookingNonInvoiceView data = (BookingNonInvoiceView) listBooking.get(i);
        if (!temp.equalsIgnoreCase(data.getInvoicesup())) {
            if (!"".equalsIgnoreCase(temp)) {
                count = count + 2;
                ktemp = count + 3 + i;
            }

            int counts = count + i;
            int countss = count + 1 + i;

            // Row Inv Sup
            HSSFRow row000 = sheet.createRow(counts);
            HSSFCell cell001 = row000.createCell(0);
            cell001.setCellValue("Invoice Sup ");
            cell001.setCellStyle(styleC3);
            HSSFCell cell002 = row000.createCell(1);
            cell002.setCellValue(data.getInvoicesup().replaceAll("\r\n", " "));
            cell002.setCellStyle(styleC29);
            HSSFCell cell003 = row000.createCell(2);
            cell003.setCellStyle(styleC29);
            HSSFCell cell004 = row000.createCell(3);
            cell004.setCellStyle(styleC29);

            sheet.addMergedRegion(CellRangeAddress.valueOf("B" + (counts + 1) + ":D" + (counts + 1)));

            temp = data.getInvoicesup();

            // Header Table
            HSSFRow row09 = sheet.createRow(countss);
            HSSFCell cell091 = row09.createCell(0);
            cell091.setCellValue("Ref No");
            cell091.setCellStyle(styleC3);
            sheet.autoSizeColumn(0);
            HSSFCell cell092 = row09.createCell(1);
            cell092.setCellValue("Booking Date");
            cell092.setCellStyle(styleC3);
            sheet.autoSizeColumn(1);
            HSSFCell cell093 = row09.createCell(2);
            cell093.setCellValue("Owner");
            sheet.autoSizeColumn(2);
            cell093.setCellStyle(styleC3);
            HSSFCell cell094 = row09.createCell(3);
            cell094.setCellValue("Pay No");
            cell094.setCellStyle(styleC3);
            sheet.autoSizeColumn(3);
            HSSFCell cell095 = row09.createCell(4);
            cell095.setCellValue("Pay Date");
            cell095.setCellStyle(styleC3);
            sheet.autoSizeColumn(4);
            //                HSSFCell cell096 = row09.createCell(5);
            //                cell096.setCellValue("Invoice Sup"); 
            //                cell096.setCellStyle(styleC3);
            //                sheet.autoSizeColumn(5);
            HSSFCell cell097 = row09.createCell(5);
            cell097.setCellValue("Description");
            cell097.setCellStyle(styleC3);
            sheet.autoSizeColumn(5);
            HSSFCell cell098 = row09.createCell(6);
            cell098.setCellValue("Pay Amount");
            cell098.setCellStyle(styleC3);
            sheet.autoSizeColumn(6);
            HSSFCell cell099 = row09.createCell(7);
            cell099.setCellValue("Currency");
            cell099.setCellStyle(styleC3);
            sheet.autoSizeColumn(7);
            HSSFCell cell100 = row09.createCell(8);
            cell100.setCellValue("Price From Billable");
            cell100.setCellStyle(styleC3);
            sheet.autoSizeColumn(8);
            HSSFCell cell101 = row09.createCell(9);
            cell101.setCellValue("Currency");
            cell101.setCellStyle(styleC3);
            sheet.autoSizeColumn(9);
            count = count + 2;
        }

        //set data 
        HSSFRow row = sheet.createRow(count + i);
        HSSFCell celldata01 = row.createCell(0);
        celldata01.setCellValue(data.getRefno());
        celldata01.setCellStyle(styleC29);
        HSSFCell celldata02 = row.createCell(1);
        celldata02.setCellValue(data.getBookdate());
        celldata02.setCellStyle(styleC29);
        HSSFCell celldata03 = row.createCell(2);
        celldata03.setCellValue(data.getOwner());
        celldata03.setCellStyle(styleC29);
        HSSFCell celldata04 = row.createCell(3);
        celldata04.setCellValue(data.getPayno());
        celldata04.setCellStyle(styleC29);
        HSSFCell celldata05 = row.createCell(4);
        celldata05.setCellValue(data.getPaydate());
        celldata05.setCellStyle(styleC29);
        //            HSSFCell celldata06 = row.createCell(5);
        //            celldata06.setCellValue(data.getInvoicesup());
        //            celldata06.setCellStyle(styleC29);
        HSSFCell celldata07 = row.createCell(5);
        celldata07.setCellValue(data.getDescription());
        celldata07.setCellStyle(styleC29);
        HSSFCell celldata08 = row.createCell(6);
        celldata08.setCellValue(data.getPayamount().trim());
        celldata08.setCellStyle(styleC25);
        HSSFCell celldata09 = row.createCell(7);
        celldata09.setCellValue(data.getCurrency());
        celldata09.setCellStyle(styleC30);
        HSSFCell celldata10 = row.createCell(8);
        celldata10.setCellValue(data.getSale().trim());
        celldata10.setCellStyle(styleC25);
        HSSFCell celldata11 = row.createCell(9);
        celldata11.setCellValue(data.getSalecurrency());
        celldata11.setCellStyle(styleC30);
    }

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

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

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

    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(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"));
    styleC25.setAlignment(styleC25.ALIGN_RIGHT);
    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);

    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);//from   w  w w  .jav a 2 s  . com
    styleC29.setVerticalAlignment(styleC29.VERTICAL_CENTER);

    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(styleC30.ALIGN_CENTER);
    styleC30.setWrapText(true);
    styleC30.setVerticalAlignment(styleC30.VERTICAL_CENTER);

    if (!listBooking.isEmpty()) {
        dataheader = (BookingInvoiceView) listBooking.get(0);

        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cell1 = row1.createCell(0);
        cell1.setCellValue("Booking Invoice 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:C2"));
        HSSFCell cell23 = row2.createCell(3);
        cell23.setCellValue("Invoice To : ");
        cell23.setCellStyle(styleC21);
        HSSFCell cell24 = row2.createCell(4);
        cell24.setCellValue(dataheader.getHeaderinvto());
        cell24.setCellStyle(styleC22);

        // Row 3
        HSSFRow row3 = sheet.createRow(2);
        HSSFCell cell31 = row3.createCell(0);
        cell31.setCellValue("Booking Date : ");
        cell31.setCellStyle(styleC21);
        HSSFCell cell32 = row3.createCell(1);
        cell32.setCellValue(dataheader.getHeaderbookingdate());
        cell32.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B3:C3"));
        HSSFCell cell33 = row3.createCell(3);
        cell33.setCellValue("Invoice Date : ");
        cell33.setCellStyle(styleC21);
        HSSFCell cell34 = row3.createCell(4);
        cell34.setCellValue(dataheader.getHeaderinvdate());
        cell34.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);

    // Header Table
    HSSFRow row09 = sheet.createRow(4);
    HSSFCell cell091 = row09.createCell(0);
    cell091.setCellValue("Ref No");
    cell091.setCellStyle(styleC3);
    sheet.autoSizeColumn(0);
    HSSFCell cell092 = row09.createCell(1);
    cell092.setCellValue("Booking Date");
    cell092.setCellStyle(styleC3);
    sheet.autoSizeColumn(1);
    HSSFCell cell093 = row09.createCell(2);
    cell093.setCellValue("Owner");
    sheet.autoSizeColumn(2);
    cell093.setCellStyle(styleC3);
    HSSFCell cell094 = row09.createCell(3);
    cell094.setCellValue("Description");
    cell094.setCellStyle(styleC3);
    sheet.autoSizeColumn(3);
    HSSFCell cell095 = row09.createCell(4);
    cell095.setCellValue("Inv No");
    cell095.setCellStyle(styleC3);
    sheet.autoSizeColumn(4);
    HSSFCell cell096 = row09.createCell(5);
    cell096.setCellValue("Inv Date");
    cell096.setCellStyle(styleC3);
    sheet.autoSizeColumn(5);
    HSSFCell cell097 = row09.createCell(6);
    cell097.setCellValue("Inv To");
    cell097.setCellStyle(styleC3);
    sheet.autoSizeColumn(6);
    HSSFCell cell098 = row09.createCell(7);
    cell098.setCellValue("Cost From Billable");
    cell098.setCellStyle(styleC3);
    sheet.autoSizeColumn(7);
    HSSFCell cell099 = row09.createCell(8);
    cell099.setCellValue("Currency");
    cell099.setCellStyle(styleC3);
    sheet.autoSizeColumn(8);

    // Detail of Table
    int count = 5;
    for (int i = 0; i < listBooking.size(); i++) {
        BookingInvoiceView data = (BookingInvoiceView) listBooking.get(i);
        //set data 
        HSSFRow row = sheet.createRow(count + i);
        HSSFCell celldata01 = row.createCell(0);
        celldata01.setCellValue(data.getRefno());
        celldata01.setCellStyle(styleC29);
        HSSFCell celldata02 = row.createCell(1);
        celldata02.setCellValue(data.getBookdate());
        celldata02.setCellStyle(styleC30);
        HSSFCell celldata03 = row.createCell(2);
        celldata03.setCellValue(data.getOwner());
        celldata03.setCellStyle(styleC29);
        HSSFCell celldata04 = row.createCell(3);
        celldata04.setCellValue(data.getDescription());
        celldata04.setCellStyle(styleC29);
        HSSFCell celldata05 = row.createCell(4);
        celldata05.setCellValue(data.getInvno());
        celldata05.setCellStyle(styleC29);
        HSSFCell celldata06 = row.createCell(5);
        celldata06.setCellValue(data.getInvdate());
        celldata06.setCellStyle(styleC29);
        HSSFCell celldata07 = row.createCell(6);
        celldata07.setCellValue(data.getInvto());
        celldata07.setCellStyle(styleC29);
        HSSFCell celldata08 = row.createCell(7);
        celldata08.setCellValue(data.getCost().trim());
        celldata08.setCellStyle(styleC25);
        HSSFCell celldata09 = row.createCell(8);
        celldata09.setCellValue(data.getCurrency());
        celldata09.setCellStyle(styleC30);

    }
    for (int j = 0; j < 10; j++) {
        sheet.autoSizeColumn(j);
    }
    sheet.setColumnWidth(4, 256 * 15);
    sheet.setColumnWidth(5, 256 * 15);
}

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

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

    OutboundHotelSummaryView dataheader = new OutboundHotelSummaryView();

    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 (!list.isEmpty()) {
        dataheader = (OutboundHotelSummaryView) list.get(0);

        // set Header Report (Row 1)
        HSSFCellStyle styleC1 = wb.createCellStyle();
        HSSFRow row1 = sheet.createRow(0);
        HSSFCell cell1 = row1.createCell(0);
        cell1.setCellValue("Hotel Summary");
        styleC1.setFont(excelFunction.getHeaderFont(wb.createFont()));
        cell1.setCellStyle(styleC1);//w  ww .jav a2  s.  c om
        sheet.addMergedRegion(CellRangeAddress.valueOf("A1:F1"));

        // Row 2
        HSSFRow row2 = sheet.createRow(1);
        HSSFCell cell21 = row2.createCell(0);
        cell21.setCellValue("Country : ");
        cell21.setCellStyle(styleC21);
        HSSFCell cell22 = row2.createCell(1);
        cell22.setCellValue(dataheader.getHeadcountry());
        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.getHeadpayby());
        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.getHeadcity());
        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.getHeadbanktransfer());
        cell34.setCellStyle(styleC22);

        // Row 4
        HSSFRow row4 = sheet.createRow(3);
        HSSFCell cell41 = row4.createCell(0);
        cell41.setCellValue("Hotel : ");
        cell41.setCellStyle(styleC21);
        HSSFCell cell42 = row4.createCell(1);
        cell42.setCellValue(dataheader.getHeadhotel());
        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.getHeadstatus());
        cell44.setCellStyle(styleC22);

        // Row 5
        HSSFRow row5 = sheet.createRow(4);
        HSSFCell cell51 = row5.createCell(0);
        cell51.setCellValue("Date : ");
        cell51.setCellStyle(styleC21);
        HSSFCell cell52 = row5.createCell(1);
        cell52.setCellValue(dataheader.getHeaddate());
        cell52.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));

    }

    // 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 row6 = sheet.createRow(6);
    HSSFCell cell61 = row6.createCell(0);
    cell61.setCellValue("SALE DATE");
    cell61.setCellStyle(styletop);
    HSSFCell cell62 = row6.createCell(1);
    cell62.setCellValue("RECORD NO");
    cell62.setCellStyle(styletop);
    HSSFCell cell63 = row6.createCell(2);
    cell63.setCellValue("REF NO");
    cell63.setCellStyle(styletop);
    HSSFCell cell64 = row6.createCell(3);
    cell64.setCellValue("HOTEL NAME");
    cell64.setCellStyle(styletop);
    HSSFCell cell65 = row6.createCell(4);
    cell65.setCellValue("CUSTOMER NAME");
    cell65.setCellStyle(styletop);
    HSSFCell cell66 = row6.createCell(5);
    cell66.setCellValue("PERIOD");
    cell66.setCellStyle(styletop);
    sheet.autoSizeColumn(5);
    HSSFCell cell67 = row6.createCell(6);
    cell67.setCellValue("PAX");
    cell67.setCellStyle(styletop);
    HSSFCell cell68 = row6.createCell(7);
    cell68.setCellValue("NETT");
    cell68.setCellStyle(styletop);
    HSSFCell cell69 = row6.createCell(8);
    cell69.setCellValue("SELLING");
    cell69.setCellStyle(styletop);
    HSSFCell cell610 = row6.createCell(9);
    cell610.setCellValue("TOTAL");
    cell610.setCellStyle(styletop);
    HSSFCell cell611 = row6.createCell(10);
    cell611.setCellValue("SALE");
    cell611.setCellStyle(styletop);
    HSSFCell cell612 = row6.createCell(11);
    cell612.setCellValue("PROFIT");
    cell612.setCellStyle(styletop);
    HSSFCell cell613 = row6.createCell(12);
    cell613.setCellValue("BANK");
    cell613.setCellStyle(styletop);
    HSSFCell cell614 = row6.createCell(13);
    cell614.setCellValue("DATE");
    cell614.setCellStyle(styletop);
    HSSFCell cell615 = row6.createCell(14);
    cell615.setCellValue("SUPPLIER");
    cell615.setCellStyle(styletop);
    HSSFCell cell616 = row6.createCell(15);
    cell616.setCellValue("STATUS");
    cell616.setCellStyle(styletop);
    HSSFCell cell617 = row6.createCell(16);
    cell617.setCellValue("REMARK");
    cell617.setCellStyle(styletop);
    HSSFCell cell618 = row6.createCell(17);
    cell618.setCellValue("SALLER");
    cell618.setCellStyle(styletop);

    sheet.addMergedRegion(CellRangeAddress.valueOf("A7:A8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("B7:B8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("C7:C8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("D7:D8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("E7:E8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("F7:F8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("G7:G8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("O7:O8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("P7:P8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("Q7:Q8"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("R7:R8"));

    HSSFRow row7 = sheet.createRow(7);
    HSSFCell cell71 = row7.createCell(0);
    cell71.setCellStyle(stylebottom);
    HSSFCell cell72 = row7.createCell(1);
    cell72.setCellStyle(stylebottom);
    HSSFCell cell73 = row7.createCell(2);
    cell73.setCellStyle(stylebottom);
    HSSFCell cell74 = row7.createCell(3);
    cell74.setCellStyle(stylebottom);
    HSSFCell cell75 = row7.createCell(4);
    cell75.setCellStyle(stylebottom);
    HSSFCell cell76 = row7.createCell(5);
    cell76.setCellStyle(stylebottom);
    //        HSSFCell cell77 = row7.createCell(6);
    //        cell77.setCellValue("OF PAX");
    //        cell77.setCellStyle(stylebottom);
    HSSFCell cell78 = row7.createCell(7);
    cell78.setCellValue("ROOM/NIGHT");
    cell78.setCellStyle(stylebottom);
    HSSFCell cell79 = row7.createCell(8);
    cell79.setCellValue("ROOM/NIGHT");
    cell79.setCellStyle(stylebottom);
    HSSFCell cell710 = row7.createCell(9);
    cell710.setCellValue("NETT");
    cell710.setCellStyle(stylebottom);
    HSSFCell cell711 = row7.createCell(10);
    cell711.setCellValue("TOTAL");
    cell711.setCellStyle(stylebottom);
    HSSFCell cell712 = row7.createCell(11);
    cell712.setCellValue("TOTAL");
    cell712.setCellStyle(stylebottom);
    HSSFCell cell713 = row7.createCell(12);
    cell713.setCellValue("TRFS");
    cell713.setCellStyle(stylebottom);
    HSSFCell cell714 = row7.createCell(13);
    cell714.setCellValue("TRFS");
    cell714.setCellStyle(stylebottom);
    HSSFCell cell715 = row7.createCell(14);
    cell715.setCellStyle(stylebottom);
    HSSFCell cell716 = row7.createCell(15);
    cell716.setCellStyle(stylebottom);
    HSSFCell cell717 = row7.createCell(16);
    cell717.setCellStyle(stylebottom);
    HSSFCell cell718 = row7.createCell(17);
    cell718.setCellStyle(stylebottom);

    //Detail of Table
    int count = 8;
    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"));

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

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

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

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

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

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

        HSSFCell celldata5 = row.createCell(5);
        celldata5.setCellValue(data.getPeriod());
        celldata5.setCellStyle(styleC23);

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

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

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

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

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

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

        HSSFCell celldata11 = row.createCell(12);
        celldata11.setCellValue(data.getBank());
        celldata11.setCellStyle(styleC24);

        HSSFCell celldata12 = row.createCell(13);
        celldata12.setCellValue(data.getTransferdate());
        celldata12.setCellStyle(styleC24);

        HSSFCell celldata15 = row.createCell(14);
        celldata15.setCellValue(data.getSupplier());
        celldata15.setCellStyle(styleC24);

        HSSFCell celldata13 = row.createCell(15);
        celldata13.setCellValue(data.getStatus());
        celldata13.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.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);/*from  www .  j a v a 2 s  .  c o  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);/*from   w  w  w  .  j av  a 2  s .  co  m*/
    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);//w  w  w.  ja va2  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  .jav  a2s  .com*/
    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.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 a  v  a2  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.RefundAirsummary.java

private void getRefundTicketDetail(HSSFWorkbook wb, List refundTicket) {
    String sheetName = "refund ticket detail";// name of sheet
    HSSFSheet sheet = wb.createSheet(sheetName);
    UtilityExcelFunction excelFunction = new UtilityExcelFunction();
    // set Header Report (Row 1)
    HSSFCellStyle styleC11 = wb.createCellStyle();
    HSSFRow row01 = sheet.createRow(0);//w w w. j a va 2s . c o  m
    HSSFCell cell01 = row01.createCell(0);
    cell01.setCellValue("List Refund Ticket Detail");
    styleC11.setFont(excelFunction.getHeaderFont(wb.createFont()));
    cell01.setCellStyle(styleC11);
    sheet.addMergedRegion(CellRangeAddress.valueOf("A1:G1"));

    // Set align Text
    HSSFDataFormat currency = wb.createDataFormat();
    HSSFCellStyle styleC21 = wb.createCellStyle();
    styleC21.setAlignment(styleC21.ALIGN_RIGHT);
    HSSFCellStyle styleC22 = wb.createCellStyle();
    styleC22.setAlignment(styleC22.ALIGN_LEFT);
    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 styleDetailTable = wb.createCellStyle();
    styleDetailTable.setAlignment(styleDetailTable.ALIGN_LEFT);
    styleDetailTable.setBorderLeft(styleDetailTable.BORDER_THIN);
    styleDetailTable.setBorderRight(styleDetailTable.BORDER_THIN);
    styleDetailTable.setWrapText(true);
    styleDetailTable.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    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);
    styleDetailTableNumber.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    HSSFCellStyle styleBorderTop = wb.createCellStyle();
    styleBorderTop.setBorderTop(styleBorderTop.BORDER_THIN);

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

    List<RefundTicketView> list = null;

    if (refundTicket != null && refundTicket.size() != 0) {
        System.out.println("Size list : " + refundTicket.size());
        list = refundTicket;
    } else {
        list = null;
    }

    if (refundTicket != null && refundTicket.size() != 0) {
        RefundTicketView refund = new RefundTicketView();
        if (list != null && list.size() != 0) {
            System.out.println("Size list  refund : " + list.size());
            refund = (RefundTicketView) list.get(0);
        } else {
            refund = null;
        }

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

        // Row 3
        HSSFRow row03 = sheet.createRow(2);
        HSSFCell cell031 = row03.createCell(0);
        cell031.setCellValue("Refund By : ");
        cell031.setCellStyle(styleC21);
        HSSFCell cell032 = row03.createCell(1);
        cell032.setCellValue(refund.getRefundbyPage());
        cell032.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
        HSSFCell cell033 = row03.createCell(4);
        cell033.setCellValue("Receive : ");
        cell033.setCellStyle(styleC21);
        HSSFCell cell034 = row03.createCell(5);
        cell034.setCellValue(refund.getReceivePage());
        cell034.setCellStyle(styleC22);

        // Row 4
        HSSFRow row04 = sheet.createRow(3);
        HSSFCell cell041 = row04.createCell(0);
        cell041.setCellValue("Passenger : ");
        cell041.setCellStyle(styleC21);
        HSSFCell cell042 = row04.createCell(1);
        cell042.setCellValue(refund.getPassengerPage());
        cell042.setCellStyle(styleC22);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B4:D4"));
        HSSFCell cell043 = row04.createCell(4);
        cell043.setCellValue("Paid : ");
        cell043.setCellStyle(styleC21);
        HSSFCell cell044 = row04.createCell(5);
        cell044.setCellValue(refund.getPaidPage());
        cell044.setCellStyle(styleC22);

        // Row 5
        HSSFRow row05 = sheet.createRow(4);
        HSSFCell cell051 = row05.createCell(0);
        cell051.setCellValue("Selector To Be Refund : ");
        cell051.setCellStyle(styleC21);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B5:D5"));
        HSSFCell cell052 = row05.createCell(1);
        cell052.setCellValue(refund.getSelectorrefundPage());
        cell052.setCellStyle(styleC22);
        HSSFCell cell053 = row05.createCell(4);
        cell053.setCellValue("Type Print : ");
        cell053.setCellStyle(styleC21);
        sheet.autoSizeColumn(4);
        HSSFCell cell054 = row05.createCell(5);
        cell054.setCellValue(refund.getTypeprintPage());
        cell054.setCellStyle(styleC22);

        // Row 6
        HSSFRow row06 = sheet.createRow(5);
        HSSFCell cell611 = row06.createCell(0);
        cell611.setCellValue("Print on : ");
        cell611.setCellStyle(styleC21);
        sheet.addMergedRegion(CellRangeAddress.valueOf("B6:D6"));
        HSSFCell cell621 = row06.createCell(1);
        cell621.setCellValue(refund.getPrintondatePage());
        cell621.setCellStyle(styleC22);
        HSSFCell cell063 = row06.createCell(4);
        cell063.setCellValue("Page : ");
        cell063.setCellStyle(styleC21);
        HSSFCell cell064 = row06.createCell(5);
        cell064.setCellValue("1 ");
        cell064.setCellStyle(styleC22);

        // Header Table
        HSSFRow row6 = sheet.createRow(8);
        HSSFCell cell61 = row6.createCell(0);
        cell61.setCellValue("Refund No");
        cell61.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(0);
        HSSFCell cell62 = row6.createCell(1);
        cell62.setCellValue("Refund Date");
        cell62.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(1);
        HSSFCell cell63 = row6.createCell(2);
        cell63.setCellValue("Air");
        sheet.autoSizeColumn(2);
        cell63.setCellStyle(styleAlignRightBorderAllHeaderTable);
        HSSFCell cell65 = row6.createCell(3);
        cell65.setCellValue("Doc No");
        cell65.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(3);
        HSSFCell cell66 = row6.createCell(4);
        cell66.setCellValue("Airline Agent");
        cell66.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(5);
        HSSFCell cell67 = row6.createCell(5);
        cell67.setCellValue("Agent");
        cell67.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(5);
        HSSFCell cell677 = row6.createCell(6);
        cell677.setCellValue("Passenger");
        cell677.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(6);
        HSSFCell cell68 = row6.createCell(7);
        cell68.setCellValue("Sector Refund");
        cell68.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(7);
        HSSFCell cell69 = row6.createCell(8);
        cell69.setCellValue("Receive Airline");
        cell69.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(8);
        HSSFCell cell71 = row6.createCell(9);
        cell71.setCellValue("Receive Date");
        cell71.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(9);
        HSSFCell cell72 = row6.createCell(10);
        cell72.setCellValue("Pay No");
        cell72.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(10);
        HSSFCell cell73 = row6.createCell(11);
        cell73.setCellValue("Export");
        cell73.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(11);
        HSSFCell cell74 = row6.createCell(12);
        cell74.setCellValue("Pay Date");
        cell74.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(12);
        HSSFCell cell75 = row6.createCell(13);
        cell75.setCellValue("Pay Customer");
        cell75.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(13);
        HSSFCell cell76 = row6.createCell(14);
        cell76.setCellValue("Airline Comm");
        cell76.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(14);
        HSSFCell cell77 = row6.createCell(15);
        cell77.setCellValue("Profit");
        cell77.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(15);
        HSSFCell cell78 = row6.createCell(16);
        cell78.setCellValue("Invoice");
        cell78.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(16);
        HSSFCell cell79 = row6.createCell(17);
        cell79.setCellValue("Receipt");
        cell79.setCellStyle(styleAlignRightBorderAllHeaderTable);
        sheet.autoSizeColumn(17);

        List<RefundTicketView> listRefund = refundTicket;

        for (int r = 0; r < listRefund.size(); r++) {
            System.out.println("Refund No: " + listRefund.get(r).getRefundno());
        }

        int count = 9 + listRefund.size();
        int startSum = 1;
        int endSum = 1;
        int numSum = 0;

        for (int r = 9; r < count; r++) {
            HSSFRow row = sheet.createRow(r);
            HSSFCell cell1 = row.createCell(0);
            cell1.setCellValue(listRefund.get(r - 9).getRefundno());
            cell1.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(0);
            HSSFCell cell2 = row.createCell(1);
            cell2.setCellValue(listRefund.get(r - 9).getRefunddate());
            cell2.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(1);
            HSSFCell cell3 = row.createCell(2);
            cell3.setCellValue(listRefund.get(r - 9).getAir());
            cell3.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(2);
            HSSFCell cell4 = row.createCell(3);
            cell4.setCellValue(listRefund.get(r - 9).getDocno());
            cell4.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(3);
            HSSFCell cell55 = row.createCell(4);
            cell55.setCellValue(listRefund.get(r - 9).getAirlineagentname());
            cell55.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(4);
            HSSFCell cell5 = row.createCell(5);
            cell5.setCellValue(listRefund.get(r - 9).getAgent());
            cell5.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(5);
            HSSFCell cell6 = row.createCell(6);
            cell6.setCellValue(listRefund.get(r - 9).getPassenger());
            cell6.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(6);
            HSSFCell cell7 = row.createCell(7);
            cell7.setCellValue(listRefund.get(r - 9).getSectorrefund());
            cell7.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(7);
            HSSFCell cell8 = row.createCell(8);
            System.out.println(
                    "(listRefund.get(r-9).getReceiveairline() : " + listRefund.get(r - 9).getReceiveairline());
            BigDecimal cancel = new BigDecimal((listRefund.get(r - 9).getReceiveairline() == null)
                    || ("".equalsIgnoreCase(listRefund.get(r - 9).getReceiveairline())) ? "0"
                            : listRefund.get(r - 9).getReceiveairline());
            cell8.setCellValue((cancel != null) ? cancel.doubleValue() : new BigDecimal("0").doubleValue());
            cell8.setCellStyle(styleDetailTableNumber);
            sheet.autoSizeColumn(8);
            HSSFCell cell9 = row.createCell(9);
            cell9.setCellValue(listRefund.get(r - 9).getReceivedate());
            cell9.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(9);
            HSSFCell cell10 = row.createCell(10);
            cell10.setCellValue(listRefund.get(r - 9).getPayno());
            cell10.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(10);
            HSSFCell cell11 = row.createCell(11);
            cell11.setCellValue(listRefund.get(r - 9).getExport());
            cell11.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(11);
            HSSFCell cell12 = row.createCell(12);
            cell12.setCellValue(listRefund.get(r - 9).getPaydate());
            cell12.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(12);
            HSSFCell cell13 = row.createCell(13);
            BigDecimal payc = new BigDecimal(listRefund.get(r - 9).getPaycustomer());
            cell13.setCellValue((payc != null) ? payc.doubleValue() : new BigDecimal("0").doubleValue());
            cell13.setCellStyle(styleDetailTableNumber);
            sheet.autoSizeColumn(13);
            HSSFCell cell14 = row.createCell(14);
            BigDecimal wait = new BigDecimal(listRefund.get(r - 9).getAirlinecomm());
            cell14.setCellValue((wait != null) ? wait.doubleValue() : new BigDecimal("0").doubleValue());
            cell14.setCellStyle(styleDetailTableNumber);
            sheet.autoSizeColumn(14);
            HSSFCell cell15 = row.createCell(15);
            BigDecimal profit = new BigDecimal(listRefund.get(r - 9).getProfit());
            cell15.setCellValue((profit != null) ? profit.doubleValue() : new BigDecimal("0").doubleValue());
            cell15.setCellStyle(styleDetailTableNumber);
            sheet.autoSizeColumn(15);
            HSSFCell cell16 = row.createCell(16);
            cell16.setCellValue(listRefund.get(r - 9).getInvoice());
            cell16.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(16);
            HSSFCell cell17 = row.createCell(17);
            cell17.setCellValue(listRefund.get(r - 9).getReceipt());
            cell17.setCellStyle(styleDetailTable);
            sheet.autoSizeColumn(17);

            if (r == (count - 1)) {
                HSSFRow rows = sheet.createRow(r + 1);

                String totalRec = "SUM(I" + 10 + ":I" + (count) + ")";
                String totalPay = "SUM(N" + 10 + ":N" + (count) + ")";
                String totalCom = "SUM(O" + 10 + ":O" + (count) + ")";
                String totalPro = "SUM(P" + 10 + ":P" + (count) + ")";

                HSSFCellStyle styletotalword = wb.createCellStyle();
                styletotalword.setAlignment(styletotal.ALIGN_CENTER);
                styletotalword.setBorderTop(styletotal.BORDER_THIN);
                styletotalword.setBorderBottom(styletotal.BORDER_THIN);

                HSSFCell celldatas01 = rows.createCell(7);
                celldatas01.setCellValue("Total");
                celldatas01.setCellStyle(styletotalword);
                HSSFCell celldatas02 = rows.createCell(8);
                celldatas02.setCellFormula(totalRec);
                celldatas02.setCellStyle(styletotal);
                HSSFCell celldatas03 = rows.createCell(13);
                celldatas03.setCellFormula(totalPay);
                celldatas03.setCellStyle(styletotal);
                HSSFCell celldatas04 = rows.createCell(14);
                celldatas04.setCellFormula(totalCom);
                celldatas04.setCellStyle(styletotal);
                HSSFCell celldatas05 = rows.createCell(15);
                celldatas05.setCellFormula(totalPro);
                celldatas05.setCellStyle(styletotal);

                rows.createCell(0).setCellStyle(styleBorderTop);
                rows.createCell(1).setCellStyle(styleBorderTop);
                rows.createCell(2).setCellStyle(styleBorderTop);
                rows.createCell(3).setCellStyle(styleBorderTop);
                rows.createCell(4).setCellStyle(styleBorderTop);
                rows.createCell(5).setCellStyle(styleBorderTop);
                rows.createCell(6).setCellStyle(styleBorderTop);

                rows.createCell(9).setCellStyle(styleBorderTop);
                rows.createCell(10).setCellStyle(styleBorderTop);
                rows.createCell(11).setCellStyle(styleBorderTop);
                rows.createCell(12).setCellStyle(styleBorderTop);
                rows.createCell(16).setCellStyle(styleBorderTop);
                rows.createCell(17).setCellStyle(styletotal);

                HSSFRow rowL = sheet.createRow(r + 2);
                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(9).setCellStyle(styleBorderTop);
                rowL.createCell(10).setCellStyle(styleBorderTop);
                rowL.createCell(11).setCellStyle(styleBorderTop);
                rowL.createCell(12).setCellStyle(styleBorderTop);
                rowL.createCell(16).setCellStyle(styleBorderTop);
                rowL.createCell(17).setCellStyle(styleBorderTop);
            }
        }
    } else {
        HSSFRow row02_2 = sheet.createRow(1);
        HSSFCell cell021 = row02_2.createCell(0);
        cell021.setCellValue("No Data");
        cell021.setCellStyle(styleC21);
        sheet.autoSizeColumn(0);
    }
}

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

private void getStockInvoiceSummary(HSSFWorkbook wb, List stockInvoiceSummary) {
    String sheetStockInvoiceSummary = "StockInvoiceSummary";// name of sheet

    UtilityExcelFunction excelFunction = new UtilityExcelFunction();

    HSSFSheet sheet = wb.createSheet(sheetStockInvoiceSummary);

    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(styleC23.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.setVerticalAlignment(styleC25.VERTICAL_CENTER);
    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);
    styleC29.setVerticalAlignment(styleC29.VERTICAL_CENTER);

    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(styleC30.ALIGN_CENTER);
    styleC30.setVerticalAlignment(styleC30.VERTICAL_CENTER);

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

    HSSFCellStyle styleC32 = wb.createCellStyle();
    styleC32.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC32.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC32.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC32.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC32.setAlignment(styleC32.ALIGN_CENTER);
    styleC32.setVerticalAlignment(styleC32.VERTICAL_CENTER);
    styleC32.setWrapText(true);/*w  ww  . ja  v a2s.co m*/

    HSSFCellStyle styleC33 = wb.createCellStyle();
    styleC33.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    styleC33.setBorderRight(HSSFCellStyle.BORDER_THIN);
    styleC33.setBorderTop(HSSFCellStyle.BORDER_THIN);
    styleC33.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    styleC33.setAlignment(styleC33.ALIGN_LEFT);
    styleC33.setVerticalAlignment(styleC33.VERTICAL_CENTER);
    styleC33.setWrapText(true);

    StockInvoiceSummaryView dataheader = (StockInvoiceSummaryView) stockInvoiceSummary.get(0);

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

    // Row 2
    HSSFRow row2 = sheet.createRow(1);
    HSSFCell cell21 = row2.createCell(0);
    cell21.setCellValue("Product : ");
    cell21.setCellStyle(styleC21);
    HSSFCell cell22 = row2.createCell(1);
    cell22.setCellValue(dataheader.getProductHeader());
    cell22.setCellStyle(styleC22);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B2:D2"));
    HSSFCell cell23 = row2.createCell(4);
    cell23.setCellValue("Inv To : ");
    cell23.setCellStyle(styleC21);
    HSSFCell cell24 = row2.createCell(5);
    cell24.setCellValue(dataheader.getInvtoHeader());
    cell24.setCellStyle(styleC22);
    sheet.addMergedRegion(CellRangeAddress.valueOf("F2:I2"));

    // Row 3
    HSSFRow row3 = sheet.createRow(2);
    HSSFCell cell31 = row3.createCell(0);
    cell31.setCellValue("Effective Date : ");
    cell31.setCellStyle(styleC21);
    HSSFCell cell32 = row3.createCell(1);
    cell32.setCellValue(dataheader.getEffectivedateHeader());
    cell32.setCellStyle(styleC22);
    sheet.addMergedRegion(CellRangeAddress.valueOf("B3:D3"));
    HSSFCell cell33 = row3.createCell(4);
    cell33.setCellValue("Invoice Date : ");
    cell33.setCellStyle(styleC21);
    HSSFCell cell34 = row3.createCell(5);
    cell34.setCellValue(dataheader.getInvoicedateHeader());
    cell34.setCellStyle(styleC22);
    sheet.addMergedRegion(CellRangeAddress.valueOf("F3:I3"));

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

    // 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);

    HSSFRow row5 = sheet.createRow(5);
    HSSFCell cell51 = row5.createCell(0);
    cell51.setCellValue("Item No");
    cell51.setCellStyle(styletop);
    HSSFCell cell62 = row5.createCell(1);
    cell62.setCellValue("Item type");
    cell62.setCellStyle(styletop);
    HSSFCell cell63 = row5.createCell(2);
    cell63.setCellValue("Ref No");
    cell63.setCellStyle(styletop);
    HSSFCell cell64 = row5.createCell(3);
    cell64.setCellValue("Owner");
    cell64.setCellStyle(styletop);
    HSSFCell cell65 = row5.createCell(4);
    cell65.setCellValue("Inv No");
    cell65.setCellStyle(styletop);
    HSSFCell cell66 = row5.createCell(5);
    cell66.setCellValue("Inv Name");
    cell66.setCellStyle(styletop);
    sheet.autoSizeColumn(5);
    HSSFCell cell67 = row5.createCell(6);
    cell67.setCellValue("Inv Date");
    cell67.setCellStyle(styletop);
    HSSFCell cell68 = row5.createCell(7);
    cell68.setCellValue("Cost");
    cell68.setCellStyle(styletop);
    HSSFCell cell69 = row5.createCell(8);
    cell69.setCellValue("Sale Price");
    cell69.setCellStyle(styletop);
    HSSFCell cell610 = row5.createCell(9);
    cell610.setCellValue("Profit");
    cell610.setCellStyle(styletop);
    HSSFCell cell611 = row5.createCell(10);
    cell611.setCellValue("Stock No");
    cell611.setCellStyle(styletop);

    //Detail of Table
    int count = 6;
    boolean isMerge = false;
    int hMerge = 7;
    int countMerge = 0;

    for (int i = 0; i < stockInvoiceSummary.size(); i++) {
        StockInvoiceSummaryView data = (StockInvoiceSummaryView) stockInvoiceSummary.get(i);
        StockInvoiceSummaryView dataTemp = new StockInvoiceSummaryView();
        if (i != stockInvoiceSummary.size() - 1) {
            dataTemp = (StockInvoiceSummaryView) stockInvoiceSummary.get(i + 1);

        } else {
            dataTemp = null;
        }

        HSSFRow row = sheet.createRow(count + i);
        String id = (data.getId() != null ? data.getId() : "");
        String idTemp = (dataTemp != null ? dataTemp.getId() : "");
        countMerge++;

        HSSFCell celldata0 = row.createCell(0);
        celldata0.setCellValue(
                !"".equalsIgnoreCase(data.getItemno()) && data.getItemno() != null ? data.getItemno() : "");
        celldata0.setCellStyle(styleC30);

        HSSFCell celldata1 = row.createCell(1);
        celldata1.setCellValue(
                !"".equalsIgnoreCase(data.getItemtype()) && data.getItemtype() != null ? data.getItemtype()
                        : "");
        celldata1.setCellStyle(styleC30);

        HSSFCell celldata2 = row.createCell(2);
        celldata2.setCellValue(
                !"".equalsIgnoreCase(data.getRefno()) && data.getRefno() != null ? data.getRefno() : "");
        celldata2.setCellStyle(styleC30);

        HSSFCell celldata3 = row.createCell(3);
        celldata3.setCellValue(
                !"".equalsIgnoreCase(data.getOwner()) && data.getOwner() != null ? data.getOwner() : "");
        celldata3.setCellStyle(styleC30);

        HSSFCell celldata4 = row.createCell(4);
        celldata4.setCellValue(
                !"".equalsIgnoreCase(data.getInvno()) && data.getInvno() != null ? data.getInvno() : "");
        celldata4.setCellStyle(styleC33);

        HSSFCell celldata5 = row.createCell(5);
        celldata5.setCellValue(
                !"".equalsIgnoreCase(data.getInvname()) && data.getInvname() != null ? data.getInvname() : "");
        celldata5.setCellStyle(styleC29);

        HSSFCell celldata6 = row.createCell(6);
        celldata6.setCellValue(
                !"".equalsIgnoreCase(data.getInvdate()) && data.getInvdate() != null ? data.getInvdate() : "");
        celldata6.setCellStyle(styleC33);

        HSSFCell celldata7 = row.createCell(7);
        celldata7.setCellValue(!"".equalsIgnoreCase(data.getCost()) && data.getCost() != null
                ? new BigDecimal(data.getCost()).doubleValue()
                : 0);
        celldata7.setCellStyle(styleC25);

        HSSFCell celldata8 = row.createCell(8);
        celldata8.setCellValue(!"".equalsIgnoreCase(data.getSaleprice()) && data.getSaleprice() != null
                ? new BigDecimal(data.getSaleprice()).doubleValue()
                : 0);
        celldata8.setCellStyle(styleC25);

        HSSFCell celldata9 = row.createCell(9);
        celldata9.setCellValue(!"".equalsIgnoreCase(data.getProfit()) && data.getProfit() != null
                ? new BigDecimal(data.getProfit()).doubleValue()
                : 0);
        celldata9.setCellStyle(styleC25);

        HSSFCell celldata10 = row.createCell(10);
        celldata10.setCellValue(
                !"".equalsIgnoreCase(data.getStockno()) && data.getStockno() != null ? data.getStockno() : "");
        celldata10.setCellStyle(styleC29);

        //            HSSFCell celldata11 = row.createCell(11);
        //            celldata11.setCellValue(!"".equalsIgnoreCase(data.getId()) && data.getId() != null ? data.getId() : "");
        //            celldata11.setCellStyle(styleC29);

        if (!id.equalsIgnoreCase(idTemp) && (!"".equalsIgnoreCase(id) || !"".equalsIgnoreCase(idTemp))) {
            if (countMerge > 1) {
                sheet.addMergedRegion(
                        CellRangeAddress.valueOf("H" + (hMerge) + ":H" + (hMerge + (countMerge - 1))));
                sheet.addMergedRegion(
                        CellRangeAddress.valueOf("I" + (hMerge) + ":I" + (hMerge + (countMerge - 1))));
                sheet.addMergedRegion(
                        CellRangeAddress.valueOf("J" + (hMerge) + ":J" + (hMerge + (countMerge - 1))));
                sheet.addMergedRegion(
                        CellRangeAddress.valueOf("K" + (hMerge) + ":K" + (hMerge + (countMerge - 1))));
            }

            hMerge = 7 + i + 1;
            countMerge = 0;
        }

        //            HSSFCell celldata11 = row.createCell(11);
        //            celldata11.setCellValue(!"".equalsIgnoreCase(data.getId()) && data.getId() != null ? data.getId() : "");
        //            celldata11.setCellStyle(styleC29);

    }

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

    //        sheet.setColumnWidth(0, 256*15);
    //        sheet.setColumnWidth(1, 256*15);
    //        sheet.setColumnWidth(2, 256*15);
    sheet.setColumnWidth(6, 256 * 10);
    sheet.setColumnWidth(7, 256 * 15);
    sheet.setColumnWidth(8, 256 * 15);
    sheet.setColumnWidth(9, 256 * 15);
    sheet.setColumnWidth(10, 256 * 60);
    //        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);

}