Example usage for org.apache.poi.hssf.usermodel HSSFCell setCellValue

List of usage examples for org.apache.poi.hssf.usermodel HSSFCell setCellValue

Introduction

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

Prototype

@SuppressWarnings("fallthrough")
public void setCellValue(boolean value) 

Source Link

Document

set a boolean value for the cell

Usage

From source file:com.ibm.ioes.bulkupload.utilities.ErrorLogServiceImpl.java

@SuppressWarnings("deprecation")
public String getErrorExcel(String filePath, int fileID) throws IOESException {
    //logger.info(" Entered into getErrorExcel method of " + this.getClass().getSimpleName());

    int colCount, ctr = 0;
    String fileName;/*from ww  w.  j  a v  a 2s.  c  o m*/
    HSSFWorkbook wb;
    HSSFSheet ws;
    HSSFRow wr;
    HSSFCell wc;
    ArrayList errVal = new ArrayList();
    ErrorFileDaoImpl objDao = new ErrorFileDaoImpl();
    ErrorLogDto dtoObj;
    BillingTriggerValidation validateDto = null;

    try {
        ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");

        fileName = filePath.substring((filePath.lastIndexOf("/") + 1), filePath.length());
        String newFile = bundle.getString("excel.errors") + "/" + fileName;
        FileOutputStream fileOut = new FileOutputStream(newFile);
        wb = new HSSFWorkbook(new FileInputStream(filePath));

        errVal = objDao.getErrorLog(fileID);
        System.out.println(errVal.toString());
        System.out.println(wb.getNumberOfSheets());
        for (int s = 0; s < wb.getNumberOfSheets(); s++) {

            ws = wb.getSheetAt(s);
            wr = ws.getRow(1);
            colCount = wr.getLastCellNum();
            wc = wr.createCell(colCount);
            wc.setCellValue("ERROR LOG");

            for (int r = 2; r <= ws.getLastRowNum(); r++) {
                if ((ctr < errVal.size())) {
                    dtoObj = (ErrorLogDto) errVal.get(ctr);
                    wr = ws.getRow(r);
                    if (wr != null) {
                        int chk = 0;
                        for (int col = 0; col < colCount; col++) {
                            wc = wr.getCell(col);
                            if (wc != null) {
                                if (!(wc.toString().trim().equals(""))) {
                                    chk = 1;
                                }
                            }
                        }
                        if (chk == 1) {
                            wc = wr.createCell(colCount);
                            System.out.println(dtoObj.getErrorLogValue());
                            if (dtoObj.getErrorLogValue() == null) {
                                wc.setCellValue("No Errors");
                            } else {
                                wc.setCellValue(dtoObj.getErrorLogValue().toString());
                            }

                            ctr++;
                        }
                    }
                }
            }
        }
        wb.write(fileOut);
        fileOut.close();
        filePath = newFile;
    } catch (IOESException ex) {
        logger.error(ex.getMessage() + "::BULKUPLOAD_ERROR:: Exception occured in getErrorExcel method of "
                + this.getClass().getSimpleName());
        throw new IOESException("SQL Exception : " + ex.getMessage(), ex);
    } catch (IOException ioExp) {
        //logger.error(ioExp.getMessage() + " Exception occured in getErrorExcel method of " + this.getClass().getSimpleName());
        //throw new IOESException("SQL Exception : "+ ioExp.getMessage(), ioExp);
        Utility.LOG(true, false, ioExp, "::BULKUPLOAD_ERROR:: Exception occured in getErrorExcel method of "
                + this.getClass().getSimpleName());
        return filePath = "NOTFOUND";
    }
    return filePath;
}

From source file:com.ibm.ioes.bulkupload.utilities.ErrorLogServiceImpl.java

public String getResultExcel(String filePath, int fileID) throws IOESException {
    //logger.info(" Entered into getErrorExcel method of " + this.getClass().getSimpleName());

    int colCount, ctr = 0;
    String fileName;/*from w  w w  .  j a v  a  2 s  . c o m*/
    HSSFWorkbook wb;
    HSSFSheet ws;
    HSSFRow wr;
    HSSFCell wc;
    ArrayList errVal = new ArrayList();
    ErrorFileDaoImpl objDao = new ErrorFileDaoImpl();
    ErrorLogDto dtoObj;

    try {
        ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");

        fileName = filePath.substring((filePath.lastIndexOf("/") + 1), filePath.length());
        String newFile = bundle.getString("excel.success") + "/" + fileName;
        FileOutputStream fileOut = new FileOutputStream(newFile);
        wb = new HSSFWorkbook(new FileInputStream(filePath));

        errVal = objDao.getResultLog(fileID);
        System.out.println(errVal.toString());
        System.out.println(wb.getNumberOfSheets());
        for (int s = 0; s < wb.getNumberOfSheets(); s++) {

            ws = wb.getSheetAt(s);
            wr = ws.getRow(1);
            colCount = wr.getLastCellNum();
            wc = wr.createCell(colCount);
            wc.setCellValue("RESULT LOG" + "_" + "ORDERNO");

            for (int r = 2; r <= ws.getLastRowNum(); r++) {
                if ((ctr < errVal.size())) {
                    dtoObj = (ErrorLogDto) errVal.get(ctr);
                    wr = ws.getRow(r);
                    if (wr != null) {
                        int chk = 0;
                        for (int col = 0; col < colCount; col++) {
                            wc = wr.getCell(col);
                            if (wc != null) {
                                if (!(wc.toString().trim().equals(""))) {
                                    chk = 1;
                                }
                            }
                        }
                        if (chk == 1) {
                            wc = wr.createCell(colCount);
                            System.out.println(dtoObj.getResultLogValue());
                            if (dtoObj.getResultLogValue() == null) {
                                wc.setCellValue("SUCCESS");
                            } else {
                                if (dtoObj.getOrderNo() != null)
                                    wc.setCellValue(dtoObj.getResultLogValue().toString() + "_("
                                            + dtoObj.getOrderNo().toString() + ")");
                            }

                            ctr++;
                        }
                    }
                }
            }
        }
        wb.write(fileOut);
        fileOut.close();
        filePath = newFile;
    } catch (IOESException ex) {
        logger.error(ex.getMessage() + "::BULKUPLOAD_ERROR:: Exception occured in getResultExcel method of "
                + this.getClass().getSimpleName());
        throw new IOESException("SQL Exception : " + ex.getMessage(), ex);
    } catch (IOException ioExp) {
        //logger.error(ioExp.getMessage() + " Exception occured in getErrorExcel method of " + this.getClass().getSimpleName());
        //throw new IOESException("SQL Exception : "+ ioExp.getMessage(), ioExp);
        Utility.LOG(true, false, ioExp, "::BULKUPLOAD_ERROR:: Exception occured in getResultExcel method of "
                + this.getClass().getSimpleName());
        return filePath = "NOTFOUND";
    }
    return filePath;
}

From source file:com.ibm.ioes.bulkupload.utilities.ErrorLogServiceImpl.java

