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:org.kopsox.spreadsheet.data.excel.ExcelSheet.java

License:Open Source License

@Override
public void mergeRegion(int firstRow, int lastRow, int firstColumn, int lastColumn) {

    if (regions.containsKey(new CellRegion(firstRow, lastRow, firstColumn, lastColumn))) {
        return;/*from   w w  w .  ja  v a  2  s  .c  o  m*/
    }

    CellRangeAddress adress = new CellRangeAddress(firstRow, lastRow, firstColumn, lastColumn);
    int index = this.sheet.addMergedRegion(adress);

    CellRegion region = new CellRegion(firstRow, lastRow, firstColumn, lastColumn, index);

    regions.put(region, region);
}

From source file:org.kuali.test.runner.output.PoiHelper.java

License:Educational Community License

/**
 *
 * @param testSuite/*  w w  w. j av  a  2  s .co m*/
 * @param kualiTest
 */
public void writeReportHeader(TestSuite testSuite, KualiTest kualiTest) {
    Sheet sheet = wb.getSheetAt(0);
    Row row = sheet.createRow(currentReportRow);
    sheet.addMergedRegion(new CellRangeAddress(currentReportRow, currentReportRow, 0, HEADER_NAMES.length - 1));

    Cell cell = row.createCell(0);

    StringBuilder headerString = new StringBuilder(128);

    headerString.append("Platform: ");

    if (testSuite != null) {
        headerString.append(testSuite.getPlatformName());
        headerString.append(", Test Suite: ");
        headerString.append(testSuite.getName());
    } else {
        headerString.append(kualiTest.getTestHeader().getPlatformName());
        headerString.append(", Test: ");
        headerString.append(kualiTest.getTestHeader().getTestName());
    }

    headerString.append(", Run Date: ");
    headerString.append(Constants.DEFAULT_TIMESTAMP_FORMAT.format(new Date()));
    cell.setCellValue(headerString.toString());
    cell.setCellStyle(cellStyleHeader);

}

From source file:org.kuali.test.runner.output.PoiHelper.java

License:Educational Community License

/**
 * /*from  w  w w.ja  v a2  s  .c o  m*/
 * @param op
 * @param showIndex 
 */
public void writeCommentEntry(Operation op, boolean showIndex) {
    Sheet sheet = wb.getSheetAt(0);
    Row retval = sheet.createRow(++currentReportRow);

    // blank operation number
    Cell cell = retval.createCell(0);
    if (showIndex) {
        cell.setCellValue(op.getIndex());
    }
    cell.setCellStyle(cellStyleNormal);

    sheet.addMergedRegion(new CellRangeAddress(currentReportRow, currentReportRow, 1, HEADER_NAMES.length - 1));

    cell = retval.createCell(1);
    cell.setCellValue(op.getCommentOperation().getComment());
    cell.setCellStyle(cellStyleNormal);
}

From source file:org.kuali.test.runner.output.PoiHelper.java

License:Educational Community License

/**
 *
 * @param test//from  ww  w  .j a v a 2  s .  c om
 */
public void writeTestHeader(KualiTest test) {
    Sheet sheet = wb.getSheetAt(0);
    Row row = sheet.createRow(++currentReportRow);
    sheet.addMergedRegion(new CellRangeAddress(currentReportRow, currentReportRow, 0, HEADER_NAMES.length - 1));

    Cell cell = row.createCell(0);
    cell.setCellValue("Test: " + test.getTestHeader().getTestName());
    cell.setCellStyle(cellStyleTestHeader);
}

From source file:org.metaeffekt.core.inventory.processor.writer.InventoryWriter.java

License:Apache License

