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.asakusafw.testdata.generator.excel.SheetEditor.java

License:Apache License

private void fillRuleFormat(Sheet sheet) {
    assert sheet != null;
    Cell value = getCell(sheet, RuleSheetFormat.FORMAT, 0, 1);
    value.setCellStyle(info.lockedStyle);
    value.setCellValue(RuleSheetFormat.FORMAT_VERSION);
}

From source file:com.asakusafw.testdata.generator.excel.SheetEditor.java

License:Apache License

private void fillRuleTotalCondition(Sheet sheet) {
    assert sheet != null;
    Cell value = getCell(sheet, RuleSheetFormat.TOTAL_CONDITION, 0, 1);
    value.setCellStyle(info.optionsStyle);
    String[] options = TotalConditionKind.getOptions();
    value.setCellValue(options[0]);//  w  ww .  j  a  v  a  2 s.  c o m
    setExplicitListConstraint(sheet, options, value.getRowIndex(), value.getColumnIndex(), value.getRowIndex(),
            value.getColumnIndex());
}

From source file:com.asakusafw.testdata.generator.excel.SheetEditor.java

License:Apache License

private void setTitle(Sheet sheet, RuleSheetFormat item) {
    assert sheet != null;
    assert item != null;
    Cell cell = getCell(sheet, item.getRowIndex(), item.getColumnIndex());
    cell.setCellStyle(info.titleStyle);
    cell.setCellValue(item.getTitle());/*from   ww w. jav  a2  s . c o m*/
}

From source file:com.asakusafw.testdata.generator.excel.SheetEditor.java

License:Apache License

private void fillRulePropertyConditions(Sheet sheet, ModelDeclaration model) {
    int index = 1;
    for (PropertyDeclaration property : model.getDeclaredProperties()) {
        Cell name = getCell(sheet, RuleSheetFormat.PROPERTY_NAME, index, 0);
        name.setCellStyle(info.lockedStyle);
        name.setCellValue(property.getName().identifier);

        Cell value = getCell(sheet, RuleSheetFormat.VALUE_CONDITION, index, 0);
        value.setCellStyle(info.optionsStyle);
        if (index == 1) {
            value.setCellValue(ValueConditionKind.KEY.getText());
        } else {/*  w  w  w  .ja v  a2  s .c  o m*/
            value.setCellValue(ValueConditionKind.ANY.getText());
        }

        Cell nullity = getCell(sheet, RuleSheetFormat.NULLITY_CONDITION, index, 0);
        nullity.setCellStyle(info.optionsStyle);
        nullity.setCellValue(NullityConditionKind.NORMAL.getText());

        Cell comments = getCell(sheet, RuleSheetFormat.COMMENTS, index, 0);
        comments.setCellStyle(info.dataStyle);
        comments.setCellValue(property.getDescription() == null ? property.getType().toString()
                : property.getDescription().getText());

        Cell options = getCell(sheet, RuleSheetFormat.EXTRA_OPTIONS, index, 0);
        options.setCellStyle(info.dataStyle);

        index++;
    }

    int start = RuleSheetFormat.PROPERTY_NAME.getRowIndex() + 1;
    int end = RuleSheetFormat.PROPERTY_NAME.getRowIndex() + index;
    setExplicitListConstraint(sheet, ValueConditionKind.getOptions(), start,
            RuleSheetFormat.VALUE_CONDITION.getColumnIndex(), end,
            RuleSheetFormat.VALUE_CONDITION.getColumnIndex());
    setExplicitListConstraint(sheet, NullityConditionKind.getOptions(), start,
            RuleSheetFormat.NULLITY_CONDITION.getColumnIndex(), end,
            RuleSheetFormat.NULLITY_CONDITION.getColumnIndex());
}

From source file:com.axelor.apps.admin.service.ViewDocExportService.java

License:Open Source License

private void writeCell(XSSFRow row, Integer oldRowIndex, int count, XSSFCellStyle cellStyle) {

    XSSFRow oldRow = oldSheet.getRow(oldRowIndex);

    while (count < oldRow.getLastCellNum()) {
        XSSFCell oldCell = oldRow.getCell(count);
        Cell cell = row.createCell(count);
        cell.setCellStyle(cellStyle);
        cell.setCellValue(oldCell.getStringCellValue());
        count++;/*www . j  a  v a 2 s.  c  o m*/
    }

}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyExcelExporter.java

