Example usage for org.apache.poi.ss.usermodel Cell setCellStyle

List of usage examples for org.apache.poi.ss.usermodel Cell setCellStyle

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell setCellStyle.

Prototype

void setCellStyle(CellStyle style);

Source Link

Document

Set the style for the cell.

Usage

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception {
    String EMEA = CompanyWrapper.getCurrentCompanyName();
    Font titleFont = p_workbook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    CellStyle titleStyle = p_workbook.createCellStyle();
    titleStyle.setWrapText(false);//  w  w  w  . j  av a 2 s.c  om
    titleStyle.setFont(titleFont);

    Row firRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(firRow, 0);
    titleCell.setCellValue(EMEA + " " + m_bundle.getString("lb_online"));
    titleCell.setCellStyle(titleStyle);
    p_sheet.setColumnWidth(0, 20 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

private void addHeader(Workbook p_workbook, Sheet p_sheet, final int p_sheetCategory) throws Exception {
    String EMEA = CompanyWrapper.getCurrentCompanyName();
    int col = -1;
    Row thirRow = getRow(p_sheet, 2);/*from w w w  . java2  s. c o  m*/
    Row fourRow = getRow(p_sheet, 3);
    // Company Name
    Cell cell_A = getCell(thirRow, ++col);
    cell_A.setCellValue(m_bundle.getString("lb_company_name"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));
    // Project Description
    Cell cell_B = getCell(thirRow, ++col);
    cell_B.setCellValue(m_bundle.getString("lb_project"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    // For "Add Job Id into online job report" issue
    if (isJobIdVisible) {
        Cell cell_C = getCell(thirRow, ++col);
        cell_C.setCellValue(m_bundle.getString("lb_job_id"));
        cell_C.setCellStyle(getHeaderStyle(p_workbook));
        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));
    }

    Cell cell_CorD = getCell(thirRow, ++col);
    cell_CorD.setCellValue(m_bundle.getString("lb_job_name"));
    cell_CorD.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_DorE = getCell(thirRow, ++col);
    cell_DorE.setCellValue(m_bundle.getString("lb_source_file_format"));
    cell_DorE.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_EorF = getCell(thirRow, ++col);
    cell_EorF.setCellValue(m_bundle.getString("lb_loc_profile"));
    cell_EorF.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_ForG = getCell(thirRow, ++col);
    cell_ForG.setCellValue(m_bundle.getString("lb_file_profiles"));
    cell_ForG.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_GorH = getCell(thirRow, ++col);
    cell_GorH.setCellValue(m_bundle.getString("lb_creation_date"));
    cell_GorH.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_HorI = getCell(thirRow, ++col);
    cell_HorI.setCellValue(m_bundle.getString("lb_creation_time"));
    cell_HorI.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_IorJ = getCell(thirRow, ++col);
    cell_IorJ.setCellValue(m_bundle.getString("lb_export_date"));
    cell_IorJ.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_JorK = getCell(thirRow, ++col);
    cell_JorK.setCellValue(m_bundle.getString("lb_export_time"));
    cell_JorK.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_KorL = getCell(thirRow, ++col);
    cell_KorL.setCellValue(m_bundle.getString("lb_status"));
    cell_KorL.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_LorM = getCell(thirRow, ++col);
    cell_LorM.setCellValue(m_bundle.getString("lb_lang"));
    cell_LorM.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_MorN_Header = getCell(thirRow, ++col);
    cell_MorN_Header.setCellValue(m_bundle.getString("lb_word_counts"));
    cell_MorN_Header.setCellStyle(getHeaderStyle(p_workbook));

    if (m_data.useInContext) {
        p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 5));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 5), getHeaderStyle(p_workbook));
    } else {
        p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 4));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 4), getHeaderStyle(p_workbook));
    }

    Cell cell_MorN = getCell(fourRow, col);
    cell_MorN.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.internalreps"));
    cell_MorN.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_NorO = getCell(fourRow, col);
    cell_NorO.setCellValue(m_bundle.getString("lb_100_exact_matches"));
    cell_NorO.setCellStyle(getHeaderStyle(p_workbook));

    if (m_data.useInContext) {
        col++;
        Cell cell_InContext = getCell(fourRow, col);
        cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
        cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
    }

    col++;
    Cell cell_FuzzyMatches = getCell(fourRow, col);
    cell_FuzzyMatches.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.fuzzymatches"));
    cell_FuzzyMatches.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_NewWords = getCell(fourRow, col);
    cell_NewWords.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.newwords"));
    cell_NewWords.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_Total = getCell(fourRow, col);
    cell_Total.setCellValue(m_bundle.getString("lb_total_source_word_count"));
    cell_Total.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_Invoice = getCell(thirRow, col);
    cell_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice"));
    cell_Invoice.setCellStyle(getHeaderStyle(p_workbook));

    if (p_sheetCategory == MONTH_SHEET) {
        if (m_data.useInContext) {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 7));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 7), getHeaderStyle(p_workbook));
        } else {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 6));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 6), getHeaderStyle(p_workbook));
        }

        Cell cell_InternalReps = getCell(fourRow, col);
        cell_InternalReps.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.internalreps"));
        cell_InternalReps.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_ExactMatches = getCell(fourRow, col);
        cell_ExactMatches.setCellValue(m_bundle.getString("lb_100_exact_matches"));
        cell_ExactMatches.setCellStyle(getHeaderStyle(p_workbook));
        col++;
        if (m_data.useInContext) {
            Cell cell_InContext = getCell(fourRow, col);
            cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
            cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
            col++;
        }

        Cell cell_FM_Invoice = getCell(fourRow, col);
        cell_FM_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.fuzzymatches"));
        cell_FM_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_NW_Invoice = getCell(fourRow, col);
        cell_NW_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.newwords"));
        cell_NW_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Total_Invoice = getCell(fourRow, col);
        cell_Total_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.total"));
        cell_Total_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_AdditionalCharges = getCell(fourRow, col);
        cell_AdditionalCharges.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.additionalCharges"));
        cell_AdditionalCharges.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_JobTotal = getCell(fourRow, col);
        cell_JobTotal.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.jobtotal"));
        cell_JobTotal.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Tracking = getCell(thirRow, col);
        cell_Tracking.setCellValue(
                m_bundle.getString("lb_tracking") + " " + EMEA + " " + m_bundle.getString("lb_use") + ")");
        cell_Tracking.setCellStyle(getHeaderStyle(p_workbook));

        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    } else if (p_sheetCategory == MONTH_REVIEW_SHEET) {
        if (m_data.useInContext) {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 7));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 7), getHeaderStyle(p_workbook));
        } else {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 6));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 6), getHeaderStyle(p_workbook));
        }

        Cell cell_InternalReps = getCell(fourRow, col);
        cell_InternalReps.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.internalreps"));
        cell_InternalReps.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_ExactMatches = getCell(fourRow, col);
        cell_ExactMatches.setCellValue(m_bundle.getString("lb_100_exact_matches"));
        cell_ExactMatches.setCellStyle(getHeaderStyle(p_workbook));
        col++;
        if (m_data.useInContext) {
            Cell cell_InContext = getCell(fourRow, col);
            cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
            cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
            col++;
        }

        Cell cell_FM_Invoice = getCell(fourRow, col);
        cell_FM_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.fuzzymatches"));
        cell_FM_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_NW_Invoice = getCell(fourRow, col);
        cell_NW_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.newwords"));
        cell_NW_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Total_Invoice = getCell(fourRow, col);
        cell_Total_Invoice.setCellValue(m_bundle.getString("lb_translation_total"));
        cell_Total_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Review = getCell(fourRow, col);
        cell_Review.setCellValue(m_bundle.getString("lb_review"));
        cell_Review.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_JobTotal = getCell(fourRow, col);
        cell_JobTotal.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.jobtotal"));
        cell_JobTotal.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Tracking = getCell(thirRow, col);
        cell_Tracking.setCellValue(
                m_bundle.getString("lb_tracking") + " " + EMEA + " " + m_bundle.getString("lb_use") + ")");
        cell_Tracking.setCellStyle(getHeaderStyle(p_workbook));

        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));
    } else {
        // Should never go here.
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

/**
 * For trados style// w  w w  .  j ava 2 s  .  c o m
 * 
 * @param p_sheet
 * @param p_sheetCategory
 * @param p_data
 * @param bundle
 * @throws Exception
 */
private void addHeaderTradosStyle(Workbook p_workbook, Sheet p_sheet, final int p_sheetCategory)
        throws Exception {
    String EMEA = CompanyWrapper.getCurrentCompanyName();

    Row secRow = getRow(p_sheet, 1);
    Cell cell_Ldfl = getCell(secRow, 0);
    cell_Ldfl.setCellValue(m_bundle.getString("lb_desp_file_list"));
    cell_Ldfl.setCellStyle(getContentStyle(p_workbook));

    int col = -1;
    Row thirRow = getRow(p_sheet, 2);
    Row fourRow = getRow(p_sheet, 3);
    // Company Name
    Cell cell_A = getCell(thirRow, ++col);
    cell_A.setCellValue(m_bundle.getString("lb_company_name"));
    cell_A.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    // Project Description
    Cell cell_B = getCell(thirRow, ++col);
    cell_B.setCellValue(m_bundle.getString("lb_project"));
    cell_B.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    if (isJobIdVisible) {
        Cell cell_C = getCell(thirRow, ++col);
        cell_C.setCellValue(m_bundle.getString("lb_job_id"));
        cell_C.setCellStyle(getHeaderStyle(p_workbook));
        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));
    }

    Cell cell_CorD = getCell(thirRow, ++col);
    cell_CorD.setCellValue(m_bundle.getString("lb_job_name"));
    cell_CorD.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_DorE = getCell(thirRow, ++col);
    cell_DorE.setCellValue(m_bundle.getString("lb_source_file_format"));
    cell_DorE.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_EorF = getCell(thirRow, ++col);
    cell_EorF.setCellValue(m_bundle.getString("lb_loc_profile"));
    cell_EorF.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_ForG = getCell(thirRow, ++col);
    cell_ForG.setCellValue(m_bundle.getString("lb_file_profiles"));
    cell_ForG.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_GorH = getCell(thirRow, ++col);
    cell_GorH.setCellValue(m_bundle.getString("lb_creation_date"));
    cell_GorH.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_HorI = getCell(thirRow, ++col);
    cell_HorI.setCellValue(m_bundle.getString("lb_creation_time"));
    cell_HorI.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_IorJ = getCell(thirRow, ++col);
    cell_IorJ.setCellValue(m_bundle.getString("lb_export_date"));
    cell_IorJ.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_JorK = getCell(thirRow, ++col);
    cell_JorK.setCellValue(m_bundle.getString("lb_export_time"));
    cell_JorK.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_KorL = getCell(thirRow, ++col);
    cell_KorL.setCellValue(m_bundle.getString("lb_status"));
    cell_KorL.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_LorM = getCell(thirRow, ++col);
    cell_LorM.setCellValue(m_bundle.getString("lb_lang"));
    cell_LorM.setCellStyle(getHeaderStyle(p_workbook));
    p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
    setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    Cell cell_MorN_Header = getCell(thirRow, ++col);
    cell_MorN_Header.setCellValue(m_bundle.getString("lb_word_counts"));
    cell_MorN_Header.setCellStyle(getHeaderStyle(p_workbook));

    if (m_data.useInContext) {
        p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 7));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 7), getHeaderStyle(p_workbook));
    } else {
        p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 6));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 6), getHeaderStyle(p_workbook));
    }

    Cell cell_MorN = getCell(fourRow, col);
    cell_MorN.setCellValue(m_bundle.getString("jobinfo.tradosmatches.invoice.per100matches"));
    cell_MorN.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_NorO = getCell(fourRow, col);
    cell_NorO.setCellValue(m_bundle.getString("lb_95_99"));
    cell_NorO.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_OorP = getCell(fourRow, col);
    cell_OorP.setCellValue(m_bundle.getString("lb_85_94"));
    cell_OorP.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_PorQ = getCell(fourRow, col);
    cell_PorQ.setCellValue(m_bundle.getString("lb_75_84") + "*");
    cell_PorQ.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_QorR = getCell(fourRow, col);
    cell_QorR.setCellValue(m_bundle.getString("lb_no_match"));
    cell_QorR.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_RorS = getCell(fourRow, col);
    cell_RorS.setCellValue(m_bundle.getString("lb_repetition_word_cnt"));
    cell_RorS.setCellStyle(getHeaderStyle(p_workbook));

    if (m_data.useInContext) {
        col++;
        Cell cell_InContext = getCell(fourRow, col);
        cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
        cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
    }

    col++;
    Cell cell_Total = getCell(fourRow, col);
    cell_Total.setCellValue(m_bundle.getString("lb_total"));
    cell_Total.setCellStyle(getHeaderStyle(p_workbook));

    col++;
    Cell cell_Invoice = getCell(thirRow, col);
    cell_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice"));
    cell_Invoice.setCellStyle(getHeaderStyle(p_workbook));

    if (p_sheetCategory == MONTH_SHEET) {
        if (m_data.useInContext) {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 9));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 9), getHeaderStyle(p_workbook));
        } else {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 8));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 8), getHeaderStyle(p_workbook));
        }

        Cell cell_Per100Matches = getCell(fourRow, col);
        cell_Per100Matches.setCellValue(m_bundle.getString("jobinfo.tradosmatches.invoice.per100matches"));
        cell_Per100Matches.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_95_99 = getCell(fourRow, col);
        cell_95_99.setCellValue(m_bundle.getString("lb_95_99"));
        cell_95_99.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_85_94 = getCell(fourRow, col);
        cell_85_94.setCellValue(m_bundle.getString("lb_85_94"));
        cell_85_94.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_75_84 = getCell(fourRow, col);
        cell_75_84.setCellValue(m_bundle.getString("lb_75_84") + "*");
        cell_75_84.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_NoMatch = getCell(fourRow, col);
        cell_NoMatch.setCellValue(m_bundle.getString("lb_no_match"));
        cell_NoMatch.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_WordCount = getCell(fourRow, col);
        cell_WordCount.setCellValue(m_bundle.getString("lb_repetition_word_cnt"));
        cell_WordCount.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        if (m_data.useInContext) {
            Cell cell_InContext = getCell(fourRow, col);
            cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
            cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
            col++;
        }

        Cell cell_Total_Invoice = getCell(fourRow, col);
        cell_Total_Invoice.setCellValue(m_bundle.getString("jobinfo.tmmatches.wordcounts.total"));
        cell_Total_Invoice.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_AdditionalCharges = getCell(fourRow, col);
        cell_AdditionalCharges.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.additionalCharges"));
        cell_AdditionalCharges.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_JobTotal = getCell(fourRow, col);
        cell_JobTotal.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.jobtotal"));
        cell_JobTotal.setCellStyle(getHeaderStyle(p_workbook));
        col++;

        Cell cell_Tracking = getCell(thirRow, col);
        cell_Tracking.setCellValue(
                m_bundle.getString("lb_tracking") + " " + EMEA + " " + m_bundle.getString("lb_use") + ")");
        cell_Tracking.setCellStyle(getHeaderStyle(p_workbook));

        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));

    } else if (p_sheetCategory == MONTH_REVIEW_SHEET) {
        if (m_data.useInContext) {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 9));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 9), getHeaderStyle(p_workbook));
        } else {
            p_sheet.addMergedRegion(new CellRangeAddress(2, 2, col, col + 7));
            setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 7), getHeaderStyle(p_workbook));
        }

        Cell cell_Per100Matches = getCell(fourRow, col);
        cell_Per100Matches.setCellValue(m_bundle.getString("jobinfo.tradosmatches.invoice.per100matches"));
        cell_Per100Matches.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_95_99 = getCell(fourRow, col);
        cell_95_99.setCellValue(m_bundle.getString("lb_95_99"));
        cell_95_99.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_85_94 = getCell(fourRow, col);
        cell_85_94.setCellValue(m_bundle.getString("lb_85_94"));
        cell_85_94.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_75_84 = getCell(fourRow, col);
        cell_75_84.setCellValue(m_bundle.getString("lb_75_84"));
        cell_75_84.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_NoMatch = getCell(fourRow, col);
        cell_NoMatch.setCellValue(m_bundle.getString("lb_no_match"));
        cell_NoMatch.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_WoerCount = getCell(fourRow, col);
        cell_WoerCount.setCellValue(m_bundle.getString("lb_repetition_word_cnt"));
        cell_WoerCount.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        if (m_data.useInContext) {
            Cell cell_InContext = getCell(fourRow, col);
            cell_InContext.setCellValue(m_bundle.getString("lb_in_context_tm"));
            cell_InContext.setCellStyle(getHeaderStyle(p_workbook));
            col++;
        }

        Cell cell_TranTotal = getCell(fourRow, col);
        cell_TranTotal.setCellValue(m_bundle.getString("lb_translation_total"));
        cell_TranTotal.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_Review = getCell(fourRow, col);
        cell_Review.setCellValue(m_bundle.getString("lb_review"));
        cell_Review.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_JobTotal = getCell(fourRow, col);
        cell_JobTotal.setCellValue(m_bundle.getString("jobinfo.tmmatches.invoice.jobtotal"));
        cell_JobTotal.setCellStyle(getHeaderStyle(p_workbook));

        col++;
        Cell cell_Tracking = getCell(thirRow, col);
        cell_Tracking.setCellValue(
                m_bundle.getString("lb_tracking") + " " + EMEA + " " + m_bundle.getString("lb_use") + ")");
        cell_Tracking.setCellStyle(getHeaderStyle(p_workbook));
        p_sheet.addMergedRegion(new CellRangeAddress(2, 3, col, col));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 3, col, col), getHeaderStyle(p_workbook));
    } else {
        // Should never go here.
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

private void writeProjectData(HashMap<String, HashMap<String, ProjectWorkflowData>> p_projectMap,
        Workbook p_workbook, Sheet[] p_sheets, boolean p_includeExReview, IntHolder[] p_rows) throws Exception {
    ArrayList<String> keys = new ArrayList<String>(p_projectMap.keySet());
    SortUtil.sort(keys);/*from  www .ja v a 2  s. c  o  m*/
    Iterator<String> keysIter = keys.iterator();

    totalCost.clear();
    totalCostDate.clear();
    int finishedJobNum = 0;

    while (keysIter.hasNext()) {
        // Cancel generate reports.
        if (isCancelled())
            return;
        // Sets Reports Percent.
        setPercent(++finishedJobNum);
        String key = keysIter.next();
        String jobId = getJobIdFromMapKey(key);
        boolean isWrongJob = m_data.wrongJobNames.contains(jobId);
        HashMap<String, ProjectWorkflowData> localeMap = p_projectMap.get(key);
        ArrayList<String> locales = new ArrayList<String>(localeMap.keySet());
        SortUtil.sort(locales);
        Iterator<String> localeIter = locales.iterator();
        BigDecimal projectTotalWordCountCost = new BigDecimal(BIG_DECIMAL_ZERO_STRING);
        BigDecimal reviewTotalWordCountCost = new BigDecimal(BIG_DECIMAL_ZERO_STRING);

        // Counts the review costing total and the translation costing
        // total.
        String localeName = null;
        ProjectWorkflowData data = null;

        // Marks whether needs to add a blank line.
        boolean containsDellReview = false;

        while (localeIter.hasNext()) {
            int col = 0;
            localeName = (String) localeIter.next();
            data = (ProjectWorkflowData) localeMap.get(localeName);

            int row = p_rows[MONTH_SHEET].getValue();
            Row theRow = getRow(p_sheets[MONTH_SHEET], row);

            CellStyle temp_moneyStyle = getMoneyStyle(p_workbook);
            CellStyle temp_normalStyle = getContentStyle(p_workbook);

            if (data.wasExportFailed) {
                temp_moneyStyle = getFailedMoneyStyle(p_workbook);
                temp_normalStyle = getRedCellStyle(p_workbook);
            }

            // Company Name
            Cell cell_A = getCell(theRow, col++);
            cell_A.setCellValue(data.companyName);
            cell_A.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

            // Project Description
            Cell cell_B = getCell(theRow, col++);
            cell_B.setCellValue(data.projectDesc);
            cell_B.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 22 * 256);

            if (isWrongJob) {
                // For "Add Job Id into online job report" issue
                if (isJobIdVisible) {
                    Cell cell_C = getCell(theRow, col++);
                    cell_C.setCellValue(Long.valueOf(jobId));
                    cell_C.setCellStyle(getWrongJobStyle(p_workbook));
                }

                Cell cell_CorD = getCell(theRow, col++);
                cell_CorD.setCellValue(data.jobName);
                cell_CorD.setCellStyle(getWrongJobStyle(p_workbook));
            } else {
                // For "Add Job Id into online job report" issue
                if (isJobIdVisible) {
                    Cell cell_C = getCell(theRow, col++);
                    cell_C.setCellValue(Long.valueOf(jobId));
                    cell_C.setCellStyle(temp_normalStyle);
                }
                Cell cell_CorD = getCell(theRow, col++);
                cell_CorD.setCellValue(data.jobName);
                cell_CorD.setCellStyle(temp_normalStyle);
            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 50 * 256);

            Cell cell_DorE = getCell(theRow, col++);
            cell_DorE.setCellValue(getAllSouceFileFormats(data.allFileProfiles));
            cell_DorE.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 20 * 256);

            Cell cell_EorF = getCell(theRow, col++);
            cell_EorF.setCellValue(data.l10nProfileName);
            cell_EorF.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 25 * 256);

            Cell cell_ForG = getCell(theRow, col++);
            cell_ForG.setCellValue(data.fileProfileNames);
            cell_ForG.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 20 * 256);

            if (data.wasExportFailed) {
                Cell cell_GorH = getCell(theRow, col++);
                cell_GorH.setCellValue(data.creationDate);
                cell_GorH.setCellStyle(getFailedDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);
                Cell cell_HorI = getCell(theRow, col++);
                cell_HorI.setCellValue(data.creationDate);
                cell_HorI.setCellStyle(getFailedTimeStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);
                Cell cell_IorJ = getCell(theRow, col++);
                cell_IorJ.setCellValue("");
                cell_IorJ.setCellStyle(getFailedDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);
                Cell cell_JorK = getCell(theRow, col++);
                cell_JorK.setCellValue("");
                cell_JorK.setCellStyle(getFailedTimeStyle(p_workbook));
            } else {
                Cell cell_GorH = getCell(theRow, col++);
                cell_GorH.setCellValue(getDateFormat().format(data.creationDate));
                cell_GorH.setCellStyle(getDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);
                Cell cell_HorI = getCell(theRow, col++);
                cell_HorI.setCellValue(getTimeFormat().format(data.creationDate));
                cell_HorI.setCellStyle(getContentStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);
                Cell cell_IorJ = getCell(theRow, col++);
                if (data.wasExported) {
                    cell_IorJ.setCellValue(getDateFormat().format(data.exportDate));
                } else {
                    cell_IorJ.setCellValue("");
                }
                cell_IorJ.setCellStyle(getDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);
                String labelExportTime = "";
                if (data.wasExported) {
                    labelExportTime = getExportDateStr(getTimeFormat(), data.exportDate);
                }
                Cell cell_JorK = getCell(theRow, col++);
                cell_JorK.setCellValue(labelExportTime);
                cell_JorK.setCellStyle(getContentStyle(p_workbook));

            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);

            // Status
            Cell cell_KorL = getCell(theRow, col++);
            cell_KorL.setCellValue(data.status);
            cell_KorL.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);
            // Language
            Cell cell_LorM = getCell(theRow, col++);
            cell_LorM.setCellValue(data.targetLang);
            cell_LorM.setCellStyle(temp_normalStyle);
            int numwidth = 10;
            // Summary Start Collumn
            m_data.initSumStartCol(col);
            Cell cell_MorN = getCell(theRow, col++);
            cell_MorN.setCellValue(data.repetitionWordCount);
            cell_MorN.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_NorO = getCell(theRow, col++);
            cell_NorO.setCellValue(data.segmentTmWordCount);
            cell_NorO.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            if (m_data.useInContext) {
                Cell cell_InContext = getCell(theRow, col++);
                cell_InContext.setCellValue(data.inContextMatchWordCount);
                cell_InContext.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);
            }

            Cell cell_FuzzyMatch = getCell(theRow, col++);
            cell_FuzzyMatch.setCellValue(data.fuzzyMatchWordCount);
            cell_FuzzyMatch.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_NoMatch = getCell(theRow, col++);
            cell_NoMatch.setCellValue(data.noMatchWordCount);
            cell_NoMatch.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_TotalWordCount = getCell(theRow, col++);
            cell_TotalWordCount.setCellValue(data.totalWordCount);
            cell_TotalWordCount.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            int moneywidth = 12;
            Cell cell_RepetitionWordCountCost = getCell(theRow, col++);
            cell_RepetitionWordCountCost.setCellValue(asDouble(data.repetitionWordCountCost));
            cell_RepetitionWordCountCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_SegmentTmWordCountCost = getCell(theRow, col++);
            cell_SegmentTmWordCountCost.setCellValue(asDouble(data.segmentTmWordCountCost));
            cell_SegmentTmWordCountCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            if (m_data.useInContext) {
                Cell cell_InContext = getCell(theRow, col++);
                cell_InContext.setCellValue(asDouble(data.inContextMatchWordCountCost));
                cell_InContext.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            }

            Cell cell_FuzzyMatchCost = getCell(theRow, col++);
            cell_FuzzyMatchCost.setCellValue(asDouble(data.fuzzyMatchWordCountCost));
            cell_FuzzyMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_NoMatchCost = getCell(theRow, col++);
            cell_NoMatchCost.setCellValue(asDouble(data.noMatchWordCountCost));
            cell_NoMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            if (totalCol == null) {
                totalCol = ReportUtil.toChar(col);
            }
            Cell cell_TotalCost = getCell(theRow, col++);
            cell_TotalCost.setCellValue(asDouble(data.totalWordCountCost));
            cell_TotalCost.setCellStyle(temp_moneyStyle);

            // Show total additional charges
            // p_sheets[MONTH_SHEET].setColumnView(col - 1, moneywidth);
            // p_sheets[MONTH_SHEET].addCell(new Number(col++, row,
            // asDouble(data.totalAdditionalCost), temp_moneyFormat));

            // p_sheets[MONTH_SHEET].setColumnView(col - 1, moneywidth);
            projectTotalWordCountCost = projectTotalWordCountCost.add(data.totalWordCountCost);

            List<Integer> indexs = totalCost.get(data.targetLang);
            if (indexs == null) {
                indexs = new ArrayList<Integer>();
                totalCost.put(data.targetLang, indexs);
            }
            indexs.add(row + 1);

            Double value = totalCostDate.get(data.targetLang);
            if (value == null) {
                value = 0.0;
            }
            value += asDouble(data.totalWordCountCost);
            totalCostDate.put(data.targetLang, value);

            // add a "project total" summary cost over the locales
            // map(1,moneyFormat)
            if (localeIter.hasNext() == false) {
                Cell cell_TotalAdditionalCost = getCell(theRow, col++);
                cell_TotalAdditionalCost.setCellValue(asDouble(data.totalAdditionalCost));
                cell_TotalAdditionalCost.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_ProjectTotalCost = getCell(theRow, col++);
                cell_ProjectTotalCost
                        .setCellValue(asDouble(projectTotalWordCountCost) + asDouble(data.totalAdditionalCost));
                cell_ProjectTotalCost.setCellStyle(temp_moneyStyle);
            } else {
                Cell cell_TotalAdditionalCost = getCell(theRow, col++);
                cell_TotalAdditionalCost.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_ProjectTotalCost = getCell(theRow, col++);
                cell_ProjectTotalCost.setCellStyle(temp_moneyStyle);
            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            p_rows[MONTH_SHEET].inc();

            // Write data into MONTH_REVIEW_SHEET
            if (p_includeExReview && data.containsDellReview) {
                containsDellReview = true;

                row = p_rows[MONTH_REVIEW_SHEET].getValue();
                theRow = getRow(p_sheets[MONTH_REVIEW_SHEET], row);
                col = 0;

                // Company Name
                Cell cell_A_Review = getCell(theRow, col++);
                cell_A_Review.setCellValue(data.companyName);
                cell_A_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                // Project Description
                Cell cell_B_Review = getCell(theRow, col++);
                cell_B_Review.setCellValue(data.projectDesc);
                cell_B_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 22 * 256);

                if (isWrongJob) {
                    // For "Job id not showing in external review tabs"
                    // Issue
                    if (isJobIdVisible) {
                        Cell cell_C_Review = getCell(theRow, col++);
                        cell_C_Review.setCellValue(data.jobId);
                        cell_C_Review.setCellStyle(getWrongJobStyle(p_workbook));
                    }
                    Cell cell_CorD_Review = getCell(theRow, col++);
                    cell_CorD_Review.setCellValue(data.jobName);
                    cell_CorD_Review.setCellStyle(getWrongJobStyle(p_workbook));
                } else {
                    // For "Job id not showing in external review tabs"
                    // Issue
                    if (isJobIdVisible) {
                        Cell cell_C_Review = getCell(theRow, col++);
                        cell_C_Review.setCellValue(data.jobId);
                        cell_C_Review.setCellStyle(temp_normalStyle);
                    }
                    Cell cell_CorD_Review = getCell(theRow, col++);
                    cell_CorD_Review.setCellValue(data.jobName);
                    cell_CorD_Review.setCellStyle(temp_normalStyle);
                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 50 * 256);
                Cell cell_DorE_Review = getCell(theRow, col++);
                cell_DorE_Review.setCellValue(data.projectDesc);
                cell_DorE_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 22 * 256);

                if (data.wasExportFailed) {
                    /*
                     * p_sheets[MONTH_SHEET].addCell(new DateTime(col++,
                     * row, data.creationDate, failed_dateFormat));
                     */
                    Cell cell_EorF_Review = getCell(theRow, col++);
                    cell_EorF_Review.setCellValue(data.creationDate);
                    cell_EorF_Review.setCellStyle(getFailedDateStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);
                    Cell cell_ForG_Review = getCell(theRow, col++);
                    cell_ForG_Review.setCellValue(data.creationDate);
                    cell_ForG_Review.setCellStyle(getFailedTimeStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);
                    Cell cell_GorH_Review = getCell(theRow, col++);
                    cell_GorH_Review.setCellValue("");
                    cell_GorH_Review.setCellStyle(getFailedDateStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);
                    Cell cell_HorI_Review = getCell(theRow, col++);
                    cell_HorI_Review.setCellValue("");
                    cell_HorI_Review.setCellStyle(getFailedTimeStyle(p_workbook));
                } else {
                    /*
                     * p_sheets[MONTH_SHEET].addCell(new Label(col++, row,
                     * dateFormat.format(data.creationDate)));
                     */
                    Cell cell_EorF_Review = getCell(theRow, col++);
                    cell_EorF_Review.setCellValue(getDateFormat().format(data.creationDate));
                    cell_EorF_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);
                    Cell cell_ForG_Review = getCell(theRow, col++);
                    cell_ForG_Review.setCellValue(getTimeFormat().format(data.creationDate));
                    cell_ForG_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);
                    String labelExportDate = "";
                    if (data.wasExported) {
                        labelExportDate = getExportDateStr(getDateFormat(), data.exportDate);
                    }
                    Cell cell_GorH_Review = getCell(theRow, col++);
                    cell_GorH_Review.setCellValue(labelExportDate);
                    cell_GorH_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);
                    String labelExportTime = "";
                    if (data.wasExported) {
                        labelExportTime = getExportDateStr(getTimeFormat(), data.exportDate);
                    }
                    Cell cell_HorI_Review = getCell(theRow, col++);
                    cell_HorI_Review.setCellValue(labelExportTime);
                    cell_HorI_Review.setCellStyle(getContentStyle(p_workbook));

                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);
                Cell cell_IorJ_Review = getCell(theRow, col++);
                cell_IorJ_Review.setCellValue(data.targetLang);
                cell_IorJ_Review.setCellStyle(temp_normalStyle);

                Cell cell_JorK_Review = getCell(theRow, col++);
                cell_JorK_Review.setCellValue(data.repetitionWordCount);
                cell_JorK_Review.setCellStyle(temp_normalStyle);

                numwidth = 10;
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);
                Cell cell_KorL_Review = getCell(theRow, col++);
                cell_KorL_Review.setCellValue(data.segmentTmWordCount);
                cell_KorL_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                if (m_data.useInContext) {
                    Cell cell_InContext = getCell(theRow, col++);
                    cell_InContext.setCellValue(data.inContextMatchWordCount);
                    cell_InContext.setCellStyle(temp_normalStyle);
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);
                }

                Cell cell_FuzzyMatch_Review = getCell(theRow, col++);
                cell_FuzzyMatch_Review.setCellValue(data.fuzzyMatchWordCount);
                cell_FuzzyMatch_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                Cell cell_NoMatch_Review = getCell(theRow, col++);
                cell_NoMatch_Review.setCellValue(data.noMatchWordCount);
                cell_NoMatch_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                Cell cell_Total_Review = getCell(theRow, col++);
                cell_Total_Review.setCellValue(data.totalWordCount);
                cell_Total_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                moneywidth = 12;
                Cell cell_RepetitionCost_Review = getCell(theRow, col++);
                cell_RepetitionCost_Review.setCellValue(asDouble(data.repetitionWordCountCostForDellReview));
                cell_RepetitionCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                Cell cell_SegmentCost_Review = getCell(theRow, col++);
                cell_SegmentCost_Review.setCellValue(asDouble(data.segmentTmWordCountCostForDellReview));
                cell_SegmentCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                if (m_data.useInContext) {
                    Cell cell_InContext = getCell(theRow, col++);
                    cell_InContext.setCellValue(asDouble(data.inContextMatchWordCountCostForDellReview));
                    cell_InContext.setCellStyle(temp_moneyStyle);
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                }

                Cell cell_FuzzyMatchCost_Review = getCell(theRow, col++);
                cell_FuzzyMatchCost_Review.setCellValue(asDouble(data.fuzzyMatchWordCountCostForDellReview));
                cell_FuzzyMatchCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_NoMatchCost_Review = getCell(theRow, col++);
                cell_NoMatchCost_Review.setCellValue(asDouble(data.noMatchWordCountCostForDellReview));
                cell_NoMatchCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                reviewTotalWordCountCost = reviewTotalWordCountCost.add(data.totalWordCountCostForDellReview);

                // Writes the "Translation Total" column.
                Cell cell_TotalCost_Review = getCell(theRow, col++);
                cell_TotalCost_Review.setCellValue(asDouble(data.totalWordCountCost));
                cell_TotalCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                // Writes the "Review" column.
                Cell cell_Review = getCell(theRow, col++);
                cell_Review.setCellValue(asDouble(data.totalWordCountCostForDellReview));
                cell_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                // add "job total" cost over the locales
                if (localeIter.hasNext() == false) {
                    Cell cell_JobTotal = getCell(theRow, col++);
                    cell_JobTotal
                            .setCellValue(asDouble(projectTotalWordCountCost.add(reviewTotalWordCountCost)));
                    cell_JobTotal.setCellStyle(temp_moneyStyle);
                } else {
                    Cell cell_JobTotal = getCell(theRow, col++);
                    cell_JobTotal.setCellStyle(temp_moneyStyle);
                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                p_rows[MONTH_REVIEW_SHEET].inc();
            } // End if (p_includeExReview && data.containsDellReview)
        } // End loop while (localeIter.hasNext())

        p_rows[MONTH_SHEET].inc();
        if (p_includeExReview && containsDellReview) {
            p_rows[MONTH_REVIEW_SHEET].inc();
        }

    } // End loop while (projectIter.hasNext())

    p_rows[MONTH_SHEET].inc();
    addTotals(p_workbook, p_sheets[MONTH_SHEET], MONTH_SHEET, p_rows[MONTH_SHEET]);

    if (p_includeExReview) {
        p_rows[MONTH_REVIEW_SHEET].inc();
        addTotals(p_workbook, p_sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET, p_rows[MONTH_REVIEW_SHEET]);
    }

    if (totalCol != null) {
        addTotalsPerLang(p_workbook, p_sheets[MONTH_SHEET], MONTH_SHEET, p_rows[MONTH_SHEET]);
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

/**
 * For Trados Style/*from  www . j av  a 2 s  .com*/
 * 
 * @param p_projectMap
 * @param p_sheets
 * @param p_includeExReview
 * @param p_rows
 * @param p_data
 * @param bundle
 * @throws Exception
 */
private void writeProjectDataTradosStyle(HashMap<String, HashMap<String, ProjectWorkflowData>> p_projectMap,
        Workbook p_workbook, Sheet[] p_sheets, boolean p_includeExReview, IntHolder[] p_rows) throws Exception {
    ArrayList<String> keys = new ArrayList<String>(p_projectMap.keySet());
    SortUtil.sort(keys);
    Iterator<String> keysIter = keys.iterator();

    totalCost.clear();
    totalCostDate.clear();
    int finishedJobNum = 0;
    while (keysIter.hasNext()) {
        // Cancel generate reports.
        if (isCancelled())
            return;
        // Sets Reports Percent.
        setPercent(++finishedJobNum);

        String key = keysIter.next();
        String jobId = getJobIdFromMapKey(key);
        boolean isWrongJob = m_data.wrongJobNames.contains(jobId);
        HashMap<String, ProjectWorkflowData> localeMap = p_projectMap.get(key);
        ArrayList<String> locales = new ArrayList<String>(localeMap.keySet());
        SortUtil.sort(locales);
        Iterator<String> localeIter = locales.iterator();
        BigDecimal projectTotalWordCountCost = new BigDecimal(BIG_DECIMAL_ZERO_STRING);
        BigDecimal reviewTotalWordCountCost = new BigDecimal(BIG_DECIMAL_ZERO_STRING);

        // Counts the review costing total and the translation costing
        // total.
        String localeName = null;
        ProjectWorkflowData data = null;

        // Marks whether needs to add a blank line.
        boolean containsDellReview = false;

        while (localeIter.hasNext()) {
            int col = 0;
            localeName = (String) localeIter.next();
            data = (ProjectWorkflowData) localeMap.get(localeName);

            int row = p_rows[MONTH_SHEET].getValue();
            Row theRow = getRow(p_sheets[MONTH_SHEET], row);

            CellStyle temp_moneyStyle = getMoneyStyle(p_workbook);
            CellStyle temp_normalStyle = getContentStyle(p_workbook);

            if (data.wasExportFailed) {
                temp_moneyStyle = getFailedMoneyStyle(p_workbook);
                temp_normalStyle = getRedCellStyle(p_workbook);
            }

            // Company Name
            Cell cell_A = getCell(theRow, col++);
            cell_A.setCellValue(data.companyName);
            cell_A.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

            // Project Description
            Cell cell_B = getCell(theRow, col++);
            cell_B.setCellValue(data.projectDesc);
            cell_B.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 22 * 256);

            if (isWrongJob) {
                // For "Add Job Id into online job report" issue
                if (isJobIdVisible) {
                    Cell cell_C = getCell(theRow, col++);
                    cell_C.setCellValue(Long.valueOf(jobId));
                    cell_C.setCellStyle(getWrongJobStyle(p_workbook));
                }

                Cell cell_CorD = getCell(theRow, col++);
                cell_CorD.setCellValue(data.jobName);
                cell_CorD.setCellStyle(getWrongJobStyle(p_workbook));
            } else {
                // For "Add Job Id into online job report" issue
                if (isJobIdVisible) {
                    Cell cell_C = getCell(theRow, col++);
                    cell_C.setCellValue(Long.valueOf(jobId));
                    cell_C.setCellStyle(temp_normalStyle);
                }
                Cell cell_CorD = getCell(theRow, col++);
                cell_CorD.setCellValue(data.jobName);
                cell_CorD.setCellStyle(temp_normalStyle);
            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 50 * 256);

            Cell cell_DorE = getCell(theRow, col++);
            cell_DorE.setCellValue(getAllSouceFileFormats(data.allFileProfiles));
            cell_DorE.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 20 * 256);

            Cell cell_EorF = getCell(theRow, col++);
            cell_EorF.setCellValue(data.l10nProfileName);
            cell_EorF.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 20 * 256);

            Cell cell_ForG = getCell(theRow, col++);
            cell_ForG.setCellValue(data.fileProfileNames);
            cell_ForG.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 20 * 256);

            if (data.wasExportFailed) {
                Cell cell_GorH = getCell(theRow, col++);
                cell_GorH.setCellValue(data.creationDate);
                cell_GorH.setCellStyle(getFailedDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

                Cell cell_HorI = getCell(theRow, col++);
                cell_HorI.setCellValue(data.creationDate);
                cell_HorI.setCellStyle(getFailedTimeStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);

                Cell cell_IorJ = getCell(theRow, col++);
                cell_IorJ.setCellValue("");
                cell_IorJ.setCellStyle(getFailedDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

                Cell cell_JorK = getCell(theRow, col++);
                cell_JorK.setCellValue("");
                cell_JorK.setCellStyle(getFailedTimeStyle(p_workbook));
            } else {
                Cell cell_GorH = getCell(theRow, col++);
                cell_GorH.setCellValue(getDateFormat().format(data.creationDate));
                cell_GorH.setCellStyle(getDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

                Cell cell_HorI = getCell(theRow, col++);
                cell_HorI.setCellValue(getTimeFormat().format(data.creationDate));
                cell_HorI.setCellStyle(getContentStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);

                Cell cell_IorJ = getCell(theRow, col++);
                if (data.wasExported) {
                    cell_IorJ.setCellValue(getDateFormat().format(data.exportDate));
                } else {
                    cell_IorJ.setCellValue("");
                }
                cell_IorJ.setCellStyle(getDateStyle(p_workbook));
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 15 * 256);

                String labelExportTime = "";
                if (data.wasExported) {
                    labelExportTime = getExportDateStr(getTimeFormat(), data.exportDate);
                }
                Cell cell_JorK = getCell(theRow, col++);
                cell_JorK.setCellValue(labelExportTime);
                cell_JorK.setCellStyle(getContentStyle(p_workbook));

            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);

            // Status
            Cell cell_KorL = getCell(theRow, col++);
            cell_KorL.setCellValue(data.status);
            cell_KorL.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, 18 * 256);
            // Language
            Cell cell_LorM = getCell(theRow, col++);
            cell_LorM.setCellValue(data.targetLang);
            cell_LorM.setCellStyle(temp_normalStyle);

            int numwidth = 10;

            // Summary Start Column
            m_data.initSumStartCol(col);

            Cell cell_MorN = getCell(theRow, col++);
            cell_MorN.setCellValue(data.segmentTmWordCount);
            cell_MorN.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_NorO = getCell(theRow, col++);
            cell_NorO.setCellValue(data.hiFuzzyMatchWordCount);
            cell_NorO.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_OorP = getCell(theRow, col++);
            cell_OorP.setCellValue(data.medHiFuzzyMatchWordCount);
            cell_OorP.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_PorQ = getCell(theRow, col++);
            cell_PorQ.setCellValue(data.medFuzzyMatchWordCount);
            cell_PorQ.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_QorR = getCell(theRow, col++);
            cell_QorR.setCellValue(data.noMatchWordCount);
            cell_QorR.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            Cell cell_RorS = getCell(theRow, col++);
            cell_RorS.setCellValue(data.repetitionWordCount);
            cell_RorS.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            if (m_data.useInContext) {
                Cell cell_InContext = getCell(theRow, col++);
                cell_InContext.setCellValue(data.inContextMatchWordCount);
                cell_InContext.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);
            }

            Cell cell_Total = getCell(theRow, col++);
            cell_Total.setCellValue(data.totalWordCount);
            cell_Total.setCellStyle(temp_normalStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, numwidth * 256);

            int moneywidth = 12;

            Cell cell_SegmentCost = getCell(theRow, col++);
            cell_SegmentCost.setCellValue(asDouble(data.segmentTmWordCountCost));
            cell_SegmentCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_HiFuzzyMatchCost = getCell(theRow, col++);
            cell_HiFuzzyMatchCost.setCellValue(asDouble(data.hiFuzzyMatchWordCountCost));
            cell_HiFuzzyMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_MedHiFuzzyMatchCost = getCell(theRow, col++);
            cell_MedHiFuzzyMatchCost.setCellValue(asDouble(data.medHiFuzzyMatchWordCountCost));
            cell_MedHiFuzzyMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_MedFuzzyMatchCost = getCell(theRow, col++);
            cell_MedFuzzyMatchCost.setCellValue(asDouble(data.medFuzzyMatchWordCountCost));
            cell_MedFuzzyMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_NoMatchCost = getCell(theRow, col++);
            cell_NoMatchCost.setCellValue(asDouble(data.noMatchWordCountCost));
            cell_NoMatchCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            Cell cell_RepetitionCost = getCell(theRow, col++);
            cell_RepetitionCost.setCellValue(asDouble(data.repetitionWordCountCost));
            cell_RepetitionCost.setCellStyle(temp_moneyStyle);
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

            if (m_data.useInContext) {
                Cell cell_InContextCost = getCell(theRow, col++);
                cell_InContextCost.setCellValue(asDouble(data.inContextMatchWordCountCost));
                cell_InContextCost.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            }

            if (totalCol == null) {
                totalCol = ReportUtil.toChar(col);
            }
            Cell cell_TotalCost = getCell(theRow, col++);
            cell_TotalCost.setCellValue(asDouble(data.totalWordCountCost));
            cell_TotalCost.setCellStyle(temp_moneyStyle);

            // Show total additional charges
            // p_sheets[MONTH_SHEET].setColumnView(col - 1, moneywidth);
            // p_sheets[MONTH_SHEET].addCell(new Number(col++, row,
            // asDouble(data.totalAdditionalCost), temp_moneyFormat));

            // p_sheets[MONTH_SHEET].setColumnView(col - 1, moneywidth);
            projectTotalWordCountCost = projectTotalWordCountCost.add(data.totalWordCountCost);

            List<Integer> indexs = totalCost.get(data.targetLang);
            if (indexs == null) {
                indexs = new ArrayList<Integer>();
                totalCost.put(data.targetLang, indexs);
            }
            indexs.add(row + 1);

            Double value = totalCostDate.get(data.targetLang);
            if (value == null) {
                value = 0.0;
            }
            value += asDouble(data.totalWordCountCost);
            totalCostDate.put(data.targetLang, value);

            // add a "project total" summary cost over the locales
            // map(1,moneyFormat)
            if (localeIter.hasNext() == false) {
                Cell cell_TotalAdditionalCost = getCell(theRow, col++);
                cell_TotalAdditionalCost.setCellValue(asDouble(data.totalAdditionalCost));
                cell_TotalAdditionalCost.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_ProjectTotalCost = getCell(theRow, col++);
                cell_ProjectTotalCost
                        .setCellValue(asDouble(projectTotalWordCountCost) + asDouble(data.totalAdditionalCost));
                cell_ProjectTotalCost.setCellStyle(temp_moneyStyle);
            } else {
                Cell cell_TotalAdditionalCost = getCell(theRow, col++);
                cell_TotalAdditionalCost.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_ProjectTotalCost = getCell(theRow, col++);
                cell_ProjectTotalCost.setCellStyle(temp_moneyStyle);
            }
            p_sheets[MONTH_SHEET].setColumnWidth(col - 1, moneywidth * 256);
            p_rows[MONTH_SHEET].inc();

            // Write data into MONTH_REVIEW_SHEET
            if (p_includeExReview && data.containsDellReview) {
                containsDellReview = true;

                row = p_rows[MONTH_REVIEW_SHEET].getValue();
                col = 0;

                // Company Name
                Cell cell_A_Review = getCell(theRow, col++);
                cell_A_Review.setCellValue(data.companyName);
                cell_A_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                // Project Description
                Cell cell_B_Review = getCell(theRow, col++);
                cell_B_Review.setCellValue(data.projectDesc);
                cell_B_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 22 * 256);

                if (isWrongJob) {
                    // For "Job id not showing in external review tabs"
                    // Issue
                    if (isJobIdVisible) {
                        Cell cell_C_Review = getCell(theRow, col++);
                        cell_C_Review.setCellValue(data.jobId);
                        cell_C_Review.setCellStyle(getWrongJobStyle(p_workbook));
                    }
                    Cell cell_CorD_Review = getCell(theRow, col++);
                    cell_CorD_Review.setCellValue(data.jobName);
                    cell_CorD_Review.setCellStyle(getWrongJobStyle(p_workbook));
                } else {
                    // For "Job id not showing in external review tabs"
                    // Issue
                    if (isJobIdVisible) {
                        Cell cell_C_Review = getCell(theRow, col++);
                        cell_C_Review.setCellValue(data.jobId);
                        cell_C_Review.setCellStyle(temp_normalStyle);
                    }
                    Cell cell_CorD_Review = getCell(theRow, col++);
                    cell_CorD_Review.setCellValue(data.jobName);
                    cell_CorD_Review.setCellStyle(temp_normalStyle);
                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 50 * 256);
                Cell cell_DorE_Review = getCell(theRow, col++);
                cell_DorE_Review.setCellValue(data.projectDesc);
                cell_DorE_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 22 * 256);

                if (data.wasExportFailed) {
                    /*
                     * p_sheets[MONTH_SHEET].addCell(new DateTime(col++,
                     * row, data.creationDate, failed_dateFormat));
                     */
                    Cell cell_EorF_Review = getCell(theRow, col++);
                    cell_EorF_Review.setCellValue(data.creationDate);
                    cell_EorF_Review.setCellStyle(getFailedDateStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                    Cell cell_ForG_Review = getCell(theRow, col++);
                    cell_ForG_Review.setCellValue(data.creationDate);
                    cell_ForG_Review.setCellStyle(getFailedTimeStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);

                    Cell cell_GorH_Review = getCell(theRow, col++);
                    cell_GorH_Review.setCellValue("");
                    cell_GorH_Review.setCellStyle(getFailedDateStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                    Cell cell_HorI_Review = getCell(theRow, col++);
                    cell_HorI_Review.setCellValue("");
                    cell_HorI_Review.setCellStyle(getFailedTimeStyle(p_workbook));
                } else {
                    /*
                     * p_sheets[MONTH_SHEET].addCell(new Label(col++, row,
                     * dateFormat.format(data.creationDate)));
                     */
                    Cell cell_EorF_Review = getCell(theRow, col++);
                    cell_EorF_Review.setCellValue(getDateFormat().format(data.creationDate));
                    cell_EorF_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                    Cell cell_ForG_Review = getCell(theRow, col++);
                    cell_ForG_Review.setCellValue(getTimeFormat().format(data.creationDate));
                    cell_ForG_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);

                    String labelExportDate = "";
                    if (data.wasExported) {
                        labelExportDate = getExportDateStr(getDateFormat(), data.exportDate);
                    }
                    Cell cell_GorH_Review = getCell(theRow, col++);
                    cell_GorH_Review.setCellValue(labelExportDate);
                    cell_GorH_Review.setCellStyle(getContentStyle(p_workbook));
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 15 * 256);

                    String labelExportTime = "";
                    if (data.wasExported) {
                        labelExportTime = getExportDateStr(getTimeFormat(), data.exportDate);
                    }
                    Cell cell_HorI_Review = getCell(theRow, col++);
                    cell_HorI_Review.setCellValue(labelExportTime);
                    cell_HorI_Review.setCellStyle(getContentStyle(p_workbook));

                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, 18 * 256);
                Cell cell_IorJ_Review = getCell(theRow, col++);
                cell_IorJ_Review.setCellValue(data.targetLang);
                cell_IorJ_Review.setCellStyle(temp_normalStyle);

                Cell cell_JorK_Review = getCell(theRow, col++);
                cell_JorK_Review.setCellValue(data.repetitionWordCount);
                cell_JorK_Review.setCellStyle(temp_normalStyle);

                numwidth = 10;
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);
                Cell cell_KorL_Review = getCell(theRow, col++);
                cell_KorL_Review.setCellValue(data.segmentTmWordCount);
                cell_KorL_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                if (m_data.useInContext) {
                    Cell cell_InContext = getCell(theRow, col++);
                    cell_InContext.setCellValue(data.inContextMatchWordCount);
                    cell_InContext.setCellStyle(temp_normalStyle);
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);
                }

                Cell cell_FuzzyMatch_Review = getCell(theRow, col++);
                cell_FuzzyMatch_Review.setCellValue(data.fuzzyMatchWordCount);
                cell_FuzzyMatch_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                Cell cell_NoMatch_Review = getCell(theRow, col++);
                cell_NoMatch_Review.setCellValue(data.noMatchWordCount);
                cell_NoMatch_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                Cell cell_Total_Review = getCell(theRow, col++);
                cell_Total_Review.setCellValue(data.totalWordCount);
                cell_Total_Review.setCellStyle(temp_normalStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, numwidth * 256);

                moneywidth = 12;
                Cell cell_RepetitionCost_Review = getCell(theRow, col++);
                cell_RepetitionCost_Review.setCellValue(asDouble(data.repetitionWordCountCostForDellReview));
                cell_RepetitionCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                Cell cell_SegmentCost_Review = getCell(theRow, col++);
                cell_SegmentCost_Review.setCellValue(asDouble(data.segmentTmWordCountCostForDellReview));
                cell_SegmentCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                if (m_data.useInContext) {
                    Cell cell_InContext = getCell(theRow, col++);
                    cell_InContext.setCellValue(asDouble(data.inContextMatchWordCountCostForDellReview));
                    cell_InContext.setCellStyle(temp_moneyStyle);
                    p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                }

                Cell cell_FuzzyMatchCost_Review = getCell(theRow, col++);
                cell_FuzzyMatchCost_Review.setCellValue(asDouble(data.fuzzyMatchWordCountCostForDellReview));
                cell_FuzzyMatchCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                Cell cell_NoMatchCost_Review = getCell(theRow, col++);
                cell_NoMatchCost_Review.setCellValue(asDouble(data.noMatchWordCountCostForDellReview));
                cell_NoMatchCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                reviewTotalWordCountCost = reviewTotalWordCountCost.add(data.totalWordCountCostForDellReview);

                // Writes the "Translation Total" column.
                Cell cell_TotalCost_Review = getCell(theRow, col++);
                cell_TotalCost_Review.setCellValue(asDouble(data.totalWordCountCost));
                cell_TotalCost_Review.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                // Writes the "Review" column.
                Cell cell_Rview = getCell(theRow, col++);
                cell_Rview.setCellValue(asDouble(data.totalWordCountCostForDellReview));
                cell_Rview.setCellStyle(temp_moneyStyle);
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);

                // add "job total" cost over the locales
                if (localeIter.hasNext() == false) {
                    Cell cell_JobTotal = getCell(theRow, col++);
                    cell_JobTotal
                            .setCellValue(asDouble(projectTotalWordCountCost.add(reviewTotalWordCountCost)));
                    cell_JobTotal.setCellStyle(temp_moneyStyle);
                } else {
                    Cell cell_JobTotal = getCell(theRow, col++);
                    cell_JobTotal.setCellStyle(temp_moneyStyle);
                    ;
                }
                p_sheets[MONTH_REVIEW_SHEET].setColumnWidth(col - 1, moneywidth * 256);
                p_rows[MONTH_REVIEW_SHEET].inc();
            } // End if (p_includeExReview && data.containsDellReview)
        } // End loop while (localeIter.hasNext())

        p_rows[MONTH_SHEET].inc();
        if (p_includeExReview && containsDellReview) {
            p_rows[MONTH_REVIEW_SHEET].inc();
        }

    } // End loop while (projectIter.hasNext())

    p_rows[MONTH_SHEET].inc();
    addTotals(p_workbook, p_sheets[MONTH_SHEET], MONTH_SHEET, p_rows[MONTH_SHEET]);

    if (p_includeExReview) {
        p_rows[MONTH_REVIEW_SHEET].inc();
        addTotals(p_workbook, p_sheets[MONTH_REVIEW_SHEET], MONTH_REVIEW_SHEET, p_rows[MONTH_REVIEW_SHEET]);
    }

    if (totalCol != null) {
        addTotalsPerLang(p_workbook, p_sheets[MONTH_SHEET], MONTH_SHEET, p_rows[MONTH_SHEET]);
    }
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportGenerator.java