public String getFilledTemplate(String filePath, int templateId, int flag, String logicalLSI)
        throws IOESException, ParseException {
    //logger.info(" Entered into getErrorExcel method of " + this.getClass().getSimpleName());

    String fileName;/*from  w w w.j  a v a  2  s  .c o m*/
    HSSFWorkbook wb;
    HSSFSheet ws;
    HSSFRow wr;
    HSSFCell wc;
    ArrayList filledTemplateData = new ArrayList();
    ArrayList<ViewOrderDto> filledTemplateDataLineDetails = new ArrayList<ViewOrderDto>();
    ArrayList<ViewOrderDto> filledTemplateDataChargeDetails = new ArrayList<ViewOrderDto>();
    ErrorFileDaoImpl objDao = new ErrorFileDaoImpl();
    ViewOrderModel objviewmodel = new ViewOrderModel();
    //ErrorLogDto dtoObj ;
    TransactionTemplateDto dtoObj;
    ViewOrderDto dtoObj1;
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    int totalRowsOfSheet = 0;
    ViewOrderDto objdto = null;
    String str = null;
    BillingTriggerValidation validateDto = null;
    try {
        ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");

        fileName = filePath.substring((filePath.lastIndexOf("/") + 1), filePath.length());
        String newFile = bundle.getString("excel.filledTemplate") + "/" + fileName;
        FileOutputStream fileOut = new FileOutputStream(newFile);
        wb = new HSSFWorkbook(new FileInputStream(filePath));
        HSSFCellStyle whiteFG_yellow = wb.createCellStyle();

        HSSFColor yellow = setColor(wb, (byte) 0xFF, (byte) 0xFF, (byte) 0x00);
        //whiteFG_yellow.setFillBackgroundColor(HSSFColor.YELLOW.index);
        whiteFG_yellow.setFillBackgroundColor(yellow.getIndex());

        HSSFCellStyle whiteFG_green = wb.createCellStyle();
        HSSFColor green = setColor(wb, (byte) 0x00, (byte) 0xFF, (byte) 0x00);
        //whiteFG_green.setFillBackgroundColor(HSSFColor.GREEN.index);
        whiteFG_green.setFillBackgroundColor(green.getIndex());

        //System.out.println(filledTemplateData.toString());
        //System.out.println(wb.getNumberOfSheets());

        for (int s = 0; s < wb.getNumberOfSheets(); s++) {
            ws = wb.getSheetAt(s);
            if (s == 0 && (templateId == 1 || templateId == 22 || templateId == 21 || templateId == 41)) {
                int ctr = 0, totalRowsOfSheetMain = 0, totalRowsOfSheetAtt = 0;
                totalRowsOfSheetMain = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);
                for (int r = 2; r <= (totalRowsOfSheetMain + 1); r++) {
                    dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                    wr = ws.createRow(r);
                    if (wr != null) {
                        wr.createCell(1).setCellValue(dtoObj.getOrderNo());
                        wr.createCell(2).setCellValue(new HSSFRichTextString((dtoObj.getAccountID())));
                        wr.createCell(3).setCellValue(new HSSFRichTextString((dtoObj.getSource())));
                        wr.createCell(4).setCellValue(new HSSFRichTextString((dtoObj.getCurrencyID())));
                        wr.createCell(5).setCellValue(new HSSFRichTextString((dtoObj.getOpportunityId())));
                        wr.createCell(6).setCellValue(new HSSFRichTextString((dtoObj.getQuoteNo())));
                        wr.createCell(7).setCellValue(new HSSFRichTextString((dtoObj.getProjectMangerID())));
                        wr.createCell(8).setCellValue(new HSSFRichTextString((dtoObj.getZoneId())));
                    }
                    ctr++;
                }
                totalRowsOfSheetAtt = objDao.getTotalRowsOfSheet(11, templateId, flag, logicalLSI);
                filledTemplateData = objDao.getFilledTemplate(11, templateId, flag, logicalLSI);
                ctr = 0;
                for (int r = 2; r <= (totalRowsOfSheetMain + 1); r++) {
                    wr = ws.getRow(r);
                    dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                    if (wr != null) {
                        wr.createCell(9).setCellValue(new HSSFRichTextString((dtoObj.getRFSDate())));
                        wr.createCell(10).setCellValue(new HSSFRichTextString((dtoObj.getActMngrPhoneNo())));
                        wr.createCell(11).setCellValue(new HSSFRichTextString((dtoObj.getActMngrEmailID())));
                        wr.createCell(12).setCellValue(new HSSFRichTextString((dtoObj.getIRUOrderYN())));
                        wr.createCell(13).setCellValue(new HSSFRichTextString((dtoObj.getFreePeriodYN())));
                        wr.createCell(14).setCellValue(new HSSFRichTextString((dtoObj.getOrdExclusiveTax())));
                        wr.createCell(15).setCellValue(new HSSFRichTextString((dtoObj.getCAFDate())));
                    }
                    ctr++;
                }
            }
            //GAM Sheet
            if (s == 1 && (templateId == 1 || templateId == 22 || templateId == 21 || templateId == 41)) {
                //to do nothing
            }
            //Contact Sheet
            if (s == 2 && (templateId == 1 || templateId == 22 || templateId == 21 || templateId == 41)) {
                int ctr = 0, rownum = 1;
                totalRowsOfSheet = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);

                for (int r = 2; r <= (totalRowsOfSheet + 1); r++) {
                    dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                    wr = ws.createRow(r);
                    if (wr != null) {
                        wr.createCell(1).setCellValue(rownum);
                        wr.createCell(2).setCellValue(dtoObj.getOrderNo());
                        wr.createCell(3).setCellValue(dtoObj.getContactType());
                        wr.createCell(4).setCellValue(new HSSFRichTextString((dtoObj.getSalutation())));
                        wr.createCell(5).setCellValue(new HSSFRichTextString((dtoObj.getFirstName())));
                        wr.createCell(6).setCellValue(new HSSFRichTextString((dtoObj.getLastName())));
                        wr.createCell(7).setCellValue(new HSSFRichTextString((dtoObj.getEmail())));
                        wr.createCell(8).setCellValue(new HSSFRichTextString((dtoObj.getCellno())));
                        wr.createCell(9).setCellValue(new HSSFRichTextString((dtoObj.getFaxno())));
                        wr.createCell(10).setCellValue(rownum);
                        wr.createCell(11).setCellValue(new HSSFRichTextString((dtoObj.getAddress1())));
                        wr.createCell(12).setCellValue(new HSSFRichTextString((dtoObj.getAddress2())));
                        wr.createCell(13).setCellValue(new HSSFRichTextString((dtoObj.getAddress3())));
                        wr.createCell(14).setCellValue(new HSSFRichTextString((dtoObj.getCountrycode())));
                        wr.createCell(15).setCellValue(new HSSFRichTextString((dtoObj.getStateid())));
                        wr.createCell(16).setCellValue(new HSSFRichTextString((dtoObj.getCityid())));
                        wr.createCell(17).setCellValue(new HSSFRichTextString((dtoObj.getPincode())));
                    }
                    ctr++;
                    rownum++;
                }
            }
            if (s == 3 && (templateId == 1 || templateId == 22 || templateId == 21)) {
                int ctr = 0, rownum = 1;
                if (templateId == 21) {
                    totalRowsOfSheet = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                    filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);
                    for (int r = 2; r <= (totalRowsOfSheet + 1); r++) {
                        dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                        wr = ws.createRow(r);
                        if (wr != null) {
                            wr.createCell(1).setCellValue(rownum);
                            wr.createCell(2).setCellValue(dtoObj.getOrderNo());
                            wr.createCell(3).setCellValue(dtoObj.getLogicalsiNo());
                            wr.createCell(4).setCellValue(dtoObj.getServiceid());
                            wr.createCell(5).setCellValue(new HSSFRichTextString((dtoObj.getServiceName())));
                            wr.createCell(6).setCellValue(dtoObj.getLineItemID());
                            wr.createCell(7).setCellValue(new HSSFRichTextString((dtoObj.getLineItemName())));

                        }
                        ctr++;
                        rownum++;
                    }
                } else {
                    totalRowsOfSheet = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                    filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);
                    for (int r = 2; r <= (totalRowsOfSheet + 1); r++) {
                        dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                        wr = ws.createRow(r);
                        if (wr != null) {
                            wr.createCell(1).setCellValue(rownum);
                            wr.createCell(2).setCellValue(dtoObj.getOrderNo());
                            wr.createCell(3).setCellValue(dtoObj.getLogicalsiNo());
                            wr.createCell(4).setCellValue(dtoObj.getServiceid());
                            wr.createCell(5).setCellValue(dtoObj.getLineItemID());
                        }
                        ctr++;
                        rownum++;
                    }
                }
            }
            if (s == 3 && templateId == 41) {
                /*int  ctr=0,rownum=1;
                totalRowsOfSheet=objDao.getTotalRowsOfSheet(s+1,templateId,flag,logicalLSI);   
                filledTemplateData = objDao.getFilledTemplate(s+1,templateId,flag,logicalLSI);   
                for(int r = 2; r <= (totalRowsOfSheet+1); r++)
                {
                   dtoObj = (TransactionTemplateDto)filledTemplateData.get(ctr);               
                   wr=ws.createRow(r);
                   if(wr!=null)
                   {         
                      wr.createCell(1).setCellValue(rownum);
                      wr.createCell(2).setCellValue(dtoObj.getOrderNo());
                      wr.createCell(3).setCellValue(new HSSFRichTextString((dtoObj.getCustPONumber())));
                      wr.createCell(4).setCellValue(new HSSFRichTextString((dtoObj.getCustPODate())));                     
                      wr.createCell(5).setCellValue(new HSSFRichTextString((dtoObj.getIsDefaultPO())));
                      wr.createCell(6).setCellValue(new HSSFRichTextString((dtoObj.getLegalEntity())));
                      wr.createCell(7).setCellValue(new HSSFRichTextString((dtoObj.getTotalPOAmount())));
                      wr.createCell(8).setCellValue(new HSSFRichTextString((dtoObj.getPeriodInMonths())));
                      wr.createCell(9).setCellValue(new HSSFRichTextString((dtoObj.getContractStartDate())));
                      wr.createCell(10).setCellValue(new HSSFRichTextString((dtoObj.getContractEndDate())));
                      wr.createCell(11).setCellValue(new HSSFRichTextString((dtoObj.getPoRemarks())));
                      wr.createCell(12).setCellValue(new HSSFRichTextString((dtoObj.getPoEmailId())));
                   }
                   ctr++;rownum++;
                }*/
            }
            if (s == 4 && templateId == 41) {
                int ctr = 0, rownum = 1;
                totalRowsOfSheet = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);
                for (int r = 2; r <= (totalRowsOfSheet + 1); r++) {
                    dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                    wr = ws.createRow(r);
                    if (wr != null) {
                        wr.createCell(1).setCellValue(rownum);
                        wr.createCell(2).setCellValue(dtoObj.getOrderNo());
                        wr.createCell(3).setCellValue(dtoObj.getLogicalsiNo());
                        wr.createCell(4).setCellValue(dtoObj.getServiceid());
                        wr.createCell(5).setCellValue(dtoObj.getLineItemID());
                        wr.createCell(6).setCellValue(dtoObj.getChargeID());
                        wr.createCell(7).setCellValue(dtoObj.getChargeAmount());
                        wr.createCell(8).setCellValue(new HSSFRichTextString((dtoObj.getChargeFrequency())));
                        wr.createCell(9).setCellValue(new HSSFRichTextString((dtoObj.getStrChargeType())));
                        wr.createCell(10).setCellValue(new HSSFRichTextString((dtoObj.getStrChargeName())));
                        wr.createCell(11).setCellValue(dtoObj.getFrequncyAmount());
                        wr.createCell(12).setCellValue(new HSSFRichTextString((dtoObj.getAnnotation())));
                    }
                    ctr++;
                    rownum++;
                }
            }
            if (s == 5 && templateId == 41) {
                int ctr = 0, rownum = 1;
                totalRowsOfSheet = objDao.getTotalRowsOfSheet(s + 1, templateId, flag, logicalLSI);
                filledTemplateData = objDao.getFilledTemplate(s + 1, templateId, flag, logicalLSI);
                for (int r = 2; r <= (totalRowsOfSheet + 1); r++) {
                    dtoObj = (TransactionTemplateDto) filledTemplateData.get(ctr);
                    wr = ws.createRow(r);
                    if (wr != null) {
                        wr.createCell(1).setCellValue(rownum);
                        wr.createCell(2).setCellValue(new HSSFRichTextString(""));
                        wr.createCell(3).setCellValue(dtoObj.getLineItemID());
                        wr.createCell(4).setCellValue(dtoObj.getCreditPeriodID());
                        wr.createCell(5).setCellValue(new HSSFRichTextString((dtoObj.getCreditPeriodName())));
                        wr.createCell(6).setCellValue(dtoObj.getLegealEntityID());
                        wr.createCell(7).setCellValue(new HSSFRichTextString((dtoObj.getLegalEntityName())));
                        wr.createCell(8).setCellValue(dtoObj.getLicenseCompanyID());
                        wr.createCell(9).setCellValue(new HSSFRichTextString((dtoObj.getLicenseCompanyName())));
                        wr.createCell(10).setCellValue(dtoObj.getBillingModeID());
                        wr.createCell(11).setCellValue(new HSSFRichTextString((dtoObj.getBillingModeName())));
                        wr.createCell(12).setCellValue(dtoObj.getBillingFormatID());
                        wr.createCell(13).setCellValue(new HSSFRichTextString((dtoObj.getBillingFormatName())));
                        wr.createCell(14).setCellValue(dtoObj.getBillingTypeID());
                        wr.createCell(15).setCellValue(new HSSFRichTextString((dtoObj.getBillingTypeName())));
                        wr.createCell(16).setCellValue(dtoObj.getTaxationID());
                        wr.createCell(17).setCellValue(new HSSFRichTextString(dtoObj.getTaxationName()));
                        wr.createCell(18).setCellValue(dtoObj.getBillingLevelID());
                        wr.createCell(19).setCellValue(new HSSFRichTextString(dtoObj.getBillingLevelName()));
                        wr.createCell(20).setCellValue(dtoObj.getNoticePeriod());
                        wr.createCell(21).setCellValue(new HSSFRichTextString(dtoObj.getPenaltyClause()));
                        wr.createCell(22).setCellValue(dtoObj.getCommitPeriod());
                        wr.createCell(23).setCellValue(dtoObj.getIsNfa());
                        wr.createCell(24).setCellValue(dtoObj.getBcpID());
                        wr.createCell(25).setCellValue(new HSSFRichTextString(dtoObj.getBcpName()));
                        wr.createCell(26).setCellValue(new HSSFRichTextString(dtoObj.getStandardReasonId()));
                        wr.createCell(27).setCellValue(new HSSFRichTextString(dtoObj.getStandardReasonName()));

                    }
                    ctr++;
                    rownum++;
                }
            }

            // billing trigger bulkupload  sheet 1 start

            if (s == 0 && templateId == 61) {
                int ctr = 0, rownum = 1;

                filledTemplateDataLineDetails = objviewmodel.getFilledTemplateforBillingLineSectionBulkUpload();
                for (int r = 2; r <= (filledTemplateDataLineDetails.size() + 1); r++) {
                    dtoObj1 = (ViewOrderDto) filledTemplateDataLineDetails.get(ctr);
                    wr = ws.createRow(r);
                    if (wr != null) {
                        HSSFCell cell0 = wr.createCell(0);
                        cell0.setCellValue(rownum);

                        HSSFCell cell1 = wr.createCell(1);
                        cell1.setCellValue(new HSSFRichTextString(dtoObj1.getLineNumber()));
                        HSSFCellStyle sty1 = ws.getRow(1).getCell(1).getCellStyle();

                        wr.createCell(2).setCellValue(new HSSFRichTextString(dtoObj1.getLineName()));
                        wr.createCell(3).setCellValue(new HSSFRichTextString(dtoObj1.getLogicalSino()));
                        wr.createCell(4).setCellValue(new HSSFRichTextString(dtoObj1.getCustLogicalSino()));
                        wr.createCell(5).setCellValue(dtoObj1.getOrderno());
                        wr.createCell(6).setCellValue(new HSSFRichTextString(dtoObj1.getOrdertype()));
                        wr.createCell(7).setCellValue(new HSSFRichTextString(dtoObj1.getOrder_subtype()));
                        wr.createCell(8).setCellValue(new HSSFRichTextString(dtoObj1.getSiid()));
                        wr.createCell(9).setCellValue(new HSSFRichTextString(dtoObj1.getAccountid()));
                        wr.createCell(10).setCellValue(new HSSFRichTextString(dtoObj1.getFx_status()));
                        wr.createCell(11).setCellValue(new HSSFRichTextString(dtoObj1.getLine_status()));
                        wr.createCell(12).setCellValue(new HSSFRichTextString(dtoObj1.getChallen_No()));
                        wr.createCell(13).setCellValue(new HSSFRichTextString(dtoObj1.getChallen_date()));
                        validateDto = dtoObj1.getBillingTriggerAllowDenyLogic();

                        HSSFCell cell14 = wr.createCell(14);
                        cell14.setCellValue(new HSSFRichTextString(dtoObj1.getLocNo()));
                        HSSFCellStyle sty = ws.getRow(1).getCell(14).getCellStyle();
                        if ("allow".equals(validateDto.getLocNoForEdit())) {
                            cell14.setCellStyle(sty);

                        } else {
                            cell14.setCellStyle(sty1);
                        }

                        HSSFCell cell15 = wr.createCell(15);
                        if (!(dtoObj1.getLocDate() == null || "".equals(dtoObj1.getLocDate()))) {
                            cell15.setCellValue(new HSSFRichTextString(
                                    Utility.showDate_Report4(df.parse(dtoObj1.getLocDate()))));
                        } else {
                            cell15.setCellValue(new HSSFRichTextString(dtoObj1.getLocDate()));
                        }
                        if ("allow".equals(validateDto.getLocDateForEdit())) {
                            cell15.setCellStyle(sty);
                        } else {
                            cell15.setCellStyle(sty1);
                        }

                        HSSFCell cell16 = wr.createCell(16);
                        if (!(dtoObj1.getLocRecDate() == null || "".equals(dtoObj1.getLocRecDate()))) {
                            cell16.setCellValue(new HSSFRichTextString(
                                    Utility.showDate_Report4(df.parse(dtoObj1.getLocRecDate()))));
                        } else {
                            cell16.setCellValue(new HSSFRichTextString(dtoObj1.getLocRecDate()));
                        }

                        if ("allow".equals(validateDto.getLocRecDateForEdit())) {
                            cell16.setCellStyle(sty);
                        } else {
                            cell16.setCellStyle(sty1);
                        }

                        HSSFCell cell17 = wr.createCell(17);
                        if (!(dtoObj1.getBillingTriggerDate() == null
                                || "".equals(dtoObj1.getBillingTriggerDate()))) {
                            cell17.setCellValue(new HSSFRichTextString(
                                    Utility.showDate_Report4(df.parse(dtoObj1.getBillingTriggerDate()))));
                        } else {
                            cell17.setCellValue(new HSSFRichTextString(dtoObj1.getBillingTriggerDate()));
                        }

                        if ("allow".equals(validateDto.getBtdForEdit())) {
                            cell17.setCellStyle(sty);
                        } else {
                            cell17.setCellStyle(sty1);
                        }

                        wr.createCell(18)
                                .setCellValue(new HSSFRichTextString(dtoObj1.getBillingTriggerProcess()));

                    }
                    ctr++;
                    rownum++;
                }
            }

            // billing trigger bulkupload  sheet 1 end

            //billing trigger bulkupload  sheet 2 start
            if (s == 1 && templateId == 61) {
                int ctr = 0, rownum = 1;
                if (filledTemplateDataLineDetails.size() > 0) {

                    filledTemplateDataChargeDetails = objviewmodel
                            .getFilledTemplateforBillingChargeSectionBulkUpload();
                    for (int r = 2; r <= (filledTemplateDataChargeDetails.size() + 1); r++) {
                        dtoObj1 = (ViewOrderDto) filledTemplateDataChargeDetails.get(ctr);
                        wr = ws.createRow(r);
                        if (wr != null) {
                            wr.createCell(0).setCellValue(rownum);
                            HSSFCell cell1 = wr.createCell(1);
                            cell1.setCellValue(dtoObj1.getChargeInfoId());
                            HSSFCellStyle sty1 = ws.getRow(1).getCell(1).getCellStyle();
                            wr.createCell(2).setCellValue(new HSSFRichTextString(dtoObj1.getLineNumber()));
                            wr.createCell(3).setCellValue(new HSSFRichTextString(dtoObj1.getChargeType()));
                            wr.createCell(4).setCellValue(new HSSFRichTextString(dtoObj1.getChargeName()));
                            wr.createCell(5).setCellValue(dtoObj1.getChargePeriod());
                            wr.createCell(6).setCellValue(dtoObj1.getChargeAmt());
                            wr.createCell(7).setCellValue(new HSSFRichTextString(dtoObj1.getChargeStatus()));
                            HSSFCell cell8 = wr.createCell(8);
                            HSSFCellStyle sty8 = ws.getRow(1).getCell(8).getCellStyle();
                            if (!(dtoObj1.getDisconnectiondate() == null
                                    || "".equals(dtoObj1.getDisconnectiondate()))) {
                                cell8.setCellValue(new HSSFRichTextString(
                                        Utility.showDate_Report4(df.parse(dtoObj1.getDisconnectiondate()))));
                            } else {
                                cell8.setCellValue(new HSSFRichTextString(dtoObj1.getDisconnectiondate()));
                            }
                            if ("Changed".equalsIgnoreCase(dtoObj1.getChargeStatus())) {
                                cell8.setCellStyle(sty8);

                            }

                            wr.createCell(9)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargeCreatedOnOrder()));
                            wr.createCell(10)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargeEndedOnOrder()));
                            wr.createCell(11).setCellValue(new HSSFRichTextString(dtoObj1.getBillPeriod()));
                            wr.createCell(12).setCellValue(new HSSFRichTextString(dtoObj1.getStartdatelogic()));
                            wr.createCell(13).setCellValue(dtoObj1.getStart_date_days());
                            wr.createCell(14).setCellValue(dtoObj1.getStart_date_month());
                            wr.createCell(15).setCellValue(new HSSFRichTextString(dtoObj1.getEnddatelogic()));
                            wr.createCell(16).setCellValue(dtoObj1.getEnd_date_days());
                            wr.createCell(17).setCellValue(dtoObj1.getEnd_date_month());
                            wr.createCell(18)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargeEndDate_String()));
                            wr.createCell(19).setCellValue(new HSSFRichTextString(dtoObj1.getAnnualRate()));
                            wr.createCell(20).setCellValue(new HSSFRichTextString(dtoObj1.getAnnotation()));
                            wr.createCell(21).setCellValue(new HSSFRichTextString(dtoObj1.getStartTokenNo()));
                            wr.createCell(22).setCellValue(new HSSFRichTextString(dtoObj1.getStartFxStatus()));
                            wr.createCell(23).setCellValue(new HSSFRichTextString(dtoObj1.getStartFxNo()));
                            wr.createCell(24).setCellValue(new HSSFRichTextString(dtoObj1.getEndTokenNo()));
                            wr.createCell(25).setCellValue(new HSSFRichTextString(dtoObj1.getEndFxStatus()));
                            wr.createCell(26).setCellValue(new HSSFRichTextString(dtoObj1.getEndFxNo()));
                            wr.createCell(27)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargeStartStatus()));
                            wr.createCell(28)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargeEndStatus()));
                            wr.createCell(29)
                                    .setCellValue(new HSSFRichTextString(dtoObj1.getChargefrequency()));
                            wr.createCell(30).setCellValue(new HSSFRichTextString(dtoObj1.getFxViewId()));
                        }
                        ctr++;
                        rownum++;
                    }
                }
            }
            //         billing trigger bulkupload  sheet 2 end   
        }
        wb.write(fileOut);
        fileOut.close();
        filePath = newFile;
    } catch (IOESException ex) {
        logger.error(ex.getMessage() + "::BULKUPLOAD_ERROR:: Exception occured in getFilledTemplate method of "
                + this.getClass().getSimpleName());
        throw new IOESException("SQL Exception : " + ex.getMessage(), ex);
    } catch (IOException ioExp) {
        //logger.error(ioExp.getMessage() + " Exception occured in getErrorExcel method of " + this.getClass().getSimpleName());
        //throw new IOESException("SQL Exception : "+ ioExp.getMessage(), ioExp);
        Utility.LOG(true, false, ioExp, "::BULKUPLOAD_ERROR:: Exception occured in getFilledTemplate method of "
                + this.getClass().getSimpleName());
        return filePath = "NOTFOUND";
    }
    return filePath;
}

