Example usage for org.apache.poi.hssf.usermodel HSSFFont getItalic

List of usage examples for org.apache.poi.hssf.usermodel HSSFFont getItalic

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFFont getItalic.

Prototype


public boolean getItalic() 

Source Link

Document

get whether to use italics or not

Usage

From source file:org.bbreak.excella.reports.ReportsTestUtil.java

License:Open Source License

/**
 * HSSF????/*from ww w.  j  a v  a2  s . c o m*/
 * 
 * @param workbook 
 * @param font 
 * @return ??
 */
private static String getHSSFFontString(HSSFWorkbook workbook, HSSFFont font) {
    StringBuffer sb = new StringBuffer();
    sb.append("[FONT]");
    sb.append("fontheight=").append(Integer.toHexString(font.getFontHeight())).append(",");
    sb.append("italic=").append(font.getItalic()).append(",");
    sb.append("strikout=").append(font.getStrikeout()).append(",");
    sb.append("colorpalette=").append(getHSSFColorString((HSSFWorkbook) workbook, font.getColor())).append(",");
    sb.append("bold=").append(font.getBold()).append(",");
    sb.append("supersubscript=").append(Integer.toHexString(font.getTypeOffset())).append(",");
    sb.append("underline=").append(Integer.toHexString(font.getUnderline())).append(",");
    sb.append("charset=").append(Integer.toHexString(font.getCharSet())).append(",");
    sb.append("fontname=").append(font.getFontName());
    sb.append("[/FONT]");
    return sb.toString();
}

From source file:org.orbeon.oxf.util.XLSUtils.java

License:Open Source License

public static void copyFont(HSSFFont destination, HSSFFont source) {
    destination.setBoldweight(source.getBoldweight());
    destination.setColor(source.getColor());
    destination.setFontHeight(source.getFontHeight());
    destination.setFontHeightInPoints(source.getFontHeightInPoints());
    destination.setFontName(source.getFontName());
    destination.setItalic(source.getItalic());
    destination.setStrikeout(source.getStrikeout());
    destination.setTypeOffset(source.getTypeOffset());
    destination.setUnderline(source.getUnderline());
}

From source file:org.sysmodb.xml.HSSFXMLStyleHelper.java

License:BSD License

public boolean areFontsEmpty(CellStyle style) {
    HSSFCellStyle newStyle = (HSSFCellStyle) style;
    HSSFFont font = newStyle.getFont(workbook);
    if (font.getBold())
        return false;
    if (font.getItalic())
        return false;
    if (font.getUnderline() != HSSFFont.U_NONE)
        return false;
    // Ignore same-ish defaults
    if (font.getFontHeightInPoints() != 10 && font.getFontHeightInPoints() != 11)
        return false;
    // Arial is default for Excel, Calibri is default for OO
    if (!font.getFontName().equals("Arial") && !font.getFontName().equals("Calibri"))
        return false;
    if ((font.getColor() != HSSFFont.COLOR_NORMAL) && (getRGBString(font.getColor()) != null)
            && !getRGBString(font.getColor()).equals("#000"))
        return false;

    return true;//  w ww. j a v  a  2 s  .co m
}

From source file:org.sysmodb.xml.HSSFXMLStyleHelper.java

License:BSD License

@Override
public void writeFontProperties(XMLStreamWriter xmlWriter, CellStyle style) throws XMLStreamException {
    HSSFCellStyle newStyle = (HSSFCellStyle) style;
    HSSFFont font = newStyle.getFont(workbook);
    if (font.getBold()) {
        xmlWriter.writeStartElement("font-weight");
        xmlWriter.writeCharacters("bold");
        xmlWriter.writeEndElement();//from   w w w.  j a v  a  2  s .c  om
    }
    if (font.getItalic()) {
        xmlWriter.writeStartElement("font-style");
        xmlWriter.writeCharacters("italics");
        xmlWriter.writeEndElement();
    }
    if (font.getUnderline() != HSSFFont.U_NONE) {
        xmlWriter.writeStartElement("text-decoration");
        xmlWriter.writeCharacters("underline");
        xmlWriter.writeEndElement();
    }
    // Ignore same-ish defaults
    if (font.getFontHeightInPoints() != 10 && font.getFontHeightInPoints() != 11) {
        xmlWriter.writeStartElement("font-size");
        xmlWriter.writeCharacters(String.valueOf(font.getFontHeightInPoints() + "pt"));
        xmlWriter.writeEndElement();
    }
    // Arial is default for Excel, Calibri is default for OO
    if (!font.getFontName().equals("Arial") && !font.getFontName().equals("Calibri")) {
        xmlWriter.writeStartElement("font-family");
        xmlWriter.writeCharacters(font.getFontName());
        xmlWriter.writeEndElement();
    }
    if ((font.getColor() != HSSFFont.COLOR_NORMAL) && (getRGBString(font.getColor()) != null)
            && !getRGBString(font.getColor()).equals("#000")) {
        xmlWriter.writeStartElement("color");
        xmlWriter.writeCharacters(getRGBString(font.getColor()));
        xmlWriter.writeEndElement();
    }

}

