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

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

Introduction

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

Prototype

void setCellStyle(CellStyle style);

Source Link

Document

Set the style for the cell.

Usage

From source file:com.github.jferard.spreadsheetwrapper.xls.poi.XlsPoiWriter.java

License:Open Source License

/**
 * @return/*  w  ww .j  a v a  2  s.  c om*/
 */
@Override
public Date setDate(final int r, final int c, final Date date) {
    final Cell cell = this.getOrCreatePOICell(r, c);
    cell.setCellValue(date);
    if (this.dateCellStyle != null)
        cell.setCellStyle(this.dateCellStyle);
    return date;
}

From source file:com.github.luischavez.lat.excel.Excel.java

License:Open Source License

protected void createCell(int index, Row row, CellStyle style, String value) {
    Cell cell = row.createCell(index);
    if (null != style) {
        cell.setCellStyle(style);
    }//w  ww.  j a  v a 2  s.  c o m
    cell.setCellValue(value);
}

From source file:com.github.luischavez.lat.excel.Excel.java

License:Open Source License

protected void createNumber(int index, Row row, CellStyle style, double value) {
    Cell cell = row.createCell(index);
    if (null != style) {
        cell.setCellStyle(style);
    }/*w  w  w .j  a va 2 s. c o  m*/
    cell.setCellValue(value);
}

From source file:com.github.luischavez.lat.excel.Excel.java

License:Open Source License

protected void createFormula(int index, Row row, CellStyle style, String formula) {
    Cell cell = row.createCell(index);
    if (null != style) {
        cell.setCellStyle(style);
    }//from  www .j  a  va2  s  . co  m
    cell.setCellType(Cell.CELL_TYPE_FORMULA);
    cell.setCellFormula(formula);
}

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

License:Apache License

/**
 * Finalization of the implementation <code>Cells</code>.
 *
 * @return an instance of the implementation <code>Row</code>
 * @see com.github.svrtm.xlreport.Row#addCells(int)
 * @see com.github.svrtm.xlreport.Row#addCells(int...)
 *//* w  ww .  j ava2  s. com*/
@SuppressWarnings("unchecked")
public TR configureCells() {
    if (columnWidth == -1 && incrementValue == -1 && cellStyle == null)
        return (TR) row;

    int increment = incrementValue;
    for (final int i : indexesCells) {
        if (row.cells.get(i) == null)
            row.prepareNewCell(i).createCell();

        final org.apache.poi.ss.usermodel.Row poiRow = row.poiRow;
        final Cell poiCell = poiRow.getCell(i);
        if (poiCell == null)
            throw new ReportBuilderException(
                    format("A cell of number %d [row:%d] can't be found. Please, create a cell before using it",
                            i, poiRow.getRowNum()));

        if (columnWidth != -1)
            poiCell.getSheet().setColumnWidth(i, columnWidth);
        if (incrementValue != -1)
            poiCell.setCellValue(increment++);
        if (enableAutoSize)
            setAutoSizeColumn(poiCell);

        if (cellStyle != null)
            if (row.cells.get(i).cellStyle == null) {
                // Apply a style to the cell
                final CellStyle poiStyle = cellStyle.getStyle();
                poiCell.setCellStyle(poiStyle);

                final List<Cell> mergedCells = findMergedCells(poiCell);
                if (mergedCells != null)
                    for (final Cell mergedCell : mergedCells)
                        mergedCell.setCellStyle(poiStyle);
            }
    }

    return (TR) row;
}

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

License:Open Source License

private void processCell(Row row, Element td) {
    TableCellBox cellBox = (TableCellBox) (box.getElementBoxes(td)).get(0);
    CellStyle style = prepareCellStyle(cellBox.getStyle());

    mergedCells.stream().filter(merge -> merge.isApplicable(row)).forEach(merge -> merge.fillRow(row));

    int cellNumber = row.getPhysicalNumberOfCells();
    Cell cell = row.createCell(cellNumber);
    cell.setCellValue(td.getTextContent());
    cell.setCellStyle(style);

    mergeCells(row, td, cellNumber, style);
    calculateColumnWidth(cellNumber, cellBox.getStyle());
}

From source file:com.github.xiilei.ecdiff.Processor.java

License:Apache License

public boolean cellComparer(Cell src_cell, Cell dist_cell) {
    if (dist_cell == null) {
        logger.warn("comparer,dist_cell is null");
        return false;
    }//from  w  ww. j ava  2 s  . c om
    if (src_cell == null || !getStringCellValue(dist_cell).trim().equals(getStringCellValue(src_cell))) {
        CellStyle style = dist_cell.getCellStyle();
        style.setFont(this.font);
        dist_cell.setCellStyle(style);
    }
    return true;
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception {
    Font titleFont = p_workBook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Times");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    CellStyle cs = p_workBook.createCellStyle();
    cs.setFont(titleFont);//w  w w  . j  a v  a2  s .  c  o  m

    Row titleRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(titleRow, 0);
    titleCell.setCellValue("DITA QA Report");
    titleCell.setCellStyle(cs);
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private void addLanguageHeader(Workbook p_workBook, Sheet p_sheet) throws Exception {
    int col = 0;//www .  java  2s  . c o  m
    int row = LANGUAGE_HEADER_ROW;

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

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

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private void writeLanguageInfo(Workbook p_workbook, Sheet p_sheet, String p_sourceLang, String p_targetLang)
        throws Exception {
    int col = 0;//w  ww . jav  a 2  s.c o m
    int row = LANGUAGE_INFO_ROW;
    CellStyle contentStyle = getContentStyle(p_workbook);
    Row langInfoRow = getRow(p_sheet, row);

    // Source Language
    Cell srcLangCell = getCell(langInfoRow, col++);
    srcLangCell.setCellValue(p_sourceLang);
    srcLangCell.setCellStyle(contentStyle);

    // Target Language
    Cell trgLangCell = getCell(langInfoRow, col++);
    trgLangCell.setCellValue(p_targetLang);
    trgLangCell.setCellStyle(contentStyle);
}