License:Apache License

/**
 * Add totals row/*from   w w w  .  j av  a 2s  .  co m*/
 * 
 * @param p_sheet
 * @param p_sheetCategory
 * @param p_row
 * @param p_data
 * @param bundle
 * @throws Exception
 */
private void addTotals(Workbook p_workbook, Sheet p_sheet, final int p_sheetCategory, IntHolder p_row)
        throws Exception {
    int row = p_row.getValue() + 1; // skip a row

    String title = m_bundle.getString("lb_totals");
    java.text.NumberFormat.getCurrencyInstance(Locale.US);
    // Get Summary Start Column
    int c = m_data.getSumStartCol();
    String sumStartCol = getColumnName(c);
    Row theRow = getRow(p_sheet, row);

    Cell cell_A = getCell(theRow, 0);
    cell_A.setCellValue(title);
    cell_A.setCellStyle(getSubTotalStyle(p_workbook));
    // modify the number 3 to "sumStartCellCol-B" for "Add Job Id into
    // online job report" issue
    p_sheet.addMergedRegion(new CellRangeAddress(row, row, 0, sumStartCol.charAt(0) - 'B'));
    setRegionStyle(p_sheet, new CellRangeAddress(row, row, 0, sumStartCol.charAt(0) - 'B'),
            getSubTotalStyle(p_workbook));
    int lastRow = p_row.getValue() - 2;

    // add in word count totals
    // word counts
    Cell cell_B = getCell(theRow, c++);
    cell_B.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_B.setCellStyle(getSubTotalStyle(p_workbook));

    sumStartCol = getColumnName(c);
    Cell cell_C = getCell(theRow, c++);
    cell_C.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_C.setCellStyle(getSubTotalStyle(p_workbook));

    sumStartCol = getColumnName(c);
    Cell cell_D = getCell(theRow, c++);
    cell_D.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_D.setCellStyle(getSubTotalStyle(p_workbook));

    sumStartCol = getColumnName(c);
    Cell cell_E = getCell(theRow, c++);
    cell_E.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_E.setCellStyle(getSubTotalStyle(p_workbook));

    sumStartCol = getColumnName(c);
    Cell cell_F = getCell(theRow, c++);
    cell_F.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_F.setCellStyle(getSubTotalStyle(p_workbook));

    sumStartCol = getColumnName(c);
    if (m_data.isTradosStyle()) {
        Cell cell_G = getCell(theRow, c++);
        cell_G.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_G.setCellStyle(getSubTotalStyle(p_workbook));
        sumStartCol = getColumnName(c);

        Cell cell_H = getCell(theRow, c++);
        cell_H.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_H.setCellStyle(getSubTotalStyle(p_workbook));
        sumStartCol = getColumnName(c);
    }

    if (m_data.useInContext) {
        Cell cell_InContext = getCell(theRow, c++);
        cell_InContext.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_InContext.setCellStyle(getSubTotalStyle(p_workbook));
        sumStartCol = getColumnName(c);
    }

    // word count costs
    Cell cell_K = getCell(theRow, c++);
    cell_K.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_K.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_L = getCell(theRow, c++);
    cell_L.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_L.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_M = getCell(theRow, c++);
    cell_M.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_M.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_N = getCell(theRow, c++);
    cell_N.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_N.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_O = getCell(theRow, c++);
    cell_O.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_O.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_P = getCell(theRow, c++);
    cell_P.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_P.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    Cell cell_Q = getCell(theRow, c++);
    cell_Q.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_Q.setCellStyle(getTotalMoneyStyle(p_workbook));
    sumStartCol = getColumnName(c);

    if (m_data.isTradosStyle()) {
        Cell cell_R = getCell(theRow, c++);
        cell_R.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_R.setCellStyle(getTotalMoneyStyle(p_workbook));
        sumStartCol = getColumnName(c);

        Cell cell_S = getCell(theRow, c++);
        cell_S.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_S.setCellStyle(getTotalMoneyStyle(p_workbook));
        sumStartCol = getColumnName(c);
    }

    if (m_data.useInContext) {
        Cell cell_InContext = getCell(theRow, c++);
        cell_InContext.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
        cell_InContext.setCellStyle(getTotalMoneyStyle(p_workbook));
        sumStartCol = getColumnName(c);
    }

    // add an extra column for Dell Tracking Use
    Cell cell_V = getCell(theRow, c++);
    cell_V.setCellValue("");
    cell_V.setCellStyle(getTotalMoneyStyle(p_workbook));
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java

License:Apache License

/**
 * Add title to the sheet/*from  w ww. ja  va 2  s  .c  o  m*/
 * 
 * @param p_workBook
 * @param p_sheet
 *            the sheet
 * @throws Exception
 */
private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception {
    Font titleFont = p_workBook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Times");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    CellStyle cs = p_workBook.createCellStyle();
    cs.setFont(titleFont);

    Row titleRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue(m_bundle.getString("lb_post_review_qa_report"));
    titleCell.setCellStyle(cs);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java

License:Apache License

/**
 * Add hidden info "TER_taskID" for offline uploading. When upload, system
 * can know the report type and current task ID report generated from.
 * /*from  ww w  .  j  a  v a 2s  .  c  o m*/
 * @param p_workbook
 * @param p_sheet
 * @param p_job
 * @param p_targetLocale
 * @throws Exception
 */
private void addHidenInfoForUpload(Workbook p_workbook, Sheet p_sheet, Job p_job,
        GlobalSightLocale p_targetLocale) throws Exception {
    String reportInfo = "";
    for (Workflow wf : p_job.getWorkflows()) {
        if (p_targetLocale.getId() == wf.getTargetLocale().getId()) {
            Collection tasks = ServerProxy.getTaskManager().getCurrentTasks(wf.getId());
            if (tasks != null) {
                for (Iterator it = tasks.iterator(); it.hasNext();) {
                    Task task = (Task) it.next();
                    reportInfo = ReportConstants.POST_REVIEW_REPORT_ABBREVIATION + "_" + task.getId();
                }
            }
        }
    }

    Row titleRow = getRow(p_sheet, 0);
    Cell taskIdCell = getCell(titleRow, 26);
    taskIdCell.setCellValue(reportInfo);
    taskIdCell.setCellStyle(contentStyle);

    p_sheet.setColumnHidden(26, true);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java

License:Apache License

/**
 * Add language header to the sheet//from ww w.j av a 2  s . c  o  m
 * 
 * @param p_workBook
 * @param p_sheet
 *            the sheet
 * @throws Exception
 */
private void addLanguageHeader(Workbook p_workBook, Sheet p_sheet) throws Exception {
    int col = 0;
    int row = LANGUAGE_HEADER_ROW;

    Row langRow = getRow(p_sheet, row);
    Cell srcLangCell = getCell(langRow, col);
    srcLangCell.setCellValue(m_bundle.getString("lb_source_language"));
    srcLangCell.setCellStyle(getHeaderStyle(p_workBook));
    col++;

    Cell trgLangCell = getCell(langRow, col);
    trgLangCell.setCellValue(m_bundle.getString("lb_target_language"));
    trgLangCell.setCellStyle(getHeaderStyle(p_workBook));
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.PostReviewQAReportGenerator.java

License:Apache License

private void addQuaAssessment(Workbook p_workBook, Sheet p_sheet) throws Exception {
    int col = 0;/*from   ww w  . j  av a  2 s .  c o m*/
    int row = 6;

    Row langRow = getRow(p_sheet, row);
    Cell quaAssessmentCell = getCell(langRow, col);
    quaAssessmentCell.setCellValue(m_bundle.getString("lb_quality_assessment"));
    quaAssessmentCell.setCellStyle(getHeaderStyle(p_workBook));
}