From source file:com.ibm.ioes.bulkupload.utilities.ErrorLogServiceImpl.java

public String getResultErrorMixLog(String filePath, int fileID) throws IOESException {
    //logger.info(" Entered into getErrorExcel method of " + this.getClass().getSimpleName());

    int colCount, ctr = 0;
    String fileName;/*from w ww  .  j a  v  a 2 s.  c  om*/
    HSSFWorkbook wb;
    HSSFSheet ws;
    HSSFRow wr;
    HSSFCell wc;
    ArrayList errVal = new ArrayList();
    ErrorFileDaoImpl objDao = new ErrorFileDaoImpl();
    ErrorLogDto dtoObj;

    try {
        ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");

        fileName = filePath.substring((filePath.lastIndexOf("/") + 1), filePath.length());
        String newFile = bundle.getString("excel.success") + "/" + fileName;
        FileOutputStream fileOut = new FileOutputStream(newFile);
        wb = new HSSFWorkbook(new FileInputStream(filePath));

        errVal = objDao.getResultErrorMixLog(fileID);
        System.out.println(errVal.toString());
        System.out.println(wb.getNumberOfSheets());

        HSSFCellStyle styleErr = wb.createCellStyle();
        HSSFCellStyle styleSuccess = wb.createCellStyle();
        HSSFFont fontSuccess = wb.createFont();
        HSSFFont fontErr = wb.createFont();

        for (int s = 0; s < wb.getNumberOfSheets(); s++) {

            ws = wb.getSheetAt(s);
            wr = ws.getRow(1);
            colCount = wr.getLastCellNum();
            wc = wr.createCell(colCount);
            wc.setCellValue("RESULT LOG" + "_" + "ORDERNO");

            for (int r = 2; r <= ws.getLastRowNum(); r++) {
                if ((ctr < errVal.size())) {
                    dtoObj = (ErrorLogDto) errVal.get(ctr);
                    wr = ws.getRow(r);
                    if (wr != null) {
                        int chk = 0;
                        for (int col = 0; col < colCount; col++) {
                            wc = wr.getCell(col);
                            if (wc != null) {
                                if (!(wc.toString().trim().equals(""))) {
                                    chk = 1;
                                }
                            }
                        }
                        if (chk == 1) {
                            wc = wr.createCell(colCount);
                            if ((dtoObj.getResultLogValue() == null || dtoObj.getResultLogValue().length() == 0)
                                    && dtoObj.getErrorLogValue() != null) {
                                fontErr.setColor(HSSFColor.RED.index);
                                styleErr.setFont(fontErr);
                                wc.setCellStyle(styleErr);
                                wc.setCellValue(dtoObj.getErrorLogValue().toString());
                            } else {
                                fontSuccess.setColor(HSSFColor.BLACK.index);
                                styleSuccess.setFont(fontSuccess);
                                wc.setCellStyle(styleSuccess);
                                wc.setCellValue(dtoObj.getResultLogValue().toString());
                            }

                            ctr++;
                        }
                    }
                }
            }
        }
        wb.write(fileOut);
        fileOut.close();
        filePath = newFile;
    } catch (IOESException ex) {
        logger.error(ex.getMessage() + " Exception occured in getResultExcel method of "
                + this.getClass().getSimpleName());
        throw new IOESException("SQL Exception : " + ex.getMessage(), ex);
    } catch (IOException ioExp) {
        //logger.error(ioExp.getMessage() + " Exception occured in getErrorExcel method of " + this.getClass().getSimpleName());
        //throw new IOESException("SQL Exception : "+ ioExp.getMessage(), ioExp);
        return filePath = "NOTFOUND";
    }
    return filePath;
}