private void writeArtifacts(Inventory inventory, HSSFWorkbook myWorkBook) {
    HSSFSheet mySheet = myWorkBook.createSheet("Artifact Inventory");
    mySheet.createFreezePane(0, 1);/*  w w  w  .j a  v  a 2s . co m*/
    mySheet.setDefaultColumnWidth(20);

    HSSFRow myRow = null;
    HSSFCell myCell = null;

    int rowNum = 0;

    myRow = mySheet.createRow(rowNum++);

    HSSFCellStyle headerStyle = createHeaderStyle(myWorkBook);

    int cellNum = 0;
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Id"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Checksum"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Component"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Group Id"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Version"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Latest Version"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("License"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Security Relevance"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Security Category"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Vulnerability"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Classification"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Comment"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("URL"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Projects"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Verified"));

    // create columns for key / value map content
    Set<String> attributes = new HashSet<>();
    for (Artifact artifact : inventory.getArtifacts()) {
        attributes.addAll(artifact.getAttributes());
    }

    List<String> ordered = new ArrayList<>(attributes);
    Collections.sort(ordered);

    for (String key : ordered) {
        myCell = myRow.createCell(cellNum++);
        myCell.setCellStyle(headerStyle);
        myCell.setCellValue(new HSSFRichTextString(key));
    }

    int numCol = cellNum;

    for (Artifact artifact : inventory.getArtifacts()) {
        myRow = mySheet.createRow(rowNum++);

        cellNum = 0;
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getId()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getChecksum()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getComponent()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getGroupId()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getVersion()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getLatestAvailableVersion()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getLicense()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.isSecurityRelevant() ? "X" : ""));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getSecurityCategory()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getVulnerability()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getClassification()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getComment()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.getUrl()));
        myCell = myRow.createCell(cellNum++);
        String projects = artifact.getProjects().toString();
        projects = projects.substring(1, projects.length() - 1);
        myCell.setCellValue(new HSSFRichTextString(projects));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(artifact.isVerified() ? "X" : ""));

        for (String key : ordered) {
            myCell = myRow.createCell(cellNum++);
            myCell.setCellValue(new HSSFRichTextString(artifact.get(key)));
        }
    }

    /** adjust with of cells
    for (int i = 0; i <= numCol; i++) {
    Integer width = (Integer) inventory.getContextMap().get("artifacts.column[" + i + "].width");
    if (width != null) {
        mySheet.setColumnWidth(i, Math.min(width, 255));
    }
    }*/

    mySheet.setAutoFilter(new CellRangeAddress(0, 65000, 0, numCol - 1));
}

From source file:org.metaeffekt.core.inventory.processor.writer.InventoryWriter.java

License:Apache License

private void writeNotices(Inventory inventory, HSSFWorkbook myWorkBook) {
    HSSFSheet mySheet = myWorkBook.createSheet("License Notices");
    mySheet.createFreezePane(0, 1);//from   w w  w.  ja v a 2s .c o  m
    mySheet.setDefaultColumnWidth(80);

    HSSFRow myRow = null;
    HSSFCell myCell = null;

    int rowNum = 0;

    myRow = mySheet.createRow(rowNum++);

    HSSFCellStyle headerStyle = createHeaderStyle(myWorkBook);

    int cellNum = 0;
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Component"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Version"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("License"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("License in Effect"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Source Category"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("License Notice"));
    myCell = myRow.createCell(cellNum++);
    myCell.setCellStyle(headerStyle);
    myCell.setCellValue(new HSSFRichTextString("Comment"));

    // create columns for key / value map content
    Set<String> attributes = new HashSet<>();
    for (LicenseMetaData licenseMetaData : inventory.getLicenseMetaData()) {
        attributes.addAll(licenseMetaData.getAttributes());
    }

    List<String> ordered = new ArrayList<>(attributes);
    Collections.sort(ordered);

    for (String key : ordered) {
        myCell = myRow.createCell(cellNum++);
        myCell.setCellStyle(headerStyle);
        myCell.setCellValue(new HSSFRichTextString(key));
    }

    int numCol = cellNum;

    for (LicenseMetaData licenseMetaData : inventory.getLicenseMetaData()) {
        myRow = mySheet.createRow(rowNum++);

        cellNum = 0;
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getComponent()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getVersion()));
        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getLicense()));
        myCell = myRow.createCell(cellNum++);
        String licenseInEffect = licenseMetaData.getLicenseInEffect();
        if (StringUtils.isEmpty(licenseInEffect)) {
            licenseInEffect = licenseMetaData.getLicense();
        }
        myCell.setCellValue(new HSSFRichTextString(licenseInEffect));

        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getSourceCategory()));

        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getNotice()));

        myCell = myRow.createCell(cellNum++);
        myCell.setCellValue(new HSSFRichTextString(licenseMetaData.getComment()));

        for (String key : ordered) {
            myCell = myRow.createCell(cellNum++);
            myCell.setCellValue(new HSSFRichTextString(licenseMetaData.get(key)));
        }
    }

    /**
    for (int i = 0; i < 6; i++) {
    Integer width = (Integer) inventory.getContextMap().get("obligations.column[" + i + "].width");
    if (width != null) {
        mySheet.setColumnWidth(i, Math.min(width, 255));
    }
    }
     */

    mySheet.setAutoFilter(new CellRangeAddress(0, 65000, 0, numCol - 1));

}

From source file:org.meveocrm.admin.action.reporting.MeasurementBean.java

License:Open Source License

