Example usage for org.apache.poi.ss.usermodel Sheet addMergedRegion

List of usage examples for org.apache.poi.ss.usermodel Sheet addMergedRegion

Introduction

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

Prototype

int addMergedRegion(CellRangeAddress region);

Source Link

Document

Adds a merged region of cells (hence those cells form one)

Usage

From source file:com.efficio.fieldbook.service.ExportExcelServiceImpl.java

License:Open Source License

private int printDirectionHeader(Sheet fieldMapSheet, Plot[][] plots, int range, int numberOfRows, int rowIndex,
        int machineRowCapacity, CellStyle mainHeader, CellStyle subHeaderStyle, boolean isSerpentine) {

    Row row = fieldMapSheet.createRow(rowIndex);
    int columnIndex = 0;
    Cell cell1 = row.createCell(columnIndex++);
    cell1.setCellValue("");
    cell1.setCellStyle(mainHeader);//from   w w w .j av a2 s .  c  om

    int numberOfDirections = numberOfRows / machineRowCapacity;
    int remainingRows = numberOfRows % machineRowCapacity;
    if (remainingRows > 0) {
        numberOfDirections++;
    }

    for (int i = 0; i < numberOfDirections; i++) {
        int startCol = machineRowCapacity * i + 1;
        if (i % 2 == 1) {
            Cell cell = row.createCell(startCol);
            cell.setCellValue(DOWN);
            cell.setCellStyle(subHeaderStyle);
        } else {
            Cell cell = row.createCell(startCol);
            cell.setCellValue(UP);
            cell.setCellStyle(subHeaderStyle);
        }
        /*
        if (isSerpentine) {
        if (i % 2 == 1) {
            Cell cell = row.createCell(startCol);
            cell.setCellValue(DOWN);
            cell.setCellStyle(subHeaderStyle);
        }
        else {
            Cell cell = row.createCell(startCol);
            cell.setCellValue(UP);
            cell.setCellStyle(subHeaderStyle);
        }
        }
        else {
        Cell cell = row.createCell(startCol);
        cell.setCellValue(UP);
        cell.setCellStyle(subHeaderStyle);
        }
        */
        if (i == numberOfDirections - 1 && remainingRows > 0) { //last item
            fieldMapSheet.addMergedRegion(
                    new CellRangeAddress(rowIndex, rowIndex, startCol, machineRowCapacity * i + remainingRows));
        } else {
            fieldMapSheet.addMergedRegion(
                    new CellRangeAddress(rowIndex, rowIndex, startCol, machineRowCapacity * (i + 1)));
        }
    }
    rowIndex++;
    return rowIndex;
}

From source file:com.eyeq.pivot4j.export.poi.ExcelExporter.java

License:Common Public License

/**
 * @param context/*from  ww w . j a v  a 2  s.co m*/
 * @param sheet
 * @param regions
 */
protected void mergeCells(RenderContext context, Sheet sheet, List<CellRangeAddress> regions) {
    for (CellRangeAddress region : regions) {
        sheet.addMergedRegion(region);
    }
}

From source file:com.firstonesoft.poi.TimesheetDemo.java

License:Apache License

public static void main(String[] args) throws Exception {
    Workbook wb;// w w  w  .  j a v a  2 s.co  m

    if (args.length > 0 && args[0].equals("-xls"))
        wb = new HSSFWorkbook();
    else
        wb = new XSSFWorkbook();

    Map<String, CellStyle> styles = createStyles(wb);

    Sheet sheet = wb.createSheet("Timesheet");
    PrintSetup printSetup = sheet.getPrintSetup();
    printSetup.setLandscape(true);
    sheet.setFitToPage(true);
    sheet.setHorizontallyCenter(true);

    //title row
    Row titleRow = sheet.createRow(0);
    titleRow.setHeightInPoints(45);
    Cell titleCell = titleRow.createCell(0);
    titleCell.setCellValue("Resumen de Horas");
    titleCell.setCellStyle(styles.get("title"));
    sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1"));

    //header row
    Row headerRow = sheet.createRow(1);
    headerRow.setHeightInPoints(40);
    Cell headerCell;
    for (int i = 0; i < titles.length; i++) {
        headerCell = headerRow.createCell(i);
        headerCell.setCellValue(titles[i]);
        headerCell.setCellStyle(styles.get("header"));
    }

    int rownum = 2;
    for (int i = 0; i < 10; i++) {
        Row row = sheet.createRow(rownum++);
        for (int j = 0; j < titles.length; j++) {
            Cell cell = row.createCell(j);
            if (j == 9) {
                //the 10th cell contains sum over week days, e.g. SUM(C3:I3)
                String ref = "C" + rownum + ":I" + rownum;
                cell.setCellFormula("SUM(" + ref + ")");
                cell.setCellStyle(styles.get("formula"));
            } else if (j == 11) {
                cell.setCellFormula("J" + rownum + "-K" + rownum);
                cell.setCellStyle(styles.get("formula"));
            } else {
                cell.setCellStyle(styles.get("cell"));
            }
        }
    }

    //row with totals below
    Row sumRow = sheet.createRow(rownum++);
    sumRow.setHeightInPoints(35);
    Cell cell;
    cell = sumRow.createCell(0);
    cell.setCellStyle(styles.get("formula"));
    cell = sumRow.createCell(1);
    cell.setCellValue("Total Hrs:");
    cell.setCellStyle(styles.get("formula"));

    for (int j = 2; j < 12; j++) {
        cell = sumRow.createCell(j);
        String ref = (char) ('A' + j) + "3:" + (char) ('A' + j) + "12";
        cell.setCellFormula("SUM(" + ref + ")");
        if (j >= 9)
            cell.setCellStyle(styles.get("formula_2"));
        else
            cell.setCellStyle(styles.get("formula"));
    }
    rownum++;
    sumRow = sheet.createRow(rownum++);
    sumRow.setHeightInPoints(25);
    cell = sumRow.createCell(0);
    cell.setCellValue("Total Regular Hours");
    cell.setCellStyle(styles.get("formula"));
    cell = sumRow.createCell(1);
    cell.setCellFormula("L13");
    cell.setCellStyle(styles.get("formula_2"));
    sumRow = sheet.createRow(rownum++);
    sumRow.setHeightInPoints(25);
    cell = sumRow.createCell(0);
    cell.setCellValue("Total Overtime Hours");
    cell.setCellStyle(styles.get("formula"));
    cell = sumRow.createCell(1);
    cell.setCellFormula("K13");
    cell.setCellStyle(styles.get("formula_2"));

    //set sample data
    for (int i = 0; i < sample_data.length; i++) {
        Row row = sheet.getRow(2 + i);
        for (int j = 0; j < sample_data[i].length; j++) {
            if (sample_data[i][j] == null)
                continue;

            if (sample_data[i][j] instanceof String) {
                row.getCell(j).setCellValue((String) sample_data[i][j]);
            } else {
                row.getCell(j).setCellValue((Double) sample_data[i][j]);
            }
        }
    }

    //finally set column widths, the width is measured in units of 1/256th of a character width
    sheet.setColumnWidth(0, 30 * 256); //30 characters wide
    for (int i = 2; i < 9; i++) {
        sheet.setColumnWidth(i, 6 * 256); //6 characters wide
    }
    sheet.setColumnWidth(10, 10 * 256); //10 characters wide

    // Write the output to a file
    String file = "D://timesheet.xls";
    if (wb instanceof XSSFWorkbook)
        file += "x";
    FileOutputStream out = new FileOutputStream(file);
    wb.write(out);
    out.close();
}

