Package org.apache.poi.hssf.usermodel

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


    {
      sheet.setColumnWidth(index.shortValue(), (short) 3000);
    }

    // --------- En-tête -----------
    HSSFFont font = wb.createFont();
    font.setFontHeightInPoints((short) 18);
    font.setFontName("Arial");

    HSSFCellStyle style = wb.createCellStyle();
    style.setFont(font);

    HSSFRow row = sheet.createRow((short) 0);
    final HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue(new HSSFRichTextString(evenement.getSaison().getNom()
        + " - " + evenement.getNom() + " - Liste des inscriptions"));
    cell.setCellStyle(style);

    // --------- Séparateur -----------
    sheet.createRow((short) 1);

    // --------- En-tête de colonne -------
    font = wb.createFont();
    font.setFontHeightInPoints((short) 10);
    font.setFontName("Arial");
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    style = wb.createCellStyle();
    style.setFont(font);

    row = sheet.createRow((short) 2);
View Full Code Here


    }

    sheet.setColumnWidth((short) indexDerniereCol, (short) 3000);

    // --------- En-tête -----------
    HSSFFont font = wb.createFont();
    font.setFontHeightInPoints((short) 18);
    font.setFontName("Arial");

    HSSFCellStyle style = wb.createCellStyle();
    style.setFont(font);

    HSSFRow row = sheet.createRow((short) 0);
    final HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue(new HSSFRichTextString(evenement.getNom()
        + " - Liste des articles"));
    cell.setCellStyle(style);

    // --------- Séparateur -----------
    sheet.createRow((short) 1);

    // --------- En-tête de colonne -------
    font = wb.createFont();
    font.setFontHeightInPoints((short) 10);
    font.setFontName("Arial");
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    style = wb.createCellStyle();
    style.setFont(font);

    row = sheet.createRow((short) 2);
View Full Code Here

    {
      sheet.setColumnWidth(index.shortValue(), (short) 3000);
    }

    // --------- En-tête -----------
    HSSFFont font = wb.createFont();
    font.setFontHeightInPoints((short) 18);
    font.setFontName("Arial");

    HSSFCellStyle style = wb.createCellStyle();
    style.setFont(font);

    HSSFRow row = sheet.createRow((short) 0);
    final HSSFCell cell = row.createCell((short) 0);
    cell.setCellValue(new HSSFRichTextString(evenement.getSaison().getNom()
        + " - " + evenement.getNom() + " - Liste des inscriptions"));
    cell.setCellStyle(style);

    // --------- Séparateur -----------
    sheet.createRow((short) 1);

    // --------- En-tête de colonne -------
    font = wb.createFont();
    font.setFontHeightInPoints((short) 10);
    font.setFontName("Arial");
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    style = wb.createCellStyle();
    style.setFont(font);

    row = sheet.createRow((short) 2);
View Full Code Here

        emptyCellStyle.setRightBorderColor(backColorIndex);
        emptyCellStyle.setFillForegroundColor(HSSFColor.WHITE.index);
        emptyCellStyle.setFillBackgroundColor(HSSFColor.WHITE.index);
        emptyCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

        HSSFFont defaultFont = workbook.createFont();
        defaultFont.setFontName("Serif"); //$NON-NLS-1$
        short size = 10;
        defaultFont.setFontHeightInPoints(size);
        emptyCellStyle.setFont(defaultFont);
    }