From source file:com.ibm.ioes.dao.NewOrderDaoExt.java

/**
 * Method to get all data for Masters Download
 * @param productID// w w w.jav  a2s .c o  m
 * @return
 */
public HSSFWorkbook downloadMasters(long productID) {

    String methodName = "downloadMasters", className = this.getClass().getName(), msg = "";
    boolean logToFile = true, logToConsole = true;
    AppConstants.IOES_LOGGER.info(methodName + " method of " + className + " class have been called");

    Connection connection = null;
    ArrayList<String> allowedSections = new ArrayList<String>();
    HSSFWorkbook wb = new HSSFWorkbook();
    CallableStatement getAllDropDownAttributes = null;
    CallableStatement getDetailForEachdropDown = null;
    ResultSet rsForAllDropDowns = null;
    ResultSet rsForEachDropDown = null;
    CallableStatement getAllMasters = null;
    ResultSet rsAllMasters = null;
    try {
        connection = DbConnection.getConnectionObject();
        connection.setAutoCommit(false);
        allowedSections = getAllowedSections(productID);

        //for Service Summary
        if (allowedSections.contains(new String("SERVICE_SUMMARY"))) {
            getAllDropDownAttributes = connection.prepareCall(sp_getAllDropDownAttributes);
            getAllDropDownAttributes.setLong(1, productID);
            rsForAllDropDowns = getAllDropDownAttributes.executeQuery();
            while (rsForAllDropDowns.next()) {

                //makeSheetForServiceSummary(wb,rsForAllDropDowns.getInt("ATTMASTERID"));
                HSSFSheet sheet = wb.createSheet(rsForAllDropDowns.getString("ATTDESCRIPTION"));
                HSSFCellStyle headerCellStyle = wb.createCellStyle();
                HSSFFont boldFont = wb.createFont();
                boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                headerCellStyle.setFont(boldFont);
                HSSFRow excelRow = null;
                HSSFCell excelCell = null;
                excelRow = sheet.createRow(0);
                excelCell = excelRow.createCell(0);
                excelCell.setCellStyle(headerCellStyle);
                excelCell.setCellValue(new HSSFRichTextString(rsForAllDropDowns.getString("ATTDESCRIPTION")));

                excelRow = sheet.createRow(1);

                excelCell = excelRow.createCell(0);
                excelCell.setCellStyle(headerCellStyle);
                excelCell.setCellValue(new HSSFRichTextString("ID"));

                excelCell = excelRow.createCell(1);
                excelCell.setCellStyle(headerCellStyle);
                excelCell.setCellValue(new HSSFRichTextString("VALUE"));

                getDetailForEachdropDown = connection.prepareCall(sp_getDataForEachDropDown);
                getDetailForEachdropDown.setLong(1, rsForAllDropDowns.getInt("ATTMASTERID"));
                rsForEachDropDown = getDetailForEachdropDown.executeQuery();
                int rowNo = 2;
                while (rsForEachDropDown.next()) {
                    //create a sheet
                    excelRow = sheet.createRow(rowNo);
                    for (int cell = 0, col = 1; cell < 2; cell++, col++) {
                        excelCell = excelRow.createCell(cell);
                        excelCell.setCellValue(new HSSFRichTextString(rsForEachDropDown.getString(col)));
                    }
                    rowNo = rowNo + 1;

                }
            }
        }

        //for all other Sections

        getAllMasters = connection.prepareCall(sqlSp_getAllMasters);
        rsAllMasters = getAllMasters.executeQuery();
        while (rsAllMasters.next()) {
            String sectionName = rsAllMasters.getString("SECTION_NAME");
            if (allowedSections.contains(sectionName)) {

                String columns = rsAllMasters.getString("COLUMN_NAMES");
                String[] columnNames = columns.split(",");

                HSSFSheet sheet = wb.createSheet(rsAllMasters.getString("MASTER_NAME"));
                HSSFCellStyle headerCellStyle = wb.createCellStyle();
                HSSFFont boldFont = wb.createFont();
                boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                headerCellStyle.setFont(boldFont);
                HSSFRow excelRow = null;
                HSSFCell excelCell = null;
                excelRow = sheet.createRow(0);
                for (int count = 0; count < columnNames.length; count++) {
                    excelCell = excelRow.createCell(count);
                    excelCell.setCellStyle(headerCellStyle);
                    excelCell.setCellValue(new HSSFRichTextString(columnNames[count]));
                }
                PreparedStatement getMasterData = null;
                ResultSet rsMasterData = null;
                getMasterData = connection.prepareStatement(rsAllMasters.getString("QUERY"));
                rsMasterData = getMasterData.executeQuery();
                int rowNo = 1;
                while (rsMasterData.next()) {
                    excelRow = sheet.createRow(rowNo);
                    for (int cell = 0, col = 1; cell < columnNames.length; cell++, col++) {
                        excelCell = excelRow.createCell(cell);
                        excelCell.setCellValue(new HSSFRichTextString(rsMasterData.getString(col)));
                    }
                    rowNo = rowNo + 1;
                }
            }

        }

    } catch (Exception e) {
        try {
            connection.rollback();
        } catch (SQLException e1) {
            Utility.onEx_LOG_RET_NEW_EX(e1, methodName, className, msg, logToFile, logToConsole);
        }
    } finally {
        try {
            DbConnection.closeResultset(rsAllMasters);
            DbConnection.closeResultset(rsForAllDropDowns);
            DbConnection.closeCallableStatement(getAllDropDownAttributes);
            DbConnection.closeCallableStatement(getAllMasters);
            DbConnection.closeCallableStatement(getDetailForEachdropDown);
            DbConnection.closeCallableStatement(getAllMasters);
            DbConnection.freeConnection(connection);
        } catch (Exception e) {
        }
    }

    return wb;
}