From source file:com.github.cutstock.excel.utils.ExcelUtil.java

License:Apache License

public static void mergeRegion(Sheet sheet, IExcelRectangle titleRect) {
    sheet.addMergedRegion(CellRangeAddress.valueOf(getMergeString(titleRect)));
}

From source file:com.github.ukase.toolkit.xlsx.CellMerge.java

License:Open Source License

void apply(Sheet sheet) {
    CellRangeAddress region = new CellRangeAddress(rowStart, rowEnd, cellStart, cellEnd);
    sheet.addMergedRegion(region);
}

From source file:com.glaf.oa.reports.web.springmvc.OAReportController.java

License:Apache License

private void convert(Sheet sheet, List<AssesssortType> ty) {
    CellRangeAddress cellRangeAddress;//  w w  w.  j  a  va 2s .  co  m
    int aIndex = 0;
    int first = 6;
    int last = 0;
    int Index = 0;
    int firstRow = 6;
    int lastRow = 0;
    boolean rst = false;
    for (AssesssortType b1 : ty) {
        rst = false;
        for (AssesssortType b2 : b1.getSubAssessList()) {
            int size = b2.getAdsList().size();
            if (size > 0) {
                aIndex = aIndex + size;
                Index = Index + size;
                lastRow = 6 + Index - 1;
                firstRow = lastRow - size + 1;
                cellRangeAddress = new CellRangeAddress(firstRow, lastRow, 1, 1);
                sheet.addMergedRegion(cellRangeAddress);
                rst = true;
            }
        }
        if (rst) {
            Index = Index + 1;
            firstRow = lastRow + 2;
            last = 6 + aIndex - 1;
            cellRangeAddress = new CellRangeAddress(first, last, 0, 0);
            // ????
            sheet.addMergedRegion(cellRangeAddress);
            cellRangeAddress = new CellRangeAddress(first, last, 3, 3);
            // ????
            sheet.addMergedRegion(cellRangeAddress);
            aIndex = aIndex + 1;
            first = last + 2;
        }
    }

}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.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  ww  . j  av  a  2s. co  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_MTPro = getCell(thirRow, ++col);
    cell_MTPro.setCellValue(m_bundle.getString("lb_mt_translation_name"));
    cell_MTPro.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.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

/**
 * For trados style/*ww w.java 2  s .c om*/
 * 
 * @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_MTPro = getCell(thirRow, ++col);
    cell_MTPro.setCellValue(m_bundle.getString("lb_mt_translation_name"));
    cell_MTPro.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 + 8));
        setRegionStyle(p_sheet, new CellRangeAddress(2, 2, col, col + 8), 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_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_MT = getCell(fourRow, col);
    cell_MT.setCellValue(m_bundle.getString("lb_tm_mt"));
    cell_MT.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));

    Cell cell_Score = getCell(thirRow, ++col);
    cell_Score.setCellValue(m_bundle.getString("lb_tm_mt_confidence_score"));
    cell_Score.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_Count = getCell(thirRow, ++col);
    cell_Count.setCellValue(m_bundle.getString("lb_tm_mt_engine_word_counts"));
    cell_Count.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));

    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.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

/**
 * Add totals row//from w  w  w  .  j  a  v  a2s.c  o 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);
    }

    Cell cell_MT = getCell(theRow, c++);
    cell_MT.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_MT.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);
    }

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

    Cell cell_MTEWC = getCell(theRow, c++);
    cell_MTEWC.setCellFormula("SUM(" + sumStartCol + "5:" + sumStartCol + lastRow + ")");
    cell_MTEWC.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.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);/*w ww.j  av a 2  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.
    }
}