--- /dev/null
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache POI" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache POI", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.poi.hssf.usermodel.examples;
+
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.HSSFColor;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Shows how to use various fills.
+ *
+ * @author Glen Stampoultzis (glens at apache.org)
+ */
+public class FrillsAndFills
+{
+ public static void main(String[] args)
+ throws IOException
+ {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet("new sheet");
+
+ // Create a row and put some cells in it. Rows are 0 based.
+ HSSFRow row = sheet.createRow((short) 1);
+
+ // Aqua background
+ HSSFCellStyle style = wb.createCellStyle();
+ style.setFillBackgroundColor(HSSFColor.AQUA.index);
+ style.setFillPattern(HSSFCellStyle.BIG_SPOTS);
+ HSSFCell cell = row.createCell((short) 1);
+ cell.setCellValue("X");
+ cell.setCellStyle(style);
+
+ // Orange "foreground", foreground being the fill foreground not the font color.
+ style = wb.createCellStyle();
+ style.setFillForegroundColor(HSSFColor.ORANGE.index);
+ style.setFillPattern(HSSFCellStyle.SOLID_FILL);
+ cell = row.createCell((short) 2);
+ cell.setCellValue("X");
+ cell.setCellStyle(style);
+
+ // Write the output to a file
+ FileOutputStream fileOut = new FileOutputStream("workbook.xls");
+ wb.write(fileOut);
+ fileOut.close();
+ }
+}
public final static short sid = 0xE0;
// null constant
- public final static short NULL = 0xfffffff0;
+ public final static short NULL = (short)0xfff0;
// xf type
public final static short XF_STYLE = 1;
public final static short VERTICAL_BOTTOM = 0x2;
public final static short VERTICAL_JUSTIFY = 0x3;
+ // fill
+ public final static short NO_FILL = 0 ;
+ public final static short SOLID_FILL = 1 ;
+ public final static short FINE_DOTS = 2 ;
+ public final static short ALT_BARS = 3 ;
+ public final static short SPARSE_DOTS = 4 ;
+ public final static short THICK_HORZ_BANDS = 5 ;
+ public final static short THICK_VERT_BANDS = 6 ;
+ public final static short THICK_BACKWARD_DIAG = 7 ;
+ public final static short THICK_FORWARD_DIAG = 8 ;
+ public final static short BIG_SPOTS = 9 ;
+ public final static short BRICKS = 10 ;
+ public final static short THIN_HORZ_BANDS = 11 ;
+ public final static short THIN_VERT_BANDS = 12 ;
+ public final static short THIN_BACKWARD_DIAG = 13 ;
+ public final static short THIN_FORWARD_DIAG = 14 ;
+ public final static short SQUARES = 15 ;
+ public final static short DIAMONDS = 16 ;
+
// fields in BOTH style and Cell XF records
private short field_1_font_index; // not bit-mapped
private short field_2_format_index; // not bit-mapped
* for cell XF types this is the parent style (usually 0/normal). For
* style this should be NULL.
*
- * @param index of parent XF
+ * @param parent index of parent XF
* @see #NULL
* @see #setCellOptions(short)
*/
* set the vertical alignment of text in the cell
*
*
- * @param where to align the text
+ * @param align where to align the text
* @see #VERTICAL_TOP
* @see #VERTICAL_CENTER
* @see #VERTICAL_BOTTOM
}
/**
- * set the fill pattern - ???
+ * set the fill pattern
*
+ * @see #NO_FILL
+ * @see #SOLID_FILL
+ * @see #FINE_DOTS
+ * @see #ALT_BARS
+ * @see #SPARSE_DOTS
+ * @see #THICK_HORZ_BANDS
+ * @see #THICK_VERT_BANDS
+ * @see #THICK_BACKWARD_DIAG
+ * @see #THICK_FORWARD_DIAG
+ * @see #BIG_SPOTS
+ * @see #BRICKS
+ * @see #THIN_HORZ_BANDS
+ * @see #THIN_VERT_BANDS
+ * @see #THIN_BACKWARD_DIAG
+ * @see #THIN_FORWARD_DIAG
+ * @see #SQUARES
+ * @see #DIAMONDS
*
* @param fill - fill pattern??
* @see #setAdtlPaletteOptions(short)
}
/**
- * get the additional fill pattern - ???
+ * get the additional fill pattern
*
+ * @see #NO_FILL
+ * @see #SOLID_FILL
+ * @see #FINE_DOTS
+ * @see #ALT_BARS
+ * @see #SPARSE_DOTS
+ * @see #THICK_HORZ_BANDS
+ * @see #THICK_VERT_BANDS
+ * @see #THICK_BACKWARD_DIAG
+ * @see #THICK_FORWARD_DIAG
+ * @see #BIG_SPOTS
+ * @see #BRICKS
+ * @see #THIN_HORZ_BANDS
+ * @see #THIN_VERT_BANDS
+ * @see #THIN_BACKWARD_DIAG
+ * @see #THIN_FORWARD_DIAG
+ * @see #SQUARES
+ * @see #DIAMONDS
*
* @return fill - fill pattern??
* @see #getAdtlPaletteOptions()
/**
* get the background palette color index
*
- *
- * @param color - palette index
+ * @retyrb color palette index
* @see #getFillPaletteOptions()
*/
public final static short BORDER_SLANTED_DASH_DOT = 0xD;
+ /** No background */
+ public final static short NO_FILL = 0 ;
+ /** Solidly filled */
+ public final static short SOLID_FILL = 1 ;
+ /** Small fine dots */
+ public final static short FINE_DOTS = 2 ;
+ /** Wide dots */
+ public final static short ALT_BARS = 3 ;
+ /** Sparse dots */
+ public final static short SPARSE_DOTS = 4 ;
+ /** Thick horizontal bands */
+ public final static short THICK_HORZ_BANDS = 5 ;
+ /** Thick vertical bands */
+ public final static short THICK_VERT_BANDS = 6 ;
+ /** Thick backward facing diagonals */
+ public final static short THICK_BACKWARD_DIAG = 7 ;
+ /** Thick forward facing diagonals */
+ public final static short THICK_FORWARD_DIAG = 8 ;
+ /** Large spots */
+ public final static short BIG_SPOTS = 9 ;
+ /** Brick-like layout */
+ public final static short BRICKS = 10 ;
+ /** Thin horizontal bands */
+ public final static short THIN_HORZ_BANDS = 11 ;
+ /** Thin vertical bands */
+ public final static short THIN_VERT_BANDS = 12 ;
+ /** Thin backward diagonal */
+ public final static short THIN_BACKWARD_DIAG = 13 ;
+ /** Thin forward diagonal */
+ public final static short THIN_FORWARD_DIAG = 14 ;
+ /** Squares */
+ public final static short SQUARES = 15 ;
+ /** Diamonds */
+ public final static short DIAMONDS = 16 ;
+
+
/** Creates new HSSFCellStyle why would you want to do this?? */
protected HSSFCellStyle(short index, ExtendedFormatRecord rec)
/**
* setting to one fills the cell with the foreground color... No idea about
* other values
- * @param fp fill pattern (set to 1 to fill w/foreground color
+ *
+ * @see #NO_FILL
+ * @see #SOLID_FILL
+ * @see #FINE_DOTS
+ * @see #ALT_BARS
+ * @see #SPARSE_DOTS
+ * @see #THICK_HORZ_BANDS
+ * @see #THICK_VERT_BANDS
+ * @see #THICK_BACKWARD_DIAG
+ * @see #THICK_FORWARD_DIAG
+ * @see #BIG_SPOTS
+ * @see #BRICKS
+ * @see #THIN_HORZ_BANDS
+ * @see #THIN_VERT_BANDS
+ * @see #THIN_BACKWARD_DIAG
+ * @see #THIN_FORWARD_DIAG
+ * @see #SQUARES
+ * @see #DIAMONDS
+ *
+ * @param fp fill pattern (set to 1 to fill w/foreground color)
*/
-
public void setFillPattern(short fp)
{
format.setAdtlFillPattern(fp);
}
/**
- * set the background fill color
+ * set the background fill color.
+ * <p>
+ * For example:
+ * <pre>
+ * cs.setFillPattern( (short) 1 );
+ * cs.setFillBackgroundColor(HSSFColor.RED.index);
+ * </pre>
+ * You will need to set the fill style first.
+ *
* @param bg color
*/