From source file:com.ibm.ioes.utilities.MailForDisConnectProvisioning.java

public HSSFWorkbook generateExcel_ACS(ArrayList<ACSMailTemplateDto> mailDataList) {
    HSSFWorkbook wb = null;/*from www  .j av  a  2 s . c o m*/
    try {
        ACSMailTemplateDto mailObjDto = null;
        wb = new HSSFWorkbook();
        HSSFSheet mailProvisionSheet = wb.createSheet("Mail Disconnect");
        HSSFCellStyle headerCellStyle = wb.createCellStyle();
        HSSFFont boldFont = wb.createFont();
        boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        headerCellStyle.setFont(boldFont);

        HSSFRow excelRow = null;
        HSSFCell excelCell = null;

        excelRow = mailProvisionSheet.createRow(0);
        excelRow = mailProvisionSheet.createRow(0);

        int i_cell = 0;

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Date of Creation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Quote No./ISS Order No."));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Region"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Parent A/C ID(Billed)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Child ID (Unbilled)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Premium ACS ID"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Type of ID"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Customer Name"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Address"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("City State"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Pin"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Moderator Name"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Phone No."));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Contact Person"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Phone No."));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Account Manager Name"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email ID/ Phone No"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Web Conf (Y/N)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Web Conf Rental"));

        int iCount = 1;
        for (int i = 0; i < mailDataList.size(); i++) {
            mailObjDto = mailDataList.get(i);
            excelRow = mailProvisionSheet.createRow(iCount++);

            i_cell = 0;

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getDateOfCreation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getOrderNo())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getRegion())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getParentId())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChildId())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAcsId())));
            /*excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue( new HSSFRichTextString(""+Utility.fnCheckNull(mailObjDto.getServiceType()));*/
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getTypeOfId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getCustomerName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAddress())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getCity())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getPinNo())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonEmailId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonPhoneNo())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpEmail())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpPhone())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell
                    .setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrphone())
                    + "/" + Utility.fnCheckNull(mailObjDto.getAccMgrEmailId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getWebConf())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getWebConfRental())));
        }
    } catch (Exception ex) {
        Utility.LOG(true, true, "Error while fetching accounts for provisiong : " + new Date());
    }
    return wb;
}