public void generateExcelReport(Object document)
        throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {

    FacesContext facesContext = FacesContext.getCurrentInstance();
    String messageBundleName = facesContext.getApplication().getMessageBundle();
    ResourceBundle messageBundle = ResourceBundle.getBundle(messageBundleName);

    HSSFWorkbook workbook = (HSSFWorkbook) document;
    HSSFSheet sheet = workbook.getSheetAt(0);

    Row row = sheet.createRow(1);//from ww  w .  ja  va 2 s .  c  om
    Cell dateCell = row.createCell(0);
    dateCell.setCellValue("Date");
    dateCell.setCellStyle(getCellStyle(workbook));

    int j = 1;
    while (hasDimension(j) && j < 4) {
        if (j > 1 && getDimension(j).size() > 0) {
            row = sheet.createRow(j);
        }
        log.info(getDimension(j).toString());
        Integer dimCounter = 1;
        Integer colspan = 0;
        for (String dimension : getDimension(j)) {
            Integer colFrom = dimCounter + colspan;
            Cell cell = row.createCell(dimCounter + colspan);

            cell.setCellStyle(getCellStyle(workbook));
            if (hasSubDimension(dimension, j)) {
                colspan += getColspan(dimension, j);
                Integer colTo = colspan;
                sheet.addMergedRegion(new CellRangeAddress(j, j, colFrom, colTo));
                for (int i = dimCounter + 1; i <= colspan; i++) {
                    Cell blankCell = row.createCell(i);
                    blankCell.setCellStyle(getCellStyle(workbook));
                }

            } else {
                dimCounter++;
            }

            if (dimension1Filter != null && !dimension1Filter.isEmpty()) {
                if (dimension1Filter.equals(dimension) && j <= 1) {
                    cell.setCellValue(dimension);
                } else if (j > 1) {
                    cell.setCellValue(dimension);
                }
            } else {
                cell.setCellValue(dimension);
            }
        }
        j++;

    }

    // for (List<MeasuredValue> mv : mainMVModel) {
    row = sheet.createRow(j);
    int mvCounter = 0;
    for (MeasuredValue subMV : mainMVModel) {
        Cell cell = row.createCell(mvCounter);
        if (mvCounter == 0) {
            cell.setCellValue(sdf1.format(subMV.getDate()));
        } else {
            if (subMV.getValue() != null && subMV.getMeasurementPeriod() == period) {
                cell.setCellValue(subMV.getValue() == null ? 0 : subMV.getValue().doubleValue());
            }
        }

        cell.setCellStyle(getCellStyle(workbook));

        sheet.autoSizeColumn(mvCounter, true);
        mvCounter++;
    }
    j++;

    // }

    HSSFRow reportTitleRow = sheet.getRow(0);
    HSSFCell reportTitleCell = reportTitleRow.createCell(0);

    reportTitleCell.setCellValue(messageBundle.getString("menu.measuredValues") + " "
            + new SimpleDateFormat("MMMM").format(selectedDate) + ","
            + new SimpleDateFormat("yyyy").format(selectedDate) + " "
            + messageBundle.getString("entity.measuredvalue.measurementPeriod") + " : "
            + messageBundle.getString("enum.measurementperiod." + measuredPeriod));

    sheet.autoSizeColumn(0);
}

From source file:org.neo4art.colour.write.WriteFileCsv.java

License:Apache License

