Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Font


          "This line finishes with two trailing spaces.  ";
      
       XSSFWorkbook wb = new XSSFWorkbook();
       XSSFSheet sheet = wb.createSheet();

       Font font1 = wb.createFont();
       font1.setColor((short) 20);
       Font font2 = wb.createFont();
       font2.setColor(Font.COLOR_RED);
       Font font3 = wb.getFontAt((short)0);

       XSSFRow row = sheet.createRow(2);
       XSSFCell cell = row.createCell(2);

       XSSFRichTextString richTextString =
View Full Code Here


    private void saveAndReloadReport(Workbook wb, File outFile) throws IOException {
        // run some method on the font to verify if it is "disconnected" already
        //for(short i = 0;i < 256;i++)
        {
            Font font = wb.getFontAt((short)0);
            if(font instanceof XSSFFont) {
                XSSFFont xfont = (XSSFFont) wb.getFontAt((short)0);
                CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont();
                assertEquals(0, ctFont.sizeOfBArray());
            }
View Full Code Here

  public void getFontAt(){
     XSSFWorkbook workbook = new XSSFWorkbook();
    StylesTable styleSource = workbook.getStylesSource();
    short i = 0;
    //get default font
    Font fontAt = workbook.getFontAt(i);
    assertNotNull(fontAt);

    //get customized font
    XSSFFont customFont = new XSSFFont();
    customFont.setItalic(true);
View Full Code Here

        int cellType = cell.getCellType();

        // for formula cells we compute the cell width for the cached formula result
        if(cellType == Cell.CELL_TYPE_FORMULA) cellType = cell.getCachedFormulaResultType();

        Font font = wb.getFontAt(style.getFontIndex());

        AttributedString str;
        TextLayout layout;

        double width = -1;
View Full Code Here

        AttributedString str;
        TextLayout layout;

        Workbook wb = sheet.getWorkbook();
        DataFormatter formatter = new DataFormatter();
        Font defaultFont = wb.getFontAt((short) 0);

        str = new AttributedString(String.valueOf(defaultChar));
        copyAttributes(defaultFont, str, 0, 1);
        layout = new TextLayout(str.getIterator(), fontRenderContext);
        int defaultCharWidth = (int)layout.getAdvance();
View Full Code Here

        AttributedString str;
        TextLayout layout;

        Workbook wb = sheet.getWorkbook();
        DataFormatter formatter = new DataFormatter();
        Font defaultFont = wb.getFontAt((short) 0);

        str = new AttributedString(String.valueOf(defaultChar));
        copyAttributes(defaultFont, str, 0, 1);
        layout = new TextLayout(str.getIterator(), fontRenderContext);
        int defaultCharWidth = (int)layout.getAdvance();
View Full Code Here

                // Note: xl fill foreground = background
                setFillForegroundColor(xlCellStyle, bg);
                xlCellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
            }

            Font xlFont = xlWorkbook.createFont();
            setFontColor(xlFont, fg);
            xlFont.setFontName(fontData.getName());
            xlFont.setFontHeightInPoints((short) fontData.getHeight());
            xlCellStyle.setFont(xlFont);

            if (vertical)
                xlCellStyle.setRotation((short) 90);
View Full Code Here

    DataFormat df = wb.createDataFormat();

    // --字体设定 --//

    //普通字体
    Font normalFont = wb.createFont();
    normalFont.setFontHeightInPoints((short) 10);

    //加粗字体
    Font boldFont = wb.createFont();
    boldFont.setFontHeightInPoints((short) 10);
    boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);

    //蓝色加粗字体
    Font blueBoldFont = wb.createFont();
    blueBoldFont.setFontHeightInPoints((short) 10);
    blueBoldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    blueBoldFont.setColor(IndexedColors.BLUE.getIndex());

    // --Cell Style设定-- //

    //标题格式
    CellStyle headerStyle = wb.createCellStyle();
View Full Code Here

    createDateFormatStyle();
  }

  private void createBoldStyle() {
    boldStyle = wb.createCellStyle();
    Font font = wb.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
    boldStyle.setFont(font);   
  }
View Full Code Here

 
  public static Font createFont(Workbook workbook, short boldweigthValue, short colorValue,
      short fontHeightValue, String fontNameValue, boolean isItalic, boolean isStrikeOut,
      boolean hasTypeOffset, short typeOffsetValue, boolean hasUnderline,  byte underlineValue){
   
    Font font = workbook.createFont()
   
    font.setBoldweight(boldweigthValue);
    font.setColor(colorValue);
    font.setFontHeightInPoints(fontHeightValue);
    font.setFontName(fontNameValue);
    font.setItalic(isItalic);
    font.setStrikeout(isStrikeOut);
   
    if(hasTypeOffset){
      font.setTypeOffset(typeOffsetValue);
    }
   
    if(hasUnderline){
      font.setUnderline(underlineValue)
    }
       
    return font;   
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Font

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.