View Full Code Here

        }
        return hssfStyle;
    }

    private HSSFFont getHssfFont(IStyle style, boolean useLinkStyle) {
        HSSFFont cellFont = null;

        short forecolor;
        if (useLinkStyle) {
            forecolor = HSSFColor.BLUE.index;
        } else {
            Color color = PropertyUtil.getColor(style.getProperty(StyleConstants.STYLE_COLOR));
            forecolor = color == null ? HSSFColor.BLACK.index
                    : getHssfColor(color).getIndex();
        }

        String fontName = style.getFontFamily() == null ? "Serif" //$NON-NLS-1$
                : style.getFontFamily();
        short fontSize = (short) (PropertyUtil.getDimensionValue(style.getProperty(StyleConstants.STYLE_FONT_SIZE)) / 1000d);
        byte underline = useLinkStyle ? (HSSFFont.U_SINGLE)
                : ("underline".equalsIgnoreCase(style.getTextUnderline()) ? HSSFFont.U_SINGLE //$NON-NLS-1$
                : HSSFFont.U_NONE);
        boolean strikeout = "line-through".equalsIgnoreCase(style.getTextLineThrough()); //$NON-NLS-1$
        short boldweight = PropertyUtil.isBoldFont(style.getProperty(StyleConstants.STYLE_FONT_WEIGHT)) ? HSSFFont.BOLDWEIGHT_BOLD
                : HSSFFont.BOLDWEIGHT_NORMAL;
        boolean italic = (CSSConstants.CSS_OBLIQUE_VALUE.equals(style.getFontStyle()) || CSSConstants.CSS_ITALIC_VALUE.equals(style.getFontStyle()));

        // search cache to reuse existing same font.
        for (Iterator<HSSFFont> itr = fontCache.iterator(); itr.hasNext();) {
            HSSFFont font = itr.next();

            if (font.getColor() == forecolor
                    && font.getFontName().equals(fontName)
                    && font.getFontHeightInPoints() == fontSize
                    && font.getUnderline() == underline
                    && font.getStrikeout() == strikeout
                    && font.getBoldweight() == boldweight
                    && font.getItalic() == italic) {
                cellFont = font;
                break;
            }
        }
View Full Code Here

            PlaqueAttribueeLine.COMP_NOM_PRENOM);

        final HSSFWorkbook wb = new HSSFWorkbook();
        int sheetIndex = -1;

        final HSSFFont font = wb.createFont();
        font.setFontHeightInPoints((short) 12);
        font.setFontName("Arial");

        final HSSFCellStyle style = wb.createCellStyle();
        style.setFont(font);

        for (CategorieParticipante catPart : categoriesParticipantes)
        {
          int categorySheetIndex = -1;

          Collection<PlaqueAttribueeLine> plaquesCategorie = selectStr
              .getResult(catPart.getCategorie(), plaques);
          plaquesCategorie = orderStr.getResult(plaquesCategorie);

          final Iterator<PlaqueAttribueeLine> itLine = plaquesCategorie
              .iterator();

          while (itLine.hasNext())
          {
            final HSSFSheet sheet = newSheet(wb, catPart
                .getCategorie(), ++categorySheetIndex);
            sheetIndex++;
            sheet.getPrintSetup().setLandscape(true);
            boolean emptySheet = true;

            for (short j = 0; j < ListePlaquePage.COLONNES_PAR_PAGE; j++)
            {
              for (short k = 0; k < ListePlaquePage.LIGNES_PAR_PAGE; k++)
              {
                if (itLine.hasNext())
                {
                  final PlaqueAttribueeLine line = itLine
                      .next();

                  //Seules les feuilles où il y a au moins un nom
                  //sont incluses dans le classeur.
                  if (line.getNomPrenom() != null
                      && !line.getNomPrenom().equals(""))
                  {
                    emptySheet = false;
                  }

                  final HSSFRow row = sheet
                      .createRow(getIndexLigne(k));

                  HSSFCell cell = row
                      .createCell(getIndexColonne(
                          j,
                          ListePlaquePage.INDEX_PLAQUE));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getPlaque()));
                  cell.setCellStyle(style);

                  cell = row.createCell(getIndexColonne(j,
                      ListePlaquePage.INDEX_NOM));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getNomPrenom()));
                  cell.setCellStyle(style);

                  cell = row.createCell(getIndexColonne(j,
                      ListePlaquePage.INDEX_COMMENTAIRE));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getCommentaire()));
                  cell.setCellStyle(style);
                }
                else
                {
                  //Aucune ligne à écrire... Terminer la boucle.
                  break;
                }
              }
            }

            //Enlever la feuille si elle est vide.
            if (emptySheet)
            {
              wb.removeSheetAt(sheetIndex--);
            }
          }
        }

        try
        {
          File file = File.createTempFile("excel", null);
          FileOutputStream fileOut = new FileOutputStream(file);
          wb.write(fileOut);
          fileOut.close();

          return new FileResourceStream(file);
        }
        catch (FileNotFoundException e)
        {
          throw new SystemeException(e);
        }
        catch (IOException e)
        {
          throw new SystemeException(e);
        }
      }

      @Override
      protected void setHeaders(WebResponse response)
      {
        super.setHeaders(response);
        response.setAttachmentHeader("Plaques - "
            + saisonReload.getAnnee().toString() + ".xls");
      }

      private HSSFSheet newSheet(final HSSFWorkbook wb,
          final Categorie categorie, final int page)
      {
        final HSSFSheet sheet = wb.createSheet(categorie
            .getCodeCategorie()
            + " " + categorie.getSexe() + "(" + page + ")");

        sheet.setColumnWidth((short) 0, (short) 2500);
        sheet.setColumnWidth((short) 1, (short) 8500);
        sheet.setColumnWidth((short) 2, (short) 3500);
        sheet.setColumnWidth((short) 3, (short) 1000);
        sheet.setColumnWidth((short) 4, (short) 2500);
        sheet.setColumnWidth((short) 5, (short) 8500);
        sheet.setColumnWidth((short) 6, (short) 3500);

        // --------- En-tête -----------
        HSSFFont font = wb.createFont();
        font.setFontHeightInPoints((short) 36);
        font.setFontName("Arial");
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        HSSFCellStyle style = wb.createCellStyle();
        style.setFont(font);

        HSSFRow row = sheet.createRow((short) 0);
        HSSFCell cell = row.createCell((short) 0);
        cell.setCellValue(new HSSFRichTextString(categorie
            .getDiscipline().getNom()));

        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 1));

        cell = row.createCell((short) 2);
        cell.setCellValue(new HSSFRichTextString(categorie.getNom()));

        sheet.addMergedRegion(new Region(0, (short) 2, 0, (short) 5));

        cell = row.createCell((short) 6);
        cell.setCellValue(new HSSFRichTextString(categorie.getSexe()));

        HSSFUtils.applyStyle(row, style);

        // ------- Séparateur -----------
        row = sheet.createRow((short) 1);
        row.setHeightInPoints(new Float(7.5));

        row = sheet.createRow((short) 2);

        for (short i = 0; i < ListePlaquePage.COLONNES_PAR_PAGE; i++)
        {
          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_PLAQUE));
          cell.setCellValue(new HSSFRichTextString("PLAQUE"));

          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_NOM));
          cell.setCellValue(new HSSFRichTextString("NOM, PRÉNOM"));

          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_COMMENTAIRE));
          cell.setCellValue(new HSSFRichTextString(""));
        }

        font = wb.createFont();
        font.setFontHeightInPoints((short) 10);
        font.setFontName("Arial");
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        style = wb.createCellStyle();
        style.setFont(font);

        HSSFUtils.applyStyle(row, style);
View Full Code Here

    sheet.setColumnWidth((short) 11, (short) 6500);
    sheet.setColumnWidth((short) 12, (short) 4000);
    sheet.setColumnWidth((short) 13, (short) 12000);

    // --------- En-tête de colonne -------
    HSSFFont font = wb.createFont();
    HSSFCellStyle style = wb.createCellStyle();

    font = wb.createFont();
    font.setFontHeightInPoints((short) 10);
    font.setFontName("Arial");
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

    style = wb.createCellStyle();
    style.setFont(font);

    HSSFRow row = sheet.createRow((short) 0);
View Full Code Here

    sheet.setColumnWidth(4, 6000);
    sheet.setColumnWidth(5, 1600);
    sheet.setColumnWidth(6, 20000);
    HSSFRow row = sheet.createRow(0);
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    style.setFont(font);
    writeHeaderCell(row, 0, "Value", style);
    writeHeaderCell(row, 1, "Raw Long Bits", style);
    writeHeaderCell(row, 2, "JDK Double Rendering", style);
    writeHeaderCell(row, 3, "Actual Rendering", style);
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

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.