Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFFont


    mySheet.setDefaultColumnWidth(15);
    mySheet.setColumnWidth(0, 7000);
   
    myWorkBook.setSheetName(0, "Monatsreport");
   
    HSSFFont myFont;
   
    String[] header = "Mitarbeiter ID: Name",
              "Buchungsdatum",
              "Gesamtgehalt",
              "Steuerabzug",
              "Soz. Vers. AN",
              "Gehalt Netto",
              "Soz. Vers. AG",
              "Gesamtkosten"};

    CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 7);
    mySheet.addMergedRegion( cra );
   
    myRow = mySheet.createRow(0);
   
    myCell = myRow.createCell(0);
    myCell.setCellValue("�bersicht aller Abrechnungen im Monat "+df.format(startDat));
   
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 350);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setFillForegroundColor(HSSFColor.GREY_80_PERCENT.index);
    myCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    myCellStyle.setFont(myFont);
    myCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
   
    myCell.setCellStyle(myCellStyle);
   
    for(int i = 1; i < 7; i++){
      myCell = myRow.createCell(i);
      myCellStyle = myWorkBook.createCellStyle();
      myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
      myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
      myCell.setCellStyle(myCellStyle);
    }
    myCell = myRow.createCell(7);
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
    myCell.setCellStyle(myCellStyle);
   
   
    myRow = mySheet.createRow(mySheet.getLastRowNum()+1);
   
    myFont = myWorkBook.createFont();
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
    myCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    myCellStyle.setFont(myFont);
   
    for(int i = 0; i < header.length; i++){
        myCell = myRow.createCell(i);
        myCell.setCellValue(header[i]);
        myCell.setCellStyle(myCellStyle);
    }
   
    HSSFCellStyle dateCellStyle = myWorkBook.createCellStyle();
    dateCellStyle.setDataFormat(HSSFDataFormat
        .getBuiltinFormat("m/d/yy"));
    dateCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    dateCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
   
    HSSFCellStyle euroCellStyle = myWorkBook.createCellStyle();
    euroCellStyle.setDataFormat(myWorkBook.createDataFormat().getFormat("#,##0.00 �"));
    euroCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    euroCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
   
    HSSFCellStyle euroRightCellStyle = myWorkBook.createCellStyle();
    euroRightCellStyle.setDataFormat(myWorkBook.createDataFormat().getFormat("#,##0.00 �"));
    euroRightCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    euroRightCellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
   
    while(rs.next()){
      myRow = mySheet.createRow(mySheet.getLastRowNum()+1);
      if(rs.getInt("PersID") != persID){
        if(!firstEntry){
          createSumRows();
        }
        myCell = myRow.createCell(0);
        myCell.setCellValue(rs.getString("PersID")+": "+rs.getString("Nachname")+", "+rs.getString("Vorname"));
        myCellStyle = myWorkBook.createCellStyle();
        myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        myCell.setCellStyle(myCellStyle);
       
        myCell = myRow.createCell(1);
        myCell.setCellValue(rs.getDate("BuchungsDat"));
        myCell.setCellStyle(dateCellStyle);
       
        myCell = myRow.createCell(2);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
                  rs.getDouble("gehaltausgezahlt.sonstBezug")-
                  rs.getDouble("gehaltausgezahlt.sonstAbzug"));
        myCell.setCellStyle(euroCellStyle);
        gesGesamtgehalt += myCell.getNumericCellValue();
        mitarbGesamtgehalt += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(3);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.LSt")+
                  rs.getDouble("gehaltausgezahlt.KiSt")+
                  rs.getDouble("gehaltausgezahlt.Soli"));
        myCell.setCellStyle(euroCellStyle);
        gesSteuerabzug += myCell.getNumericCellValue();
        mitarbSteuerabzug += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(4);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAN")+
                  rs.getDouble("gehaltausgezahlt.KVAN")+
                  rs.getDouble("gehaltausgezahlt.ALVAN")+
                  rs.getDouble("gehaltausgezahlt.PVAN"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAN += myCell.getNumericCellValue();
        mitarbSozVersAN += myCell.getNumericCellValue();

        myCell = myRow.createCell(5);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehNetto"));
        myCell.setCellStyle(euroCellStyle);
        gesGehaltNetto += myCell.getNumericCellValue();
        mitarbGehaltNetto += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(6);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAG")+
                    rs.getDouble("gehaltausgezahlt.KVAG")+
                    rs.getDouble("gehaltausgezahlt.ALVAG")+
                    rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAG += myCell.getNumericCellValue();
        mitarbSozVersAG += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(7);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
            rs.getDouble("gehaltausgezahlt.sonstBezug")-
            rs.getDouble("gehaltausgezahlt.sonstAbzug")+
            rs.getDouble("gehaltausgezahlt.RVAG")+
            rs.getDouble("gehaltausgezahlt.KVAG")+
            rs.getDouble("gehaltausgezahlt.ALVAG")+
            rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroRightCellStyle);
        gesGesamtkosten += myCell.getNumericCellValue();
        mitarbGesamtkosten += myCell.getNumericCellValue();
       
        firstEntry = false;
        persID = rs.getInt("PersID");
      }else{
        myCell = myRow.createCell(0);
        myCellStyle = myWorkBook.createCellStyle();
        myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        myCell.setCellStyle(myCellStyle);
       
        myCell = myRow.createCell(1);
        myCell.setCellValue(rs.getDate("BuchungsDat"));
        myCell.setCellStyle(dateCellStyle);

        myCell = myRow.createCell(2);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
                  rs.getDouble("gehaltausgezahlt.sonstBezug")-
                  rs.getDouble("gehaltausgezahlt.sonstAbzug"));
        myCell.setCellStyle(euroCellStyle);
        gesGesamtgehalt += myCell.getNumericCellValue();
        mitarbGesamtgehalt += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(3);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.LSt")+
                  rs.getDouble("gehaltausgezahlt.KiSt")+
                  rs.getDouble("gehaltausgezahlt.Soli"));
        myCell.setCellStyle(euroCellStyle);
        gesSteuerabzug += myCell.getNumericCellValue();
        mitarbSteuerabzug += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(4);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAN")+
                  rs.getDouble("gehaltausgezahlt.KVAN")+
                  rs.getDouble("gehaltausgezahlt.ALVAN")+
                  rs.getDouble("gehaltausgezahlt.PVAN"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAN += myCell.getNumericCellValue();
        mitarbSozVersAN += myCell.getNumericCellValue();

        myCell = myRow.createCell(5);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehNetto"));
        myCell.setCellStyle(euroCellStyle);
        gesGehaltNetto += myCell.getNumericCellValue();
        mitarbGehaltNetto += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(6);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAG")+
                    rs.getDouble("gehaltausgezahlt.KVAG")+
                    rs.getDouble("gehaltausgezahlt.ALVAG")+
                    rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAG += myCell.getNumericCellValue();
        mitarbSozVersAG += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(7);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
            rs.getDouble("gehaltausgezahlt.sonstBezug")-
            rs.getDouble("gehaltausgezahlt.sonstAbzug")+
            rs.getDouble("gehaltausgezahlt.RVAG")+
            rs.getDouble("gehaltausgezahlt.KVAG")+
            rs.getDouble("gehaltausgezahlt.ALVAG")+
            rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroRightCellStyle);
        gesGesamtkosten += myCell.getNumericCellValue();
        mitarbGesamtkosten += myCell.getNumericCellValue();
      }
    }
    createSumRows();
   
    cra = new CellRangeAddress(mySheet.getLastRowNum(), mySheet.getLastRowNum(), 0, 7);
    mySheet.addMergedRegion( cra );
     
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 240);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   
    myCell = myRow.createCell(0);
    myCell.setCellValue("Gesamtsumme");
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setFillForegroundColor(HSSFColor.TEAL.index);
View Full Code Here


        processCellStyleBorder( workbook, cellTarget, "bottom",
                cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
        processCellStyleBorder( workbook, cellTarget, "left",
                cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor() );

        HSSFFont font = cellStyle.getFont( workbook );
        processCellStyleFont( workbook, blockTarget, font );

    }