From source file:poi.hssf.view.SVTableCellEditor.java

License:Apache License

/**
 *  Gets the tableCellEditorComponent attribute of the SVTableCellEditor object
 *
 * @return             The tableCellEditorComponent value
 *//*from  w ww .  j  ava 2 s .  c o m*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
        int column) {
    System.out.println("GetTableCellEditorComponent");
    HSSFCell cell = (HSSFCell) value;
    if (cell != null) {
        HSSFCellStyle style = cell.getCellStyle();
        HSSFFont f = wb.getFontAt(style.getFontIndex());
        boolean isbold = f.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
        boolean isitalics = f.getItalic();

        int fontstyle = Font.PLAIN;

        if (isbold)
            fontstyle = Font.BOLD;
        if (isitalics)
            fontstyle = fontstyle | Font.ITALIC;

        int fontheight = f.getFontHeightInPoints();
        if (fontheight == 9)
            fontheight = 10; //fix for stupid ol Windows

        Font font = new Font(f.getFontName(), fontstyle, fontheight);
        editor.setFont(font);

        if (style.getFillPattern() == HSSFCellStyle.SOLID_FOREGROUND) {
            editor.setBackground(getAWTColor(style.getFillForegroundColor(), white));
        } else
            editor.setBackground(white);

        editor.setForeground(getAWTColor(f.getColor(), black));

        //Set the value that is rendered for the cell
        switch (cell.getCellType()) {
        case HSSFCell.CELL_TYPE_BLANK:
            editor.setText("");
            break;
        case HSSFCell.CELL_TYPE_BOOLEAN:
            if (cell.getBooleanCellValue()) {
                editor.setText("true");
            } else {
                editor.setText("false");
            }
            break;
        case HSSFCell.CELL_TYPE_NUMERIC:
            editor.setText(Double.toString(cell.getNumericCellValue()));
            break;
        case HSSFCell.CELL_TYPE_STRING:
            editor.setText(cell.getRichStringCellValue().getString());
            break;
        case HSSFCell.CELL_TYPE_FORMULA:
        default:
            editor.setText("?");
        }
        switch (style.getAlignment()) {
        case HSSFCellStyle.ALIGN_LEFT:
        case HSSFCellStyle.ALIGN_JUSTIFY:
        case HSSFCellStyle.ALIGN_FILL:
            editor.setHorizontalAlignment(SwingConstants.LEFT);
            break;
        case HSSFCellStyle.ALIGN_CENTER:
        case HSSFCellStyle.ALIGN_CENTER_SELECTION:
            editor.setHorizontalAlignment(SwingConstants.CENTER);
            break;
        case HSSFCellStyle.ALIGN_GENERAL:
        case HSSFCellStyle.ALIGN_RIGHT:
            editor.setHorizontalAlignment(SwingConstants.RIGHT);
            break;
        default:
            editor.setHorizontalAlignment(SwingConstants.LEFT);
            break;
        }

    }
    return editor;
}

From source file:poi.hssf.view.SVTableUtils.java

License:Apache License

/**
 *  Creates a new font for a specific cell style
 *//*from   w w  w .j  a  v a  2 s  . c  o m*/
public static Font makeFont(HSSFFont font) {
    boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL;
    boolean isitalics = font.getItalic();
    int fontstyle = Font.PLAIN;
    if (isbold) {
        fontstyle = Font.BOLD;
    }
    if (isitalics) {
        fontstyle = fontstyle | Font.ITALIC;
    }

    int fontheight = font.getFontHeightInPoints();
    if (fontheight == 9) {
        //fix for stupid ol Windows
        fontheight = 10;
    }

    return new Font(font.getFontName(), fontstyle, fontheight);
}

From source file:uk.ac.manchester.cs.owl.semspreadsheets.model.hssf.impl.CellHSSFImpl.java

License:BSD License

public boolean isItalic() {
    HSSFFont hssfFont = theCell.getCellStyle().getFont(getWorkbook());
    return hssfFont.getItalic();
}

From source file:uk.ac.manchester.cs.owl.semspreadsheets.model.hssf.impl.CellHSSFImpl.java

License:BSD License

private Font getFont(HSSFFont hssfFont) {
    Font font = fontCache.get(hssfFont);
    if (font == null) {
        String name = hssfFont.getFontName();
        int size = hssfFont.getFontHeightInPoints();
        int style = Font.PLAIN;
        if (hssfFont.getBoldweight() == HSSFFont.BOLDWEIGHT_BOLD) {
            style = Font.BOLD;/*from   w  w w . jav  a2  s. c  om*/
            if (hssfFont.getItalic()) {
                style = style | Font.ITALIC;
            }
        } else if (hssfFont.getItalic()) {
            style = Font.ITALIC;
        }
        font = new Font(name, style, size);
        fontCache.put(hssfFont, font);
    }
    return font;

}