public void createSheet() {
    try {/* www.  java2 s.com*/
        FileOutputStream fileOut = new FileOutputStream(csv);
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet worksheet = workbook.createSheet("Pixel image");
        HSSFRow row1 = worksheet.createRow((short) 0);

        HSSFCell cellA1 = row1.createCell(0);
        HSSFCell cellA2 = row1.createCell(1);
        HSSFCell cellA3 = row1.createCell(2);

        cellA1.setCellValue("RED");
        cellA2.setCellValue("GREEN");
        cellA3.setCellValue("BLUE");

        CellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
        HSSFSheet worksheetReport = workbook.createSheet("Report");
        HSSFRow rowReport = worksheetReport.createRow((short) 0);
        HSSFRow rowReport1 = worksheetReport.createRow((short) 2);
        HSSFRow rowReport2 = worksheetReport.createRow((short) 4);
        HSSFRow rowReport3 = worksheetReport.createRow((short) 6);
        HSSFRow rowReport4 = worksheetReport.createRow((short) 8);
        HSSFRow rowReport5 = worksheetReport.createRow((short) 10);
        HSSFRow rowReport6 = worksheetReport.createRow((short) 12);

        worksheetReport.addMergedRegion(new CellRangeAddress(0, 0, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(2, 2, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(4, 4, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(6, 6, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(7, 7, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(8, 8, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(9, 9, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(10, 10, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(11, 11, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(12, 12, 0, 2));
        worksheetReport.addMergedRegion(new CellRangeAddress(13, 13, 0, 2));

        HSSFCell cellB1 = rowReport.createCell(0);
        cellB1.setCellStyle(cellStyle);
        HSSFCell cellB2 = rowReport1.createCell(0);
        cellB2.setCellStyle(cellStyle);
        HSSFCell cellB3 = rowReport2.createCell(0);
        cellB3.setCellStyle(cellStyle);
        HSSFCell cellB4 = rowReport3.createCell(0);
        cellB4.setCellStyle(cellStyle);
        HSSFCell cellB5 = rowReport4.createCell(0);
        cellB5.setCellStyle(cellStyle);
        HSSFCell cellB6 = rowReport5.createCell(0);
        cellB6.setCellStyle(cellStyle);
        HSSFCell cellB7 = rowReport6.createCell(0);
        cellB7.setCellStyle(cellStyle);

        cellB1.setCellValue("MAX RGB");
        cellB2.setCellValue("MIN RGB");
        cellB3.setCellValue("AVG RGB");
        cellB4.setCellValue("NAME RGB AVG");
        cellB5.setCellValue("NAME RGB MAX");
        cellB6.setCellValue("NAME RGB MIN");
        cellB7.setCellValue("INCREMENT");

        workbook.write(fileOut);
        workbook.close();
        fileOut.flush();
        fileOut.close();
    } catch (Exception e) {

    }
}

From source file:org.netxilia.impexp.impl.ExcelExportService.java

License:Open Source License

@Override
public void exportSheetTo(INetxiliaSystem workbookProcessor, SheetFullName sheetName, OutputStream out,
        IProcessingConsole console)/* www .j  a va 2s. c  o m*/
        throws ExportException, NetxiliaResourceException, NetxiliaBusinessException {
    Workbook poiWorkbook = new HSSFWorkbook();
    Sheet poiSheet = poiWorkbook.createSheet(sheetName.getSheetName());
    ISheet nxSheet = null;
    try {
        nxSheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId()).getSheet(sheetName.getSheetName());

        SheetData nxSheetData = nxSheet.receiveSheet().getNonBlocking();
        for (AreaReference area : nxSheetData.getSpans()) {
            poiSheet.addMergedRegion(new CellRangeAddress(area.getFirstRowIndex(), area.getLastRowIndex(),
                    area.getFirstColumnIndex(), area.getLastColumnIndex()));
        }
        // cells
        Matrix<CellData> nxCells = nxSheet.receiveCells(AreaReference.ALL).getNonBlocking();

        int rowIndex = 0;
        for (List<CellData> nxRow : nxCells.getRows()) {
            Row poiRow = poiSheet.createRow(rowIndex);
            for (CellData nxCell : nxRow) {
                if (nxCell != null) {
                    Cell poiCell = poiRow.createCell(nxCell.getReference().getColumnIndex());
                    try {
                        copyCellValue(nxCell, poiCell);
                    } catch (Exception ex) {
                        if (console != null) {
                            console.println("Error " + nxCell.getReference() + ":" + ex);
                        }
                    }
                }
            }
            rowIndex++;
        }

        // columns
        List<ColumnData> nxColumns = nxSheet.receiveColumns(Range.ALL).getNonBlocking();
        for (int c = 0; c < nxColumns.size(); ++c) {
            ColumnData col = nxColumns.get(c);
            if (col.getWidth() > 0) {
                poiSheet.setColumnWidth(c, PoiUtils.pixel2WidthUnits(col.getWidth()));
            }

            PoiUtils.netxiliaStyle2Poi(col.getStyles(), poiSheet.getWorkbook(), poiSheet.getColumnStyle(c));
        }
    } catch (StorageException e) {
        throw new ExportException(e);
    }

    // close the workbook
    try {
        poiWorkbook.write(out);
    } catch (IOException e) {
        throw new ExportException(e);
    }
}

From source file:org.obiba.mica.dataset.search.rest.harmonization.ExcelContingencyWriter.java

License:Open Source License

private void writeTableHeaders(XSSFSheet sheet, String title, List<String> headers) {
    int colNum = headers.size() + 1;

    IntStream.rangeClosed(0, 3).forEach(i -> {
        Row rowTemp = sheet.createRow(i);
        IntStream.rangeClosed(0, colNum).forEach(j -> rowTemp.createCell(j));
    });/*from  w w  w .  ja  v a 2 s. c o  m*/

    Row row = sheet.getRow(0);
    Cell titleLabel = row.getCell(0);
    titleLabel.setCellValue(title);
    titleLabel.setCellStyle(titleStyle);
    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colNum));

    row = sheet.getRow(2);
    Cell crossVarLabel = row.getCell(0);
    crossVarLabel.setCellValue(this.crossVariable.getName());
    sheet.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));

    Cell varLabel = row.getCell(1);
    varLabel.setCellValue(this.variable.getName());
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, colNum - 1));

    Cell totalLabel = row.getCell(colNum);
    totalLabel.setCellValue("Total");
    sheet.addMergedRegion(new CellRangeAddress(2, 3, colNum, colNum));

    int cellnum = 1;
    row = sheet.getRow(3);

    for (String h : headers) {
        Cell cell = row.getCell(cellnum++);
        cell.setCellValue(h);
    }

    addMergedStyles(sheet, new CellRangeAddress(2, 3, 0, colNum));
}