Example usage for org.apache.poi.ss.util CellRangeAddress CellRangeAddress

List of usage examples for org.apache.poi.ss.util CellRangeAddress CellRangeAddress

Introduction

In this page you can find the example usage for org.apache.poi.ss.util CellRangeAddress CellRangeAddress.

Prototype

public CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) 

Source Link

Document

Creates new cell range.

Usage

From source file:com.eryansky.core.excelTools.JsGridReportBase.java

License:Apache License

/**
 * //w  w  w . j a  v  a  2  s.c om
 * @param wb Excel
 * @param title Sheet??
 * @param styles ?
 * @param creator 
 * @param tableData ?
 * @throws Exception
 */
public HSSFWorkbook writeSheet(HSSFWorkbook wb, String title, HashMap<String, HSSFCellStyle> styles,
        String creator, TableData tableData) throws Exception {

    SimpleDateFormat formater = new SimpleDateFormat("yyyyMMdd HHmm");
    String create_time = formater.format(new Date());

    HSSFSheet sheet = wb.createSheet(title);// Excel
    sheet.setDisplayGridlines(false);// ?

    HSSFRow row = sheet.createRow(0);// 
    HSSFCell cell = row.createCell(0);// 
    int rownum = 0;
    cell.setCellValue(new HSSFRichTextString(title));
    HSSFCellStyle style = styles.get("TITLE");
    if (style != null)
        cell.setCellStyle(style);

    TableHeaderMetaData headerMetaData = tableData.getTableHeader();// HTML
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headerMetaData.getColumnCount() - 1));
    row = sheet.createRow(1);

    cell = row.createCell(0);
    cell.setCellValue(new HSSFRichTextString(":"));
    style = styles.get("SUB_TITLE");
    if (style != null)
        cell.setCellStyle(style);

    cell = row.createCell(1);
    cell.setCellValue(new HSSFRichTextString(creator));
    style = styles.get("SUB_TITLE2");
    if (style != null)
        cell.setCellStyle(style);

    cell = row.createCell(2);
    cell.setCellValue(new HSSFRichTextString(":"));
    style = styles.get("SUB_TITLE");
    if (style != null)
        cell.setCellStyle(style);

    cell = row.createCell(3);
    style = styles.get("SUB_TITLE2");
    cell.setCellValue(new HSSFRichTextString(create_time));
    if (style != null)
        cell.setCellStyle(style);

    rownum = 3;// rownum = 1?

    HSSFCellStyle headerstyle = styles.get("TABLE_HEADER");

    System.out.println(JsonMapper.getInstance().toJson(headerMetaData));
    int colnum = 0;
    for (int i = 0; i < headerMetaData.getOriginColumns().size(); i++) {
        TableColumn tc = headerMetaData.getOriginColumns().get(i);
        if (i != 0) {
            colnum += headerMetaData.getOriginColumns().get(i - 1).getLength();
        }
        generateColumn(sheet, tc, headerMetaData.maxlevel, rownum, colnum, headerstyle);
    }
    rownum += headerMetaData.maxlevel;

    List<TableDataRow> dataRows = tableData.getRows();

    HashMap<Integer, Integer> counter = new HashMap<Integer, Integer>();
    HashMap<Integer, String> word = new HashMap<Integer, String>();
    int index = 0;
    for (TableDataRow dataRow : dataRows) {
        row = sheet.createRow(rownum);

        List<TableDataCell> dataCells = dataRow.getCells();
        int size = headerMetaData.getColumns().size();
        index = -1;
        for (int i = 0; i < size; i++) {
            TableColumn tc = headerMetaData.getColumns().get(i);
            if (!tc.isVisible())
                continue;
            index++;

            String value = dataCells.get(i).getValue();
            if (tc.isGrouped()) {
                String w = word.get(index);
                if (w == null) {
                    word.put(index, value);
                    counter.put(index, 1);
                    createCell(row, tc, dataCells, i, index, styles);
                } else {
                    if (w.equals(value)) {
                        counter.put(index, counter.get(index) + 1);
                    } else {
                        stopGrouping(sheet, word, counter, index, size, rownum, styles.get("STRING"));

                        word.put(index, value);
                        counter.put(index, 1);
                        createCell(row, tc, dataCells, i, index, styles);
                    }
                }
            } else {
                createCell(row, tc, dataCells, i, index, styles);
            }
        }
        rownum++;
    }

    stopGrouping(sheet, word, counter, 0, index, rownum, styles.get("STRING"));
    // ???
    for (int c = 0; c < headerMetaData.getColumns().size(); c++) {
        sheet.autoSizeColumn((short) c, true);
    }
    sheet.setGridsPrinted(true);

    return wb;
}

From source file:com.esd.cs.common.PoiCreateExcel.java

License:Open Source License