From source file:com.ibm.ioes.utilities.MailForDisConnectProvisioning.java

public HSSFWorkbook generateExcel_VCS(ArrayList<ACSMailTemplateDto> mailDataList, String mailProvisioningFlag) {
    HSSFWorkbook wb = null;//  w ww . j  a v  a 2 s. c  o m
    try {
        ACSMailTemplateDto mailObjDto = null;
        wb = new HSSFWorkbook();
        HSSFSheet mailProvisionSheet = wb.createSheet("Mail Disconnect");
        HSSFCellStyle headerCellStyle = wb.createCellStyle();
        HSSFFont boldFont = wb.createFont();
        boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        headerCellStyle.setFont(boldFont);

        HSSFRow excelRow = null;
        HSSFCell excelCell = null;

        excelRow = mailProvisionSheet.createRow(0);
        excelRow = mailProvisionSheet.createRow(0);

        excelCell = excelRow.createCell(0);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Date of Creation"));
        excelCell = excelRow.createCell(1);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Account name"));
        excelCell = excelRow.createCell(2);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("ISS Order no"));
        excelCell = excelRow.createCell(3);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Product"));
        excelCell = excelRow.createCell(4);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Parent ID"));
        excelCell = excelRow.createCell(5);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Child ID"));
        excelCell = excelRow.createCell(6);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("VCS ID"));
        excelCell = excelRow.createCell(7);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Bundled VCS plan"));
        excelCell = excelRow.createCell(8);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Chairperson Name"));
        excelCell = excelRow.createCell(9);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Billing Person Name"));
        excelCell = excelRow.createCell(10);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Billing Address"));
        excelCell = excelRow.createCell(11);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("ID/HW address"));
        excelCell = excelRow.createCell(12);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Status"));

        int iCount = 1;
        for (int i = 0; i < mailDataList.size(); i++) {
            mailObjDto = mailDataList.get(i);
            excelRow = mailProvisionSheet.createRow(iCount++);
            excelCell = excelRow.createCell(0);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getDateOfCreation())));
            excelCell = excelRow.createCell(1);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccountName())));
            excelCell = excelRow.createCell(2);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getOrderNo())));
            excelCell = excelRow.createCell(3);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getProductName())));
            excelCell = excelRow.createCell(4);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getParentId())));
            excelCell = excelRow.createCell(5);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChildId())));
            excelCell = excelRow.createCell(6);
            excelCell
                    .setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getMultipleId())));
            excelCell = excelRow.createCell(7);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getPackageName())));
            excelCell = excelRow.createCell(8);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonName())));
            excelCell = excelRow.createCell(9);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpName())));
            excelCell = excelRow.createCell(10);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBillingAddress())));
            excelCell = excelRow.createCell(11);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getHwAddress())));
            excelCell = excelRow.createCell(12);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getStatus())));

        }
    } catch (Exception ex) {
        Utility.LOG(true, true, "Error while fetching accounts for provisiong : " + new Date());
    }
    return wb;
}

