Example usage for org.apache.poi.xssf.usermodel XSSFWorkbook createFont

List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook createFont

Introduction

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

Prototype

@Override
public XSSFFont createFont() 

Source Link

Document

Create a new Font and add it to the workbook's font table

Usage

From source file:org.jboss.windup.reporting.spreadsheet.ScorecardReporter.java

License:Open Source License

private static void appendMentoringTitleRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum) {
    XSSFCellStyle titleCell = wb.createCellStyle();
    Color titleCellGrey = new Color(0xECECEC);
    XSSFColor color = new XSSFColor(titleCellGrey);
    titleCell.setFillForegroundColor(color);
    titleCell.setBorderBottom(CellStyle.BORDER_MEDIUM);
    titleCell.setBorderTop(CellStyle.BORDER_MEDIUM);
    titleCell.setFillPattern(CellStyle.SOLID_FOREGROUND);

    Font titleFormat = wb.createFont();
    titleFormat.setBoldweight(Font.BOLDWEIGHT_BOLD);
    titleFormat.setColor((short) 0x0);
    titleCell.setFont(titleFormat);//from   w w  w  .j  av a2  s. c o  m

    XSSFRow row = sheet.createRow(rowNum);
    XSSFCell t1 = row.createCell(0);
    t1.setCellValue("Migration Service Estimate");
    t1.setCellStyle(titleCell);

    XSSFCell t2 = row.createCell(1);
    t2.setCellStyle(titleCell);

    XSSFCell t3 = row.createCell(2);
    t3.setCellStyle(titleCell);

    XSSFCell t4 = row.createCell(3);
    t4.setCellStyle(titleCell);
}

From source file:org.jboss.windup.reporting.spreadsheet.ScorecardReporter.java

License:Open Source License

private static void appendMentoringTotalRow(XSSFWorkbook wb, XSSFSheet sheet, int rowNum, int start, int end) {
    Font boldFont = wb.createFont();
    boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    boldFont.setColor((short) 0x0);

    XSSFCellStyle commentCell = wb.createCellStyle();
    commentCell.setBorderTop(CellStyle.BORDER_THIN);

    XSSFCellStyle totalCell = wb.createCellStyle();
    totalCell.setBorderTop(CellStyle.BORDER_THIN);
    totalCell.setFont(boldFont);//from w  ww .  j  a  v  a  2  s.  c o m

    XSSFCellStyle totalCellRight = wb.createCellStyle();
    totalCellRight.setBorderTop(CellStyle.BORDER_THIN);
    totalCellRight.setAlignment(HorizontalAlignment.RIGHT);
    totalCellRight.setFont(boldFont);

    XSSFRow row = sheet.createRow(rowNum);
    XSSFCell t1 = row.createCell(0);
    t1.setCellValue("Total:");
    t1.setCellStyle(totalCellRight);

    XSSFCell t2 = row.createCell(1);
    t2.setCellFormula("SUM(B" + start + ":B" + end + ")");
    t2.setCellStyle(totalCell);

    XSSFCell t3 = row.createCell(2);
    t3.setCellStyle(totalCell);

    XSSFCell t4 = row.createCell(3);
    t4.setCellStyle(commentCell);
}

From source file:org.nekorp.workflow.desktop.servicio.reporte.cliente.AbstractSeccionXLS.java

License:Apache License

public void addHeaderStyle(XSSFCellStyle cellStyle, XSSFWorkbook wb) {
    cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    cellStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(85, 142, 213)));
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    XSSFFont font = wb.createFont();
    font.setColor(IndexedColors.WHITE.getIndex());
    font.setBold(true);//w  w  w. j av a  2  s  . c  o m
    cellStyle.setFont(font);
}

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

License:Open Source License

private XSSFWorkbook createWorkbook() {
    XSSFWorkbook workbook = new XSSFWorkbook();

    XSSFFont fontTitle = workbook.createFont();
    fontTitle.setBold(true);/*from   w  w w  . j  av a 2s  . c o  m*/
    titleStyle = workbook.createCellStyle();
    titleStyle.setFont(fontTitle);
    titleStyle.setAlignment(CellStyle.ALIGN_CENTER);

    XSSFFont font = workbook.createFont();
    font.setBold(true);
    headerStyle = workbook.createCellStyle();
    headerStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(200, 200, 200)));
    headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
    headerStyle.setFont(font);
    headerStyle.setBorderBottom(CellStyle.BORDER_THIN);
    headerStyle.setBorderTop(CellStyle.BORDER_THIN);
    headerStyle.setBorderLeft(CellStyle.BORDER_THIN);
    headerStyle.setBorderRight(CellStyle.BORDER_THIN);
    headerStyle.setAlignment(CellStyle.ALIGN_CENTER);

    tableStyle = workbook.createCellStyle();
    tableStyle.setBorderBottom(CellStyle.BORDER_THIN);
    tableStyle.setBorderTop(CellStyle.BORDER_THIN);
    tableStyle.setBorderLeft(CellStyle.BORDER_THIN);
    tableStyle.setBorderRight(CellStyle.BORDER_THIN);

    return workbook;
}

From source file:org.openelis.bean.DataViewReportBean.java