/**
 * //from w w w.  j a v a2s  .  c o m
 * 
 * @param FilePath
 * @param companyList
 * @return
 */
public static boolean createRepeaExcel(String FilePath, List<ReportViewModel> companyList, ReportModel model) {
    // Excel Workbook,excel
    HSSFWorkbook wb = new HSSFWorkbook();
    // Excelsheet,exceltab
    HSSFSheet sheet = wb.createSheet("sheet1");
    // excel?
    sheet.setColumnWidth(0, 4000);
    sheet.setColumnWidth(1, 3500);

    // Excel?
    HSSFRow headRow0 = sheet.createRow(0);
    HSSFCell headCell = headRow0.createCell(0);
    // ??
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 13));// ???
    headCell = headRow0.createCell(0);
    // 
    headCell.setCellValue(model.getTitle());
    // ?
    HSSFCellStyle style = wb.createCellStyle();
    style.setFillBackgroundColor(HSSFColor.GREEN.index);
    style.setAlignment(CellStyle.ALIGN_CENTER);// 
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);// 
    // 
    HSSFFont font = wb.createFont();
    font.setFontHeightInPoints((short) 12);
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 
    style.setFont(font);
    headCell.setCellStyle(style);

    // ? ??
    HSSFRow RowTow = sheet.createRow(1);
    HSSFCell CellTow = headRow0.createCell(1);
    // ??
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 5));// ???
    CellTow = RowTow.createCell(0);
    // 
    CellTow.setCellValue(model.getCreateCompany());

    // ? 
    // ??
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 6, 13));// ???
    CellTow = RowTow.createCell(6);
    HSSFCellStyle style1 = wb.createCellStyle();
    style1.setFillBackgroundColor(HSSFColor.GREEN.index);
    style1.setAlignment(CellStyle.ALIGN_RIGHT);// ?
    CellTow.setCellStyle(style1);
    // 
    CellTow.setCellValue(model.getCreateData());

    // ?
    HSSFRow headRow = sheet.createRow(2);
    HSSFCell headell = headRow.createCell(2);
    // ???
    headell = headRow.createCell(0);
    headell.setCellValue(model.getType());

    headell = headRow.createCell(1);
    headell.setCellValue("??");

    headell = headRow.createCell(2);
    headell.setCellValue("??");
    sheet.setColumnWidth(2, 3000); // 

    headell = headRow.createCell(3);
    headell.setCellValue("???");
    sheet.setColumnWidth(3, 3000); // 

    headell = headRow.createCell(4);
    headell.setCellValue("???");
    sheet.setColumnWidth(4, 4000); // 

    headell = headRow.createCell(5);
    headell.setCellValue("???");
    sheet.setColumnWidth(5, 4000); // 

    headell = headRow.createCell(6);
    headell.setCellValue("???");
    sheet.setColumnWidth(6, 4500); // 

    headell = headRow.createCell(7);
    headell.setCellValue("");
    sheet.setColumnWidth(8, 4000);

    headell = headRow.createCell(8);
    headell.setCellValue("");
    sheet.setColumnWidth(8, 4000);

    headell = headRow.createCell(9);
    headell.setCellValue("");
    sheet.setColumnWidth(9, 4000);

    headell = headRow.createCell(10);
    headell.setCellValue("?");
    sheet.setColumnWidth(10, 4000);

    headell = headRow.createCell(11);
    headell.setCellValue("???");

    headell = headRow.createCell(12);
    headell.setCellValue("?");

    headell = headRow.createCell(13);
    headell.setCellValue("?");

    for (int i = 0; i < companyList.size(); i++) {
        ReportViewModel company = companyList.get(i);
        // Excel?
        HSSFRow row = sheet.createRow(i + 3);
        HSSFCell cell = row.createCell(i + 3);
        // ???
        // ????
        cell = row.createCell(0);
        cell.setCellValue(company.getReportName());
        // ??
        cell = row.createCell(1);
        cell.setCellValue(company.getUnitNum());
        // ??
        cell = row.createCell(2);
        cell.setCellValue(company.getEmpTotal());

        // ???
        cell = row.createCell(3);
        cell.setCellValue(company.getUnAudit());

        // ?, ???
        cell = row.createCell(4);
        cell.setCellValue(company.getUnReAudit());

        // ?, ??
        cell = row.createCell(5);
        cell.setCellValue(company.getAuditOk());

        // ?, ??
        cell = row.createCell(6);
        cell.setCellValue(company.getUnauditOk());

        // 
        cell = row.createCell(7);
        cell.setCellValue(company.getShouldTotal().toString());

        // ?
        cell = row.createCell(8);
        cell.setCellValue(company.getAlreadyTotal().toString());

        // 
        cell = row.createCell(9);
        cell.setCellValue(company.getLessTotal().toString());
        // ?
        cell = row.createCell(10);
        cell.setCellValue(company.getAmountPayable().toString());
        // ???
        cell = row.createCell(11);
        cell.setCellValue(company.getReductionAmount().toString());
        // ?
        cell = row.createCell(12);
        cell.setCellValue(company.getActualAmount().toString());
        // ?
        cell = row.createCell(13);
        cell.setCellValue(company.getAlreadyAmount().toString());
    }

    // ? 
    HSSFRow row = sheet.createRow(companyList.size() + 3);
    HSSFCell cell = row.createCell(companyList.size() + 3);
    // ???
    // ????
    sheet.addMergedRegion(new CellRangeAddress(companyList.size() + 3, companyList.size() + 3, 0, 13));// ???
    cell = row.createCell(0);
    // ?
    HSSFCellStyle styleFoot = wb.createCellStyle();
    styleFoot.setAlignment(CellStyle.ALIGN_RIGHT);// ?
    cell.setCellStyle(styleFoot);
    // 
    cell.setCellValue(model.getCreatePeople());

    try {
        FileOutputStream os = new FileOutputStream(FilePath);
        wb.write(os);
        os.flush();
        os.close();
        companyList.clear();
        companyList = null;
        os = null;
        wb = null;
        System.gc();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

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

License:Common Public License

/**
 * @param context/*from  w w  w.  j  av  a  2s  .  co m*/
 * @return
 */
protected CellRangeAddress createMergedRegion(RenderContext context) {
    if (context.getColumnSpan() > 1 || context.getRowSpan() > 1) {
        int firstRow = context.getRowIndex() + getRowOffset();
        int lastRow = firstRow + context.getRowSpan() - 1;
        int firstCol = context.getColumnIndex() + getColOffset();
        int lastCol = firstCol + context.getColumnSpan() - 1;

        return new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
    } else {
        return null;
    }
}

From source file:com.fjn.helper.common.io.file.office.excel.ListExcelSheetEditor.java

License:Apache License

/**
 * ?//from  w  w  w  .  j av a 2  s .co m
 * @param firstRow
 * @param lastRow
 * @param firstCol
 * @param lastCol
 */
public void merge(int firstRow, int lastRow, int firstCol, int lastCol) {
    excelSheet.sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol));
}

