Example usage for org.apache.poi.xssf.usermodel XSSFCell setCellStyle

List of usage examples for org.apache.poi.xssf.usermodel XSSFCell setCellStyle

Introduction

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

Prototype

@Override
public void setCellStyle(CellStyle style) 

Source Link

Document

Set the style for the cell.

Usage

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

/**
 * Creates a merged span to make all filter sections the same size and style.
 *
 * @param fromColumn/* ww w .  j  a  va 2 s.  com*/
 * @param style
 * @param sheet
 * @param row
 */
private void createMergedCellFromColumn(int fromColumn, XSSFCellStyle style, XSSFSheet sheet, XSSFRow row) {
    // Create and style cells for the span
    for (int i = fromColumn + 1; i <= FILTER_END_COLUMN_SPAN; i++) {
        XSSFCell cell = row.createCell(i);
        cell.setCellStyle(style);

    }
    sheet.addMergedRegion(
            new CellRangeAddress(row.getRowNum(), row.getRowNum(), fromColumn, FILTER_END_COLUMN_SPAN));
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void addFilterMainHeader(XSSFSheet sheet, int rowIndex, String value) {
    XSSFRow row = sheet.createRow(rowIndex);
    XSSFCell cell = row.createCell(FILTER_HEADLINE_COLUMN);
    cell.setCellValue(value);//from   w  ww.j av  a 2  s.c om
    cell.setCellStyle(filterMainHeaderStyle);

    createMergedCellFromColumn(FILTER_HEADLINE_COLUMN, filterMainHeaderStyle, sheet, row);
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private XSSFRow buildFilterTitleCell(XSSFSheet sheet, int rowIndex, String key) {
    XSSFRow row = sheet.createRow(rowIndex);
    XSSFCell cell = row.createCell(FILTER_HEADLINE_COLUMN);
    cell.setCellStyle(filterHeaderStyle);
    cell.setCellValue(key);//from  w  ww.j  a  v  a2  s  .c o  m
    return row;
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void addRichTextValueCell(XSSFSheet sheet, XSSFRow row, XSSFRichTextString value) {
    XSSFCell cell2 = row.createCell(FILTER_VALUE_COLUMN);
    cell2.setCellStyle(filterTextStyle);
    cell2.setCellValue(value);/*  w  ww . j a  v a 2 s .  c  o  m*/
    createMergedCellFromColumn(FILTER_VALUE_COLUMN, filterTextStyle, sheet, row);
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void addValueCell(XSSFSheet sheet, XSSFRow row, String value) {
    XSSFCell cell2 = row.createCell(FILTER_VALUE_COLUMN);
    cell2.setCellValue(value);//from   www .  j a  v  a 2s. c  om
    cell2.setCellStyle(filterTextStyle);
    createMergedCellFromColumn(FILTER_VALUE_COLUMN, filterTextStyle, sheet, row);
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void createDataCell(XSSFRow row, int colIndex, String value) {
    XSSFCell cell = row.createCell(colIndex);
    cell.setCellValue(value);//from w  w w .  j a  v a  2s .c om
    cell.setCellStyle(row.getRowNum() % 2 == 0 ? stripedDarker : stripedLighter);
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void createRichTextDataCell(XSSFRow row, int colIndex, XSSFRichTextString value) {
    XSSFCell cell = row.createCell(colIndex);
    cell.setCellValue(value);//from www  .  jav  a  2s  . c o m
    cell.setCellStyle(row.getRowNum() % 2 == 0 ? stripedDarker : stripedLighter);
}

From source file:se.inera.intyg.rehabstod.service.export.xlsx.XlsxExportServiceImpl.java

License:Open Source License

private void createHeaderCell(XSSFRow row, int colIndex, String value) {
    XSSFCell cell = row.createCell(colIndex);
    cell.setCellValue(value);//from w  w  w. j  a  v a2s .c om
    cell.setCellStyle(boldStyle);
}

From source file:Servelt.ExcelWriter.java

private void setMainCell(XSSFCell cell, String name) {
    XSSFCellStyle style = workbook.createCellStyle();
    style.setFillForegroundColor(HSSFColor.ORANGE.index);
    style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    style.setAlignment(XSSFCellStyle.ALIGN_CENTER);

    XSSFFont font = workbook.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style.setFont(font);//from   w w w .  j  a  va 2 s . c o m

    cell.setCellValue(name);
    cell.setCellStyle(style);
}

From source file:Servelt.ExcelWriter.java

private void setAttrCell(XSSFCell cell, String name) {
    XSSFCellStyle style = workbook.createCellStyle();
    style.setFillForegroundColor(HSSFColor.YELLOW.index);
    style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
    style.setAlignment(XSSFCellStyle.ALIGN_CENTER);

    XSSFFont font = workbook.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style.setFont(font);/*w  w w. j ava 2 s. co  m*/

    cell.setCellValue(name);
    cell.setCellStyle(style);
}