Example usage for org.apache.poi.ss.usermodel Workbook createFont

List of usage examples for org.apache.poi.ss.usermodel Workbook createFont

Introduction

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

Prototype

Font createFont();

Source Link

Document

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

Usage

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ImplementedCommentsCheckReportGenerator.java

License:Apache License

/**
 * /*w w  w.j  a v  a 2  s  . c o  m*/
 * @return format of the unlocked cell
 * @throws Exception
 */
private CellStyle getUnlockedStyle(Workbook p_workbook) throws Exception {
    if (unlockedStyle == null) {
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        unlockedStyle = style;
    }

    return unlockedStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.ImplementedCommentsCheckReportGenerator.java

License:Apache License

private CellStyle getRedStyle(Workbook p_workbook) throws Exception {
    CellStyle style = p_workbook.createCellStyle();
    Font font = p_workbook.createFont();
    if (hightLightStyle == null) {
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setColor(IndexedColors.BLACK.getIndex());
        font.setUnderline(Font.U_NONE);
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        style.setWrapText(true);/*from   ww  w.  j  a v  a 2s  . c o m*/
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.ROSE.getIndex());
        hightLightStyle = style;
    }

    return hightLightStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private void addTitle(Workbook p_workbook, Sheet p_sheet) throws Exception {
    String EMEA = CompanyWrapper.getCurrentCompanyName();
    Font titleFont = p_workbook.createFont();
    titleFont.setUnderline(Font.U_NONE);
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 14);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    CellStyle titleStyle = p_workbook.createCellStyle();
    titleStyle.setWrapText(false);/*from  w  w  w  .  j a va  2s  .  c o  m*/
    titleStyle.setFont(titleFont);

    Row firRow = getRow(p_sheet, 0);
    Cell titleCell = getCell(firRow, 0);
    titleCell.setCellValue(EMEA + " " + m_bundle.getString("online_jobs_for_ip_translator"));
    titleCell.setCellStyle(titleStyle);
    p_sheet.setColumnWidth(0, 20 * 256);
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private void addTotalsPerLang(Workbook p_workbook, Sheet p_sheet, final int p_sheetCategory, IntHolder p_row)
        throws Exception {
    Font subTotalFont = p_workbook.createFont();
    subTotalFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    subTotalFont.setColor(IndexedColors.BLACK.getIndex());
    subTotalFont.setUnderline(Font.U_NONE);
    subTotalFont.setFontName("Arial");
    subTotalFont.setFontHeightInPoints((short) 10);

    CellStyle subTotalStyle = p_workbook.createCellStyle();
    subTotalStyle.setFont(subTotalFont);

    String title = m_bundle.getString("lb_total_cost_per_lang");
    int row = p_row.getValue() + 4; // skip a row
    ArrayList<String> locales = new ArrayList<String>(totalCost.keySet());
    SortUtil.sort(locales);//  ww  w . j  a  v a2s  .  c o m

    int col = m_data.getSumStartCol();
    Row theRow = getRow(p_sheet, row);

    Cell cell_Title = getCell(theRow, col - 3);
    cell_Title.setCellValue(title);
    cell_Title.setCellStyle(subTotalStyle);

    File imgFile = File.createTempFile("GSJobChart", ".png");
    JfreeCharUtil.drawPieChart2D("", totalCostDate, imgFile);
    Drawing patriarch = p_sheet.createDrawingPatriarch();
    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 15, row - 1, 22, row + 24);
    ByteArrayOutputStream img_bytes = new ByteArrayOutputStream();
    InputStream is = imgFile.toURI().toURL().openStream();
    int b;
    while ((b = is.read()) != -1) {
        img_bytes.write(b);
    }
    is.close();
    int i = p_workbook.addPicture(img_bytes.toByteArray(), SXSSFWorkbook.PICTURE_TYPE_PNG);
    patriarch.createPicture(anchor, i);
    for (String locale : locales) {
        List<Integer> indexs = totalCost.get(locale);
        StringBuffer values = new StringBuffer();
        for (Integer index : indexs) {
            if (values.length() == 0) {
                values.append("SUM(");
            } else {
                values.append("+");
            }

            values.append(totalCol).append(index);
        }
        values.append(")");

        Row perRow = getRow(p_sheet, row);

        Cell cell_Locale = getCell(perRow, col - 1);
        cell_Locale.setCellValue(locale);
        cell_Locale.setCellStyle(getContentStyle(p_workbook));
        Cell cell_Total = getCell(perRow, col);
        cell_Total.setCellFormula(values.toString());
        cell_Total.setCellStyle(getMoneyStyle(p_workbook));
        row++;
    }

    // Reset total column number for every sheet.
    totalCol = null;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getHeaderStyle(Workbook p_workbook) {
    if (headerStyle == null) {
        Font headerFont = p_workbook.createFont();
        headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        headerFont.setColor(IndexedColors.BLACK.getIndex());
        headerFont.setUnderline(Font.U_NONE);
        headerFont.setFontName("Arial");
        headerFont.setFontHeightInPoints((short) 9);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(headerFont);/*from   w  w  w.  ja  va 2s.  c o m*/
        cs.setWrapText(true);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderRight(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setBorderLeft(CellStyle.BORDER_THIN);

        headerStyle = cs;
    }

    return headerStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getContentStyle(Workbook p_workbook) throws Exception {
    if (contentStyle == null) {
        CellStyle style = p_workbook.createCellStyle();
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);
        style.setFont(font);/*from  w w  w  .j a va 2s.c  o  m*/

        contentStyle = style;
    }

    return contentStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getDateStyle(Workbook p_workbook) throws Exception {
    if (dateStyle == null) {
        DataFormat dataFormat = p_workbook.createDataFormat();

        Font dateFont = p_workbook.createFont();
        dateFont.setFontName("Arial");
        dateFont.setFontHeightInPoints((short) 10);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setWrapText(false);//  w ww  . ja  va  2s.  c om
        cs.setFont(dateFont);
        cs.setDataFormat(dataFormat.getFormat("M/d/yy"));

        dateStyle = cs;
    }
    return dateStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getRedCellStyle(Workbook p_workbook) throws Exception {
    if (redCellStyle == null) {
        Font redFont = p_workbook.createFont();
        redFont.setFontName("Arial");
        redFont.setUnderline(Font.U_NONE);
        redFont.setFontHeightInPoints((short) 10);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(redFont);//from  w  ww .j a v a2  s .  c  o  m
        cs.setWrapText(true);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.RED.getIndex());

        redCellStyle = cs;
    }
    return redCellStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getFailedDateStyle(Workbook p_workbook) throws Exception {
    if (failedDateStyle == null) {
        DataFormat dataFormat = p_workbook.createDataFormat();

        Font dateFont = p_workbook.createFont();
        dateFont.setFontName("Arial");
        dateFont.setFontHeightInPoints((short) 10);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setWrapText(false);//  w w  w  . jav  a 2  s . c  o  m
        cs.setFont(dateFont);
        cs.setDataFormat(dataFormat.getFormat("M/d/yy"));
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.RED.getIndex());
        failedDateStyle = cs;
    }
    return failedDateStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.OnlineJobsReportForIPTranslatorGenerator.java

License:Apache License

private CellStyle getWrongJobStyle(Workbook p_workbook) throws Exception {
    if (wrongJobStyle == null) {
        Font wrongJobFont = p_workbook.createFont();
        wrongJobFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        wrongJobFont.setColor(IndexedColors.GREY_50_PERCENT.getIndex());
        wrongJobFont.setUnderline(Font.U_NONE);
        wrongJobFont.setFontName("Times");
        wrongJobFont.setFontHeightInPoints((short) 11);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(wrongJobFont);//from ww  w.  j av  a  2s  .  c  o m

        wrongJobStyle = cs;
    }
    return wrongJobStyle;
}