From source file:com.ibm.ioes.utilities.MailForProvisioning.java

public HSSFWorkbook generateExcel(ArrayList<ACSMailTemplateDto> mailDataList) {
    HSSFWorkbook wb = null;/*from  ww w  .  j  a v a  2s.c o m*/
    try {
        ACSMailTemplateDto mailObjDto = null;
        wb = new HSSFWorkbook();
        HSSFSheet mailProvisionSheet = wb.createSheet("Mail Provision");
        HSSFCellStyle headerCellStyle = wb.createCellStyle();
        HSSFFont boldFont = wb.createFont();
        boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        headerCellStyle.setFont(boldFont);

        HSSFRow excelRow = null;
        HSSFCell excelCell = null;

        excelRow = mailProvisionSheet.createRow(0);
        excelRow = mailProvisionSheet.createRow(0);

        int i_cell = 0;

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Date of Creation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Quote No./ISS Order No."));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Region"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Parent A/C ID(Billed)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Child ID (Unbilled)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Premium ACS ID"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Type of ID"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Customer Name"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Address"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("City State"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Pin"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Moderator Name"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Phone No."));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Contact Person"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));
        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Phone No."));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Account Manager Name"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Designation"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Email ID/ Phone No"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Web Conf (Y/N)"));

        excelCell = excelRow.createCell(i_cell++);
        excelCell.setCellStyle(headerCellStyle);
        excelCell.setCellValue(new HSSFRichTextString("Web Conf Rental"));

        int iCount = 1;
        for (int i = 0; i < mailDataList.size(); i++) {
            mailObjDto = mailDataList.get(i);
            excelRow = mailProvisionSheet.createRow(iCount++);

            i_cell = 0;

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getDateOfCreation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getOrderNo())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getRegion())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getParentId())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChildId())));

            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAcsId())));
            /*excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue( new HSSFRichTextString(""+Utility.fnCheckNull(mailObjDto.getServiceType()));*/
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getTypeOfId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getCustomerName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAddress())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getCity())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getPinNo())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonEmailId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonPhoneNo())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpEmail())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpPhone())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell
                    .setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrName())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrDesignation())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccMgrphone())
                    + "/" + Utility.fnCheckNull(mailObjDto.getAccMgrEmailId())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getWebConf())));
            excelCell = excelRow.createCell(i_cell++);
            excelCell.setCellValue(
                    new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getWebConfRental())));
        }
    } catch (Exception ex) {
        Utility.LOG(true, true, "Error while fetching accounts for provisiong : " + new Date());
    }
    return wb;
}

From source file:com.ibm.ioes.utilities.MailForProvisioning.java

public HSSFWorkbook generateExcel_Multiple(ArrayList<ACSMailTemplateDto> mailDataList,
        String mailProvisioningFlag) {
    HSSFWorkbook wb = null;/*from   w  ww.  jav a2s. co m*/
    try {
        ACSMailTemplateDto mailObjDto = null;
        wb = new HSSFWorkbook();
        HSSFSheet mailProvisionSheet = wb.createSheet("Mail Provision");
        HSSFCellStyle headerCellStyle = wb.createCellStyle();
        HSSFFont boldFont = wb.createFont();
        boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        headerCellStyle.setFont(boldFont);

        HSSFRow excelRow = null;
        HSSFCell excelCell = null;

        excelRow = mailProvisionSheet.createRow(0);
        excelRow = mailProvisionSheet.createRow(0);

        if ("PROVISIONING_MAIL_OVCC".equals(mailProvisioningFlag)) {
            excelCell = excelRow.createCell(0);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Date of Creation"));
            excelCell = excelRow.createCell(1);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Account name"));
            excelCell = excelRow.createCell(2);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("ISS Order no"));
            excelCell = excelRow.createCell(3);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Product"));
            excelCell = excelRow.createCell(4);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Parent ID"));
            excelCell = excelRow.createCell(5);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Child ID"));
            excelCell = excelRow.createCell(6);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("OVCC ID"));
            excelCell = excelRow.createCell(7);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Bundled OVCC plan"));
            excelCell = excelRow.createCell(8);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Chairperson Name"));
            excelCell = excelRow.createCell(9);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Billing Person Name"));
            excelCell = excelRow.createCell(10);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Billing Address"));
            excelCell = excelRow.createCell(11);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Status"));
        } else {
            excelCell = excelRow.createCell(0);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Date of Creation"));
            excelCell = excelRow.createCell(1);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Account name"));
            excelCell = excelRow.createCell(2);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("ISS Order no"));
            excelCell = excelRow.createCell(3);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Product"));
            excelCell = excelRow.createCell(4);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Parent ID"));
            excelCell = excelRow.createCell(5);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Child ID"));
            excelCell = excelRow.createCell(6);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("VCS ID"));
            excelCell = excelRow.createCell(7);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Bundled VCS plan"));
            excelCell = excelRow.createCell(8);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Chairperson Name"));
            excelCell = excelRow.createCell(9);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Billing Person Name"));
            excelCell = excelRow.createCell(10);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Billing Address"));
            excelCell = excelRow.createCell(11);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("ID/HW address"));
            excelCell = excelRow.createCell(12);
            excelCell.setCellStyle(headerCellStyle);
            excelCell.setCellValue(new HSSFRichTextString("Status"));
        }

        int iCount = 1;
        for (int i = 0; i < mailDataList.size(); i++) {
            mailObjDto = mailDataList.get(i);
            excelRow = mailProvisionSheet.createRow(iCount++);
            if ("PROVISIONING_MAIL_OVCC".equals(mailProvisioningFlag)) {
                excelCell = excelRow.createCell(0);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getDateOfCreation())));
                excelCell = excelRow.createCell(1);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccountName())));
                excelCell = excelRow.createCell(2);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getOrderNo())));
                excelCell = excelRow.createCell(3);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getProductName())));
                excelCell = excelRow.createCell(4);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getParentId())));
                excelCell = excelRow.createCell(5);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChildId())));
                excelCell = excelRow.createCell(6);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getMultipleId())));
                excelCell = excelRow.createCell(7);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getPackageName())));
                excelCell = excelRow.createCell(8);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonName())));
                excelCell = excelRow.createCell(9);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpName())));
                excelCell = excelRow.createCell(10);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBillingAddress())));
                excelCell = excelRow.createCell(11);
                excelCell
                        .setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getStatus())));
            } else {
                excelCell = excelRow.createCell(0);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getDateOfCreation())));
                excelCell = excelRow.createCell(1);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getAccountName())));
                excelCell = excelRow.createCell(2);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getOrderNo())));
                excelCell = excelRow.createCell(3);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getProductName())));
                excelCell = excelRow.createCell(4);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getParentId())));
                excelCell = excelRow.createCell(5);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChildId())));
                excelCell = excelRow.createCell(6);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getMultipleId())));
                excelCell = excelRow.createCell(7);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getPackageName())));
                excelCell = excelRow.createCell(8);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getChairPersonName())));
                excelCell = excelRow.createCell(9);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBcpName())));
                excelCell = excelRow.createCell(10);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getBillingAddress())));
                excelCell = excelRow.createCell(11);
                excelCell.setCellValue(
                        new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getHwAddress())));
                excelCell = excelRow.createCell(12);
                excelCell
                        .setCellValue(new HSSFRichTextString("" + Utility.fnCheckNull(mailObjDto.getStatus())));
            }
        }
    } catch (Exception ex) {
        Utility.LOG(true, true, "Error while fetching accounts for provisiong : " + new Date());
    }
    return wb;
}