License:Open Source License

/**
 * Creates the header row in "sheet" from "headers"; sets a style on the
 * header row to distinguish it from the other rows; updates "maxChars" to
 * account for the header labels because the header row is added after the
 * other rows have been added/*from   w w  w .  ja  v a 2s . com*/
 * 
 * @param sheet
 *        the sheet that contains all rows in "wb"
 * @param wb
 *        the workbook that gets converted to an Excel file
 * @param headers
 *        the list of labels to be shown in the header row
 * @param maxChars
 *        the list containing the maximum number of characters in each
 *        column of "sheet"
 */
private void setHeaderCells(Sheet sheet, XSSFWorkbook wb, ArrayList<String> headers,
        ArrayList<Integer> maxChars) {
    Cell cell;
    Row row;
    Font font;
    CellStyle style;

    /*
     * create the style to distinguish the header row from the other rows in
     * the output
     */
    font = wb.createFont();
    font.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_LEFT);
    style.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM);
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setFillForegroundColor(IndexedColors.GREY_80_PERCENT.getIndex());
    style.setFont(font);

    row = sheet.createRow(0);
    for (int i = 0; i < headers.size(); i++) {
        cell = row.createCell(i);
        cell.setCellStyle(style);
        setCellValue(cell, headers.get(i), null);
        setMaxChars(cell.getColumnIndex(), headers.get(i), maxChars, null);
    }
}

From source file:org.rapidpm.data.table.export.Table2XLSX.java

License:Apache License

private CellStyle createHyperLinkStyle(final XSSFWorkbook workbook) {
    final CellStyle hlink_style = workbook.createCellStyle();
    final Font hlink_font = workbook.createFont();
    hlink_font.setUnderline(Font.U_SINGLE);
    hlink_font.setColor(IndexedColors.BLUE.getIndex());
    hlink_style.setFont(hlink_font);/*from  ww w. j  ava 2  s  .  c om*/
    return hlink_style;
}

From source file:org.talend.mdm.webapp.browserecords.server.servlet.DownloadData.java

License:Open Source License

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    XSSFWorkbook workbook = new XSSFWorkbook();
    cs = workbook.createCellStyle();//from w w  w  .  j av a2 s . c  o  m
    XSSFFont f = workbook.createFont();
    f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    cs.setFont(f);
    XSSFSheet sheet = workbook.createSheet(SHEET_LABEL);
    sheet.setDefaultColumnWidth((short) 20);
    XSSFRow row = sheet.createRow((short) 0);
    try {
        setParameter(request);
        response.reset();
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); //$NON-NLS-1$
        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        fillHeader(row);
        fillSheet(sheet);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
    OutputStream out = response.getOutputStream();
    workbook.write(out);
    out.close();
}

From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportAuthorHelperImpl.java

License:Open Source License

/**
 * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook)
 *//* w  w w .j  a v a2  s  . co  m*/
@Override
protected void prepare(XSSFWorkbook book) {
    flagCellStyle = book.createCellStyle();
    flagCellStyle.setAlignment(HorizontalAlignment.CENTER);
    flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

    idCellStyle = book.createCellStyle();

    commonCellStyle = book.createCellStyle();
    commonCellStyle.setAlignment(HorizontalAlignment.LEFT);
    commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);

    noteCellStyle = book.createCellStyle();
    XSSFFont noteFont = book.createFont();
    noteFont.setFontHeightInPoints((short) 9);
    noteCellStyle.setFont(noteFont);
    noteCellStyle.setAlignment(HorizontalAlignment.LEFT);
    noteCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
    noteCellStyle.setWrapText(true);
}

From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportBookHelperImpl.java

License:Open Source License

/**
 * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook)
 *//* w w w  .  java2  s.c  o  m*/
@Override
protected void prepare(XSSFWorkbook book) {
    flagCellStyle = book.createCellStyle();
    flagCellStyle.setAlignment(HorizontalAlignment.CENTER);
    flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

    idCellStyle = book.createCellStyle();
    XSSFFont idFont = book.createFont();
    idFont.setFontHeightInPoints((short) 9);
    idCellStyle.setFont(idFont);

    commonCellStyle = book.createCellStyle();
    commonCellStyle.setAlignment(HorizontalAlignment.LEFT);
    commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);

    dateCellStyle = book.createCellStyle();
    dateCellStyle.setAlignment(HorizontalAlignment.LEFT);
    dateCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
}

From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportBookshelfHelperImpl.java

License:Open Source License

/**
 * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook)
 */// w w  w  .j a  va 2 s .  com
@Override
protected void prepare(XSSFWorkbook book) {
    flagCellStyle = book.createCellStyle();
    flagCellStyle.setAlignment(HorizontalAlignment.CENTER);
    flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);

    idCellStyle = book.createCellStyle();

    noteCellStyle = book.createCellStyle();
    XSSFFont noteFont = book.createFont();
    noteFont.setFontHeightInPoints((short) 9);
    noteCellStyle.setFont(noteFont);
    noteCellStyle.setAlignment(HorizontalAlignment.LEFT);
    noteCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
    noteCellStyle.setWrapText(true);
}