View Full Code Here

        buildStyle_border( workbook, style, "bottom",
                cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() );
        buildStyle_border( workbook, style, "left", cellStyle.getBorderLeft(),
                cellStyle.getLeftBorderColor() );

        HSSFFont font = cellStyle.getFont( workbook );
        buildStyle_font( workbook, style, font );

        return style.toString();
    }
View Full Code Here

            ParserUtils pu = new ParserUtils();
            //Set rowCount to size of rowList
            rowCount = rowList.size();
           
           
            HSSFFont boldFont = wb.createFont();
            boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            HSSFCellStyle boldStyle = wb.createCellStyle();
            boldStyle.setFont(boldFont);
            boldStyle.setWrapText(true);
           
            //Loop through excel 'Rows'
View Full Code Here

    /**
     * create a font in the underlying HSSF model and return the reference
     */
    HSSFFont createFont() {
        HSSFFont font = _workbook.createFont();
        return font;
    }
View Full Code Here

            HSSFColor color = null;

            HSSFCellStyle style = pstyle.getStyle();
            //style.setFillForegroundColor(
            Workbook workbook = getWorkbook();
            HSSFFont font = workbook.createFont();
            style.setFont(font);
            font.setFontHeightInPoints((short)getUnit());
            //font.setFontName(getFont());
            font.setItalic(getItalic());
            if (getBold()) {
                font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            } else {
                font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
            }
            font.setUnderline((byte)getUnderline());
            font.setStrikeout(getStrikeThrough());

            color = (HSSFColor)colorhash.get(
                    pstyle.getForegroundColor().toString());
            //System.out.println(pstyle.getForegroundColor().toString());
            if (color == null)
                color = new HSSFColor.BLACK();
            font.setColor(color.getIndex());
            hssfFont = font;
        }
    }