From source file:com.ideaspymes.arthyweb.ventas.web.controllers.VentasCantadasBean.java

public void generarExcelVentasCantadas() throws IOException {

    cargaResumen();//from w  w w .jav a2  s  .co  m

    if (ventasCantadas == null || ventasCantadas.isEmpty()) {
        JsfUtil.addErrorMessage("No hay datos para generar");
    } else {
        Map<String, List<ResumenVentasCantadas>> map2 = new HashMap<>();

        for (ResumenVentasCantadas rc : ventasCantadas) {
            List<ResumenVentasCantadas> valueList = map2.get(rc.getTerritorio());
            if (valueList == null) {
                valueList = new ArrayList<>();
                valueList.add(rc);
                map2.put(rc.getTerritorio(), valueList);
            } else {
                valueList.add(rc);
            }
        }

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Ventas Detalle");

        configAnchoCols(sheet);

        //Fonts
        Font fontSubTitulo = workbook.createFont();
        fontSubTitulo.setFontHeightInPoints((short) 8);
        fontSubTitulo.setBoldweight(Font.BOLDWEIGHT_BOLD);

        //Fonts
        Font fontTotal3 = workbook.createFont();
        fontTotal3.setFontHeightInPoints((short) 8);
        fontTotal3.setColor(HSSFColor.RED.index);
        fontTotal3.setBoldweight(Font.BOLDWEIGHT_BOLD);

        //Fonts
        Font fontTerritorioTotal3 = workbook.createFont();
        fontTerritorioTotal3.setFontHeightInPoints((short) 8);
        fontTerritorioTotal3.setColor(HSSFColor.ORANGE.index);
        fontTerritorioTotal3.setBoldweight(Font.BOLDWEIGHT_BOLD);

        //Estilos
        DataFormat format = workbook.createDataFormat();
        CellStyle styleTotal3 = workbook.createCellStyle();

        styleTotal3.setFont(fontTotal3);
        styleTotal3.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
        styleTotal3.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
        styleTotal3.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
        styleTotal3.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        styleTotal3.setDataFormat(format.getFormat("0.0%"));

        styleTerritorioTotal3 = workbook.createCellStyle();
        styleTerritorioTotal3.setFont(fontTerritorioTotal3);
        styleTerritorioTotal3.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
        styleTerritorioTotal3.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
        // styleTerritorioTotal3.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
        // styleTerritorioTotal3.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);

        creaCabecera(workbook, sheet);

        String[] aCols20 = null;
        String[] aCols10 = null;
        String[] aColsGrue = null;
        String indicesTotales = "";

        for (Map.Entry<String, List<ResumenVentasCantadas>> entry : map2.entrySet()) {
            ++indexRow;

            HSSFRow row = sheet.createRow((++indexRow));

            HSSFCell cellTerr = row.createCell(indexCol);
            cellTerr.setCellValue(entry.getKey().toUpperCase());
            cellTerr.setCellStyle(styleTerritorio);

            int indexInicioGrupo = indexRow + 2;

            List<ResumenVentasCantadas> detalles = entry.getValue();

            Comparator<ResumenVentasCantadas> comp = new Comparator<ResumenVentasCantadas>() {

                @Override
                public int compare(ResumenVentasCantadas o1, ResumenVentasCantadas o2) {
                    return o1.getOrden() > o2.getOrden() ? 1 : -1;
                }
            };

            Collections.sort(detalles, comp);

            for (ResumenVentasCantadas rv : detalles) {
                cols20 = "";
                cols10 = "";
                colsGrue = "";

                int indexFilaActual = ++indexRow;
                HSSFRow row1 = sheet.createRow((indexFilaActual));

                HSSFCell cellZona = row1.createCell(indexCol + 0);
                cellZona.setCellValue(rv.getZona());
                cellZona.setCellStyle(styleTitulo9);

                HSSFCell cellVendedor = row1.createCell(indexCol + 1);
                cellVendedor.setCellValue(rv.getVendedor());
                cellVendedor.setCellStyle(styleTitulo9);

                HSSFCell cellBoletas = row1.createCell(indexCol + 2);
                cellBoletas.setCellValue(rv.getCantboletas());
                cellBoletas.setCellStyle(styleCantidad);

                generarDetalles(row1, indexFilaActual, rv);

            }

            int indexFinGrupo = indexRow + 1;

            int indexTotal1 = ++indexRow;
            int indexTotal2 = ++indexRow;
            int indexTotal3 = ++indexRow;

            HSSFRow rowTotal1 = sheet.createRow(indexTotal1);
            HSSFRow rowTotal2 = sheet.createRow((indexTotal2));
            HSSFRow rowTotal3 = sheet.createRow((indexTotal3));

            aCols20 = cols20.split(",");
            aCols10 = cols10.split(",");
            aColsGrue = colsGrue.split(",");

            //TOTAL 1
            generarTotal1(rowTotal1, indexInicioGrupo, indexFinGrupo, aColsGrue, aCols20, aCols10, cellTerr);
            //TOTAL 2
            generarTotal2(rowTotal2, indexFinGrupo, aColsGrue, cellTerr);
            //TOTAL 3
            generarTotal3(rowTotal3, indexFinGrupo, styleTotal3, cellTerr, sheet);
            //++indexRow;

            indicesTotales += (indexFinGrupo + 1) + ",";
        }

        String[] aIndexTotales = indicesTotales.split(",");

        //TOTAL pais
        int indexTotalPais = ++indexRow;
        HSSFRow rowTotalPais = sheet.createRow((indexTotalPais));
        generarTotalPais(rowTotalPais, styleTotal3, sheet, aIndexTotales, aColsGrue, aCols20, aCols10);

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance()
                .getExternalContext().getResponse();

        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment; filename=Ventas Cantadas.xls");
        workbook.write(response.getOutputStream());
        response.getOutputStream().flush();
        response.getOutputStream().close();
        FacesContext.getCurrentInstance().responseComplete();
        indexRow = 1;
    }

}