Package org.apache.poi.ss.usermodel

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


   * @param workbook
   * @return
   */
  public static HSSFCellStyle getHeaderStyle(HSSFWorkbook workbook, ExcelTitle entity) {
    HSSFCellStyle titleStyle = workbook.createCellStyle();
    Font font = workbook.createFont();
    font.setFontHeightInPoints((short) 24);
    titleStyle.setFont(font);
    titleStyle.setFillForegroundColor(entity.getColor());
    titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    titleStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    return titleStyle;
View Full Code Here


        bodyCellStyle.setAlignment(CellStyle.ALIGN_LEFT);
        bodyCellStyle.setWrapText(false);
        bodyCellStyle.setDataFormat(helper.createDataFormat().getFormat("m/d/yyyy"));

        HSSFCellStyle hlink_style = workbook.createCellStyle();
        Font hlink_font = workbook.createFont();
        hlink_font.setUnderline(Font.U_SINGLE);
        hlink_font.setColor(IndexedColors.BLUE.getIndex());
        hlink_style.setFont(hlink_font);

        int previousRowNum = 2;
        int previousRowSize = 1;
        for (int i = 0; i < organizationModels.size(); i++) {
View Full Code Here

        }
    }

    public void buildTitle(HSSFSheet worksheet, String title, int startRowIndex, int startColIndex) {
        // Create font style for the report title
        Font fontTitle = worksheet.getWorkbook().createFont();
        fontTitle.setBoldweight(Font.BOLDWEIGHT_BOLD);
        fontTitle.setFontHeight((short) 280);

        // Create cell style for the report title
        HSSFCellStyle cellStyleTitle = worksheet.getWorkbook().createCellStyle();
        cellStyleTitle.setAlignment(CellStyle.ALIGN_CENTER);
        cellStyleTitle.setWrapText(false);
View Full Code Here

        worksheet.addMergedRegion(new CellRangeAddress(1,1,0,4));
    }

    public static void buildHeaders(HSSFSheet worksheet, int startRowIndex, int startColIndex, String[] headerNames) {
        // Create font style for the headers
        Font font = worksheet.getWorkbook().createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);

        // Create cell style for the headers
        HSSFCellStyle headerCellStyle = worksheet.getWorkbook().createCellStyle();
        headerCellStyle.setFillBackgroundColor(HSSFColor.GREY_25_PERCENT.index);
        headerCellStyle.setFillPattern(CellStyle.FINE_DOTS);
View Full Code Here

          int startingFonts = initialFonts[i];
         
          assertEquals(startingFonts, wb.getNumberOfFonts());
         
          // Get a font, and slightly change it
          Font a = wb.createFont();
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
          a.setFontHeightInPoints((short)23);
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
         
          // Get two more, unchanged
          Font b = wb.createFont();
          assertEquals(startingFonts+2, wb.getNumberOfFonts());
          Font c = wb.createFont();
          assertEquals(startingFonts+3, wb.getNumberOfFonts());
       }
    }
View Full Code Here

          int startingFonts = initialFonts[i];
         
          assertEquals(startingFonts, wb.getNumberOfFonts());
         
          // Get a font, and slightly change it
          Font a = wb.createFont();
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
          a.setFontHeightInPoints((short)23);
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
         
          // Get two more, unchanged
          Font b = wb.createFont();
          assertEquals(startingFonts+2, wb.getNumberOfFonts());
          Font c = wb.createFont();
          assertEquals(startingFonts+3, wb.getNumberOfFonts());
       }
    }
View Full Code Here

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

       Font font1 = wb.createFont();
       font1.setColor((short) 20);

       Row row = sheet.createRow(2);
       Cell cell = row.createCell(2);

       RichTextString richTextString =
View Full Code Here

        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

        short borderColor = IndexedColors.GREY_50_PERCENT.getIndex();

        CellStyle style;
        Font titleFont = wb.createFont();
        titleFont.setFontHeightInPoints((short)48);
        titleFont.setColor(IndexedColors.DARK_BLUE.getIndex());
        style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFont(titleFont);
        styles.put("title", style);

        Font monthFont = wb.createFont();
        monthFont.setFontHeightInPoints((short)12);
        monthFont.setColor(IndexedColors.WHITE.getIndex());
        monthFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFont(monthFont);
        styles.put("month", style);

        Font dayFont = wb.createFont();
        dayFont.setFontHeightInPoints((short)14);
        dayFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_TOP);
        style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
View Full Code Here

                 CellStyle style = cell.getCellStyle();
                 System.out.print("Format=" + style.getDataFormatString() + " ");
                 System.out.print("FG=" + renderColor(style.getFillForegroundColorColor()) + " ");
                 System.out.print("BG=" + renderColor(style.getFillBackgroundColorColor()) + " ");
                
                 Font font = wb.getFontAt( style.getFontIndex() );
                 System.out.print("Font=" + font.getFontName() + " ");
                 System.out.print("FontColor=");
                 if(font instanceof HSSFFont) {
                    System.out.print( renderColor( ((HSSFFont)font).getHSSFColor((HSSFWorkbook)wb)) );
                 }
                 if(font instanceof XSSFFont) {
View Full Code Here

          int startingFonts = initialFonts[i];
         
          assertEquals(startingFonts, wb.getNumberOfFonts());
         
          // Get a font, and slightly change it
          Font a = wb.createFont();
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
          a.setFontHeightInPoints((short)23);
          assertEquals(startingFonts+1, wb.getNumberOfFonts());
         
          // Get two more, unchanged
          /*Font b =*/ wb.createFont();
          assertEquals(startingFonts+2, wb.getNumberOfFonts());
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.