From source file:com.github.igor_kudryashov.utils.excel.ExcelWriter.java

License:Apache License

/**
 * Format a table of worksheet// w  ww.ja  va2  s. c o  m
 *
 * @param sheet
 *            Name of sheet
 * @param withHeader
 *            <code>true</code> for create auto filter and freeze pane in
 *            first row, otherwise <code>false</code>
 */
public void setAutoSizeColumns(Sheet sheet, boolean withHeader) {
    if (sheet.getLastRowNum() > 0) {
        if (withHeader) {
            int x = sheet.getRow(sheet.getLastRowNum()).getLastCellNum();
            CellRangeAddress range = new CellRangeAddress(0, 0, 0, x - 1);
            sheet.setAutoFilter(range);
            sheet.createFreezePane(0, 1);
        }
        // auto-sizing columns
        if (columnWidth.containsKey(sheet.getSheetName())) {
            Map<Integer, Integer> width = columnWidth.get(sheet.getSheetName());
            for (Map.Entry<Integer, Integer> entry : width.entrySet()) {
                sheet.setColumnWidth(entry.getKey(), entry.getValue());
            }
        }
    }
}

From source file:com.github.svrtm.xlreport.ABuilder.java

License:Apache License

/**
 * Adds a merged region of cells (hence those cells form one)
 *
 * @param firstRow//from  w  w  w . j  av a  2  s.  c  o  m
 *            Index of first row
 * @param lastRow
 *            Index of last row (inclusive), must be equal to or larger than
 *            {@code firstRow}
 * @param firstCol
 *            Index of first column
 * @param lastCol
 *            Index of last column (inclusive), must be equal to or larger
 *            than {@code firstCol}
 * @return this
 */
@SuppressWarnings("unchecked")
public HB mergedRegion(final int firstRow, final int lastRow, final int firstCol, final int lastCol) {
    if (regionsList == null)
        regionsList = new ArrayList<CellRangeAddress>(1);

    CellRangeAddress region;
    region = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
    regionsList.add(region);
    sheet.addMergedRegion(region);
    return (HB) this;
}

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;/*from  w w w .  j av a2  s  .c o  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.customize.ExcelReportWriter.java

License:Apache License

public void mergeCells(int beginColumn, int beginRow, int endColumn, int endRow) throws IOException {
    this.workSheet.addMergedRegion(new CellRangeAddress(beginRow, endRow, beginColumn, endColumn));
    setRegionStyle(this.workSheet, new CellRangeAddress(beginRow, endRow, beginColumn, endColumn), headerStyle);
}

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);//ww w  . ja va2  s .c om
    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.
    }
}