License:Apache License

/**
 * Creates the index sheet based on the given sheet names.
 * /*  w w w . j a v  a  2 s  .  c  o m*/
 * @param sheetNames
 */
protected void createIndexSheet(final Collection<T> components) {

    final Sheet indexSheet = workbook.createSheet("INDEX");

    final List<T> filteredComponents = Lists.newArrayList(Iterables.filter(components, new Predicate<T>() {
        @Override
        public boolean apply(T input) {
            return isToExport(getComponentId(input));
        }
    }));

    final List<String> sheetNames = extractSheetNamesFromTerminologyComponents(filteredComponents);

    final Row firstRow = indexSheet.createRow(0);
    createCell(firstRow, getIndexSheetHeaderName(), BOLD_STYLE, 0);

    for (int i = 0; i < sheetNames.size(); i++) {

        final String sheetName = getFinalSheetName(i + 1, sheetNames.get(i));
        final Hyperlink hyperlink = workbook.getCreationHelper().createHyperlink(XSSFHyperlink.LINK_DOCUMENT);

        hyperlink.setLabel(sheetName);
        hyperlink.setAddress(String.format("'%s'!A1", sheetName));

        final Row row = indexSheet.createRow(i + 1);
        final Cell cell = row.createCell(0);

        cell.setCellValue(sheetName);
        cell.setCellStyle(hyperlinkStyle);
        cell.setHyperlink(hyperlink);

    }

    indexSheet.autoSizeColumn(0);

}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyExcelExporter.java

License:Apache License

/**
 * Creates a property row in the excel with the given property name and value.
 * /*  w ww .  j  a v a 2 s.  c om*/
 * @param sheet
 *            the sheet where the property is created.
 * @param rowNumber
 *            the number of the row where the property is created.
 * @param propertyName
 *            the name of the property.
 * @param propertyValue
 *            the value of the property.
 */
protected void createProperty(final Sheet sheet, final int rowNumber, final String propertyName,
        final String propertyValue) {
    final Row row = sheet.createRow(rowNumber);
    Cell cell = row.createCell(0);
    cell.setCellValue(propertyName);
    cell.setCellStyle(BOLD_STYLE);

    cell = row.createCell(1);
    cell.setCellValue(propertyValue);
    cell.setCellStyle(defaultStyle);
}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyExcelExporter.java

License:Apache License

/**
 * Creates a metadata row in the excel with the given group name and keyword.
 * //from   w w  w  .jav  a2 s .com
 * @param sheet
 *            the sheet where the metadata is created.
 * @param rowNum
 *            the number of the row where the metadata is created.
 * @param groupName
 *            the name of the group.
 * @param keyword
 *            the name of the keyword.
 */
protected void createMetadata(Sheet sheet, int rowNum, String groupName, String keyword) {
    final Row row = sheet.createRow(rowNum);

    Cell cell = row.createCell(0);
    cell.setCellValue(groupName);
    cell.setCellStyle(defaultStyle);

    cell = row.createCell(1);
    cell.setCellValue(keyword);
    cell.setCellStyle(defaultStyle);
}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyExcelExporter.java

License:Apache License

/**
 * Creates a cell with the given string value.
 * /*from ww  w .j  a v a2 s  .c  o m*/
 * @param row
 *            the row where the cell is created.
 * @param cellValue
 *            the string value of the cell.
 * @param cellStyle
 *            the style of the cell.
 * @param cellIndex
 *            the index of the cell in the row.
 */
protected void createCell(final Row row, final String cellValue, final CellStyle cellStyle,
        final int cellIndex) {
    final Cell cell = row.createCell(cellIndex);
    cell.setCellValue(cellValue);
    cell.setCellStyle(cellStyle);
}

From source file:com.b2international.snowowl.datastore.server.importer.AbstractTerminologyExcelExporter.java

License:Apache License

/**
 * Creates a cell with the given int value.
 * // w w  w  .  ja va 2  s. c o  m
 * @param row
 *            the row where the cell is created.
 * @param cellValue
 *            the int value of the cell.
 * @param cellStyle
 *            the style of the cell.
 * @param cellIndex
 *            the index of the cell in the row.
 */
protected void createCell(final Row row, final int cellValue, final CellStyle cellStyle, final int cellIndex) {
    final Cell cell = row.createCell(cellIndex);
    cell.setCellValue(cellValue);
    cell.setCellStyle(cellStyle);
}