View Full Code Here

            }
        }
    }

    private boolean isBlank(HSSFCellStyle style) {
        HSSFFont font = null;
        if (style.getFontIndex() > 0) {
            font = (_workbook.getWorkbook().getFontAt(style.getFontIndex()));
        }
        if (style.getBorderBottom() == 0 && style.getBorderTop() == 0
            && style.getBorderRight() == 0 && style.getBorderLeft() == 0
            && style.getFillBackgroundColor() == HSSFColor.WHITE.index
            && style.getFillPattern() == 0 && (style.getFontIndex() == 0
                || ((font.getFontName().equals("Arial")
                    || font.getFontName().equals("Helvetica"))
                    && font.getFontHeightInPoints() > 8
                    && font.getFontHeightInPoints() < 12))) {
            return true;
        }
        return false;
    }
View Full Code Here

    @SuppressWarnings("deprecation")
    private HSSFWorkbook createWorkbook() {
        HSSFWorkbook wb = new HSSFWorkbook();

        HSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        HSSFSheet worksheet = wb.createSheet("Customers");
        worksheet.setColumnWidth(0, (20 * 256));
        worksheet.setColumnWidth(1, (30 * 256));
        worksheet.setColumnWidth(4, (20 * 256));

        HSSFRow row = worksheet.createRow(0);

        HSSFRichTextString value = new HSSFRichTextString("Customers");
        value.applyFont(font);
        row.createCell(0).setCellValue(value);

        row = worksheet.createRow(1);
        row.createCell(0).setCellValue(new HSSFRichTextString("Customer Account Details"));

        worksheet.createRow(2);

        row = worksheet.createRow(3);

        HSSFCellStyle style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        value = new HSSFRichTextString("Name");
        value.applyFont(font);
        HSSFCell cell = row.createCell(0);
        cell.setCellValue(value);
View Full Code Here

   * @return
   */
  public HSSFCellStyle getCellStyle(boolean isBold,short horAlign,short verAlign,short colour,short fontHeight) {
    HSSFCellStyle cellStyle=workBook.createCellStyle();
    if(isBold) {
      HSSFFont boldfont=workBook.createFont();
      boldfont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
      if(colour!=-1) {
        boldfont.setColor(colour);
      }
      if(fontHeight!=-1) {
        boldfont.setFontHeightInPoints(fontHeight);
      }
      cellStyle.setFont(boldfont);
    }
    if(horAlign!=-1) {
      cellStyle.setAlignment(horAlign);
View Full Code Here

    {
        HSSFCellStyle headerStyle = getNewCellStyle();

        headerStyle.setFillPattern(CellStyle.FINE_DOTS);
        headerStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
        HSSFFont bold = wb.createFont();
        bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
        bold.setColor(HSSFColor.WHITE.index);
        headerStyle.setFont(bold);

        return headerStyle;
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFFont

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.