Package org.apache.poi.hssf.usermodel

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


        EPStyle pstyle = (EPStyle) getAncestor(EPStyle.class);
        if (pstyle != null && pstyle.isValid()) {
            Hashtable colorhash = pstyle.getColorHash();       
            HSSFColor color = null;

            HSSFCellStyle style = pstyle.getStyle()//oops a little confusing
                                                      //below is the style attribute
                                                      //this is an HSSFCellStyle
                                                      //associated with EPStyle
            style.setBorderBottom((short)getStyle());

            ColorCode colorCode = getColor();
            if (colorCode != null) {
                color = (HSSFColor)colorhash.get(colorCode.toString());
            }
            if (color == null) {
                color = new HSSFColor.BLACK();
            }
            style.setBottomBorderColor(color.getIndex());
        }
       
    }   
View Full Code Here


        }
        return rval;
    }

    HSSFCellStyle addStyleRegion(Region region) {
        HSSFCellStyle style = _workbook.createStyle();
        /*
         * getLogger().debug("region = "+ region.getRowFrom() +
         * ","+region.getColumnFrom()+
         * ","+region.getRowTo()+","+region.getColumnTo());
         */
 
View Full Code Here

            for (int rownum = region.getRowFrom();
                        rownum < region.getRowTo() + 1; rownum++) {
                HSSFRow row = _sheet.getRow(rownum);
                for (short colnum = region.getColumnFrom();
                            colnum < region.getColumnTo() + 1; colnum++) {
                    HSSFCellStyle style = (HSSFCellStyle)regions.get(region);
                    if (!isBlank(style)) {
                        //don't waste time with huge blocks of blankly styled
                        // cells
                        if (row == null) {
                            if (rownum > Short.MAX_VALUE) {
View Full Code Here

        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);
View Full Code Here

        EPStyleRegion sregion = (EPStyleRegion) parent;

        if (sregion.isValid()) {
            Hashtable colorhash = sregion.getColorHash();

            HSSFCellStyle style = sregion.getStyle();
            short cnvhalign = convertAlignment(getHorizontalAlignment().getCode());
            style.setAlignment(cnvhalign);
            short cnvvalign = convertVAlignment(getVerticalAlignment().getCode());           
            style.setVerticalAlignment(cnvvalign);
            style.setFillPattern((short)getShade());


            if (getShade() == 1) {
                // TODO: change to constant when upgrade to new HSSF
                // solid w/foreground, bg doesn't matter
                getLogger().debug("shade = 1");
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {
                    getLogger().debug("s1 BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.WHITE();          
                }
                style.setFillForegroundColor(color.getIndex());
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("s1 PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());
            } else {
                HSSFColor color = (HSSFColor) colorhash.get(getBackgroundColor().toString());
                if (color == null) {               
                    getLogger().debug("BG couldn't find color for "+ getBackgroundColor().toString());
                    color = new HSSFColor.BLACK();  
                }
                style.setFillBackgroundColor(color.getIndex());           
                color = (HSSFColor) colorhash.get(getPatternColor().toString());
                if (color == null) {
                    getLogger().debug("PC couldn't find color for "+ getPatternColor().toString());
                    color = new HSSFColor.WHITE();    
                }
                style.setFillForegroundColor(color.getIndex());           
            }
            style.setWrapText(getWrapText());
            style.setLocked(true);

            String format = null;
            try {
                format = getFormat();
            } catch (NullPointerException e) {
                format = "General";
            }

            if (!format.equals("General")) {
                format = kludgeForGnumericMisformats(format);
                format = kludgeForGnumericDateDivergence(format);
                short nformat = org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(format);
                getLogger().debug("setting format to "+ nformat);
                style.setDataFormat(nformat);
            }
        } else {
            invalid = true;
        }
    }
View Full Code Here

   * @param horAlign
   * @param verAlign
   * @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);
    }
    if(verAlign!=-1) {
      cellStyle.setVerticalAlignment(verAlign);
    }
    return cellStyle;
  }
View Full Code Here

     * @param headerCell
     * @return
     */
    public HSSFCellStyle createHeaderStyle(HSSFWorkbook wb, HeaderCell headerCell)
    {
        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

     * @param properties props for this run
     */
    public void initCellStyles(TableProperties properties)
    {
        // Integer
        HSSFCellStyle style = getNewCellStyle();
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_INTEGER)));
        cellStyles.put(STYLE_INTEGER, style);

        // NUMBER
        style = getNewCellStyle();
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_NUMBER)));
        cellStyles.put(STYLE_NUMBER, style);

        // style = HSSFDataFormat.getBuiltinFormat("0.00%");

        // Date
        style = getNewCellStyle();
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setDataFormat(HSSFDataFormat.getBuiltinFormat(properties.getProperty(ExcelUtils.EXCEL_FORMAT_DATE)));
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        cellStyles.put(STYLE_DATE, style);

        // Long text
        style = getNewCellStyle(); // http://jakarta.apache.org/poi/hssf/quick-guide.html#NewLinesInCells
        style.setWrapText(true);
        cellStyles.put(STYLE_LONGSTRING, style);

        // Regular text
        cellStyles.put(STYLE_STRING, getNewCellStyle());

View Full Code Here

     * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
     */
    @Override
    protected void writeCaption(TableModel model) throws Exception
    {
        HSSFCellStyle style = this.wb.createCellStyle();
        HSSFFont bold = this.wb.createFont();
        bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
        bold.setFontHeightInPoints((short) 14);
        style.setFont(bold);
        style.setAlignment(CellStyle.ALIGN_CENTER);

        this.colNum = 0;
        this.currentRow = this.sheet.createRow(this.sheetRowNum++);
        this.currentCell = this.currentRow.createCell(this.colNum);
        this.currentCell.setCellStyle(style);
View Full Code Here

    @Override
    protected void writeTableHeader(TableModel model) throws Exception
    {
        this.currentRow = this.sheet.createRow(this.sheetRowNum++);
        this.colNum = 0;
        HSSFCellStyle headerStyle = this.getHeaderFooterStyle();
        for (HeaderCell headerCell : model.getHeaderCellList())
        {
            String columnHeader = headerCell.getTitle();
            if (columnHeader == null)
            {
View Full Code Here

TOP

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

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.