1    
2    /* ====================================================================
3     * The Apache Software License, Version 1.1
4     *
5     * Copyright (c) 2002 The Apache Software Foundation.  All rights
6     * reserved.
7     *
8     * Redistribution and use in source and binary forms, with or without
9     * modification, are permitted provided that the following conditions
10    * are met:
11    *
12    * 1. Redistributions of source code must retain the above copyright
13    *    notice, this list of conditions and the following disclaimer.
14    *
15    * 2. Redistributions in binary form must reproduce the above copyright
16    *    notice, this list of conditions and the following disclaimer in
17    *    the documentation and/or other materials provided with the
18    *    distribution.
19    *
20    * 3. The end-user documentation included with the redistribution,
21    *    if any, must include the following acknowledgment:
22    *       "This product includes software developed by the
23    *        Apache Software Foundation (http://www.apache.org/)."
24    *    Alternately, this acknowledgment may appear in the software itself,
25    *    if and wherever such third-party acknowledgments normally appear.
26    *
27    * 4. The names "Apache" and "Apache Software Foundation" and
28    *    "Apache POI" must not be used to endorse or promote products
29    *    derived from this software without prior written permission. For
30    *    written permission, please contact apache@apache.org.
31    *
32    * 5. Products derived from this software may not be called "Apache",
33    *    "Apache POI", nor may "Apache" appear in their name, without
34    *    prior written permission of the Apache Software Foundation.
35    *
36    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47    * SUCH DAMAGE.
48    * ====================================================================
49    *
50    * This software consists of voluntary contributions made by many
51    * individuals on behalf of the Apache Software Foundation.  For more
52    * information on the Apache Software Foundation, please see
53    * <http://www.apache.org/>.
54    */
55   
56   /*
57    * HSSFCellStyle.java
58    *
59    * Created on September 30, 2001, 3:47 PM
60    */
61   package org.apache.poi.hssf.usermodel;
62   
63   import org.apache.poi.hssf.record.ExtendedFormatRecord;
64   
65   /**
66    * High level representation of the style of a cell in a sheet of a workbook.
67    *
68    * @version 1.0-pre
69    *
70    * @author  Andrew C. Oliver (acoliver at apache dot org)
71    * @author Jason Height (jheight at chariot dot net dot au)
72    * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle()
73    * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
74    * @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)
75    */
76   
77   public class HSSFCellStyle
78   {
79       private ExtendedFormatRecord format                     = null;
80       private short                index                      = 0;
81       private short                fontindex                  = 0;
82   
83       /**
84        * general (normal) horizontal alignment
85        */
86   
87       public final static short    ALIGN_GENERAL              = 0x0;
88   
89       /**
90        * left-justified horizontal alignment
91        */
92   
93       public final static short    ALIGN_LEFT                 = 0x1;
94   
95       /**
96        * center horizontal alignment
97        */
98   
99       public final static short    ALIGN_CENTER               = 0x2;
100  
101      /**
102       * right-justified horizontal alignment
103       */
104  
105      public final static short    ALIGN_RIGHT                = 0x3;
106  
107      /**
108       * fill? horizontal alignment
109       */
110  
111      public final static short    ALIGN_FILL                 = 0x4;
112  
113      /**
114       * justified horizontal alignment
115       */
116  
117      public final static short    ALIGN_JUSTIFY              = 0x5;
118  
119      /**
120       * center-selection? horizontal alignment
121       */
122  
123      public final static short    ALIGN_CENTER_SELECTION     = 0x6;
124  
125      /**
126       * top-aligned vertical alignment
127       */
128  
129      public final static short    VERTICAL_TOP               = 0x0;
130  
131      /**
132       * center-aligned vertical alignment
133       */
134  
135      public final static short    VERTICAL_CENTER            = 0x1;
136  
137      /**
138       * bottom-aligned vertical alignment
139       */
140  
141      public final static short    VERTICAL_BOTTOM            = 0x2;
142  
143      /**
144       * vertically justified vertical alignment
145       */
146  
147      public final static short    VERTICAL_JUSTIFY           = 0x3;
148  
149      /**
150       * No border
151       */
152  
153      public final static short    BORDER_NONE                = 0x0;
154  
155      /**
156       * Thin border
157       */
158  
159      public final static short    BORDER_THIN                = 0x1;
160  
161      /**
162       * Medium border
163       */
164  
165      public final static short    BORDER_MEDIUM              = 0x2;
166  
167      /**
168       * dash border
169       */
170  
171      public final static short    BORDER_DASHED              = 0x3;
172  
173      /**
174       * dot border
175       */
176  
177      public final static short    BORDER_HAIR              = 0x4;
178  
179      /**
180       * Thick border
181       */
182  
183      public final static short    BORDER_THICK               = 0x5;
184  
185      /**
186       * double-line border
187       */
188  
189      public final static short    BORDER_DOUBLE              = 0x6;
190  
191      /**
192       * hair-line border
193       */
194  
195      public final static short    BORDER_DOTTED                = 0x7;
196  
197      /**
198       * Medium dashed border
199       */
200  
201      public final static short    BORDER_MEDIUM_DASHED       = 0x8;
202  
203      /**
204       * dash-dot border
205       */
206  
207      public final static short    BORDER_DASH_DOT            = 0x9;
208  
209      /**
210       * medium dash-dot border
211       */
212  
213      public final static short    BORDER_MEDIUM_DASH_DOT     = 0xA;
214  
215      /**
216       * dash-dot-dot border
217       */
218  
219      public final static short    BORDER_DASH_DOT_DOT        = 0xB;
220  
221      /**
222       * medium dash-dot-dot border
223       */
224  
225      public final static short    BORDER_MEDIUM_DASH_DOT_DOT = 0xC;
226  
227      /**
228       * slanted dash-dot border
229       */
230  
231      public final static short    BORDER_SLANTED_DASH_DOT    = 0xD;
232  
233      /**  No background */
234      public final static short     NO_FILL             = 0  ;
235      /**  Solidly filled */
236      public final static short     SOLID_FOREGROUND    = 1  ;
237      /**  Small fine dots */
238      public final static short     FINE_DOTS           = 2  ;
239      /**  Wide dots */
240      public final static short     ALT_BARS            = 3  ;
241      /**  Sparse dots */
242      public final static short     SPARSE_DOTS         = 4  ;
243      /**  Thick horizontal bands */
244      public final static short     THICK_HORZ_BANDS    = 5  ;
245      /**  Thick vertical bands */
246      public final static short     THICK_VERT_BANDS    = 6  ;
247      /**  Thick backward facing diagonals */
248      public final static short     THICK_BACKWARD_DIAG = 7  ;
249      /**  Thick forward facing diagonals */
250      public final static short     THICK_FORWARD_DIAG  = 8  ;
251      /**  Large spots */
252      public final static short     BIG_SPOTS           = 9  ;
253      /**  Brick-like layout */
254      public final static short     BRICKS              = 10 ;
255      /**  Thin horizontal bands */
256      public final static short     THIN_HORZ_BANDS     = 11 ;
257      /**  Thin vertical bands */
258      public final static short     THIN_VERT_BANDS     = 12 ;
259      /**  Thin backward diagonal */
260      public final static short     THIN_BACKWARD_DIAG  = 13 ;
261      /**  Thin forward diagonal */
262      public final static short     THIN_FORWARD_DIAG   = 14 ;
263      /**  Squares */
264      public final static short     SQUARES             = 15 ;
265      /**  Diamonds */
266      public final static short     DIAMONDS            = 16 ;
267  
268  
269      /** Creates new HSSFCellStyle why would you want to do this?? */
270  
271      protected HSSFCellStyle(short index, ExtendedFormatRecord rec)
272      {
273          this.index = index;
274          format     = rec;
275      }
276  
277      /**
278       * get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects)
279       * @return unique index number of the underlying record this style represents (probably you don't care
280       *  unless you're comparing which one is which)
281       */
282  
283      public short getIndex()
284      {
285          return index;
286      }
287  
288      /**
289       * set the data format (must be a valid format)
290       * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
291       */
292  
293      public void setDataFormat(short fmt)
294      {
295          format.setFormatIndex(fmt);
296      }
297  
298      /**
299       * get the index of the format
300       * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
301       */
302  
303      public short getDataFormat()
304      {
305          return format.getFormatIndex();
306      }
307  
308      /**
309       * set the font for this style
310       * @param font  a font object created or retreived from the HSSFWorkbook object
311       * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont()
312       * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
313       */
314  
315      public void setFont(HSSFFont font)
316      {
317          format.setIndentNotParentFont(true);
318          fontindex = font.getIndex();
319          format.setFontIndex(fontindex);
320      }
321  
322      public short getFontIndex()
323      {
324          return format.getFontIndex();
325      }
326  
327      /**
328       * set the cell's using this style to be hidden
329       * @param hidden - whether the cell using this style should be hidden
330       */
331  
332      public void setHidden(boolean hidden)
333      {
334          format.setIndentNotParentCellOptions(true);
335          format.setHidden(hidden);
336      }
337  
338      /**
339       * get whether the cell's using this style are to be hidden
340       * @return hidden - whether the cell using this style should be hidden
341       */
342  
343      public boolean getHidden()
344      {
345          return format.isHidden();
346      }
347  
348      /**
349       * set the cell's using this style to be locked
350       * @param locked - whether the cell using this style should be locked
351       */
352  
353      public void setLocked(boolean locked)
354      {
355          format.setIndentNotParentCellOptions(true);
356          format.setLocked(locked);
357      }
358  
359      /**
360       * get whether the cell's using this style are to be locked
361       * @return hidden - whether the cell using this style should be locked
362       */
363  
364      public boolean getLocked()
365      {
366          return format.isLocked();
367      }
368  
369      /**
370       * set the type of horizontal alignment for the cell
371       * @param align - the type of alignment
372       * @see #ALIGN_GENERAL
373       * @see #ALIGN_LEFT
374       * @see #ALIGN_CENTER
375       * @see #ALIGN_RIGHT
376       * @see #ALIGN_FILL
377       * @see #ALIGN_JUSTIFY
378       * @see #ALIGN_CENTER_SELECTION
379       */
380  
381      public void setAlignment(short align)
382      {
383          format.setIndentNotParentAlignment(true);
384          format.setAlignment(align);
385      }
386  
387      /**
388       * get the type of horizontal alignment for the cell
389       * @return align - the type of alignment
390       * @see #ALIGN_GENERAL
391       * @see #ALIGN_LEFT
392       * @see #ALIGN_CENTER
393       * @see #ALIGN_RIGHT
394       * @see #ALIGN_FILL
395       * @see #ALIGN_JUSTIFY
396       * @see #ALIGN_CENTER_SELECTION
397       */
398  
399      public short getAlignment()
400      {
401          return format.getAlignment();
402      }
403  
404      /**
405       * get whether this cell is to be part of a merged block of cells
406       *
407       * @returns merged or not
408       */
409  
410  //    public boolean getMergeCells()
411  //    {
412  //        return format.getMergeCells();
413  //    }
414  
415      /**
416       * set whether this cell is to be part of a merged block of cells
417       *
418       * @param merge  merged or not
419       */
420  
421  //    public void setMergeCells(boolean merge)
422  //    {
423  //        format.setMergeCells(merge);
424  //    }
425  
426      /**
427       * set whether the text should be wrapped
428       * @param wrapped  wrap text or not
429       */
430  
431      public void setWrapText(boolean wrapped)
432      {
433          format.setIndentNotParentAlignment(true);
434          format.setWrapText(wrapped);
435      }
436  
437      /**
438       * get whether the text should be wrapped
439       * @return wrap text or not
440       */
441  
442      public boolean getWrapText()
443      {
444          return format.getWrapText();
445      }
446  
447      /**
448       * set the type of vertical alignment for the cell
449       * @param align the type of alignment
450       * @see #VERTICAL_TOP
451       * @see #VERTICAL_CENTER
452       * @see #VERTICAL_BOTTOM
453       * @see #VERTICAL_JUSTIFY
454       */
455  
456      public void setVerticalAlignment(short align)
457      {
458          format.setVerticalAlignment(align);
459      }
460  
461      /**
462       * get the type of vertical alignment for the cell
463       * @return align the type of alignment
464       * @see #VERTICAL_TOP
465       * @see #VERTICAL_CENTER
466       * @see #VERTICAL_BOTTOM
467       * @see #VERTICAL_JUSTIFY
468       */
469  
470      public short getVerticalAlignment()
471      {
472          return format.getVerticalAlignment();
473      }
474  
475      /**
476       * set the degree of rotation for the text in the cell
477       * @param rotation degrees (between -90 and 90 degrees)
478       */
479  
480      public void setRotation(short rotation)
481      {
482        if ((rotation < 0)&&(rotation >= -90)) {
483          //Take care of the funny 4th quadrant issue
484          //The 4th quadrant (-1 to -90) is stored as (91 to 180)
485          rotation = (short)(90 - rotation);
486        }
487        else if ((rotation < -90)  ||(rotation > 90))
488          //Do not allow an incorrect rotation to be set
489          throw new IllegalArgumentException("The rotation must be between -90 and 90 degrees");
490          format.setRotation(rotation);
491      }
492  
493      /**
494       * get the degree of rotation for the text in the cell
495       * @return rotation degrees (between -90 and 90 degrees)
496       */
497  
498      public short getRotation()
499      {
500        short rotation = format.getRotation();
501        if (rotation > 90)
502          //This is actually the 4th quadrant
503          rotation = (short)(90-rotation);
504        return rotation;
505      }
506  
507      /**
508       * set the number of spaces to indent the text in the cell
509       * @param indent - number of spaces
510       */
511  
512      public void setIndention(short indent)
513      {
514          format.setIndent(indent);
515      }
516  
517      /**
518       * get the number of spaces to indent the text in the cell
519       * @return indent - number of spaces
520       */
521  
522      public short getIndention()
523      {
524          return format.getIndent();
525      }
526  
527      /**
528       * set the type of border to use for the left border of the cell
529       * @param border type
530       * @see #BORDER_NONE
531       * @see #BORDER_THIN
532       * @see #BORDER_MEDIUM
533       * @see #BORDER_DASHED
534       * @see #BORDER_DOTTED
535       * @see #BORDER_THICK
536       * @see #BORDER_DOUBLE
537       * @see #BORDER_HAIR
538       * @see #BORDER_MEDIUM_DASHED
539       * @see #BORDER_DASH_DOT
540       * @see #BORDER_MEDIUM_DASH_DOT
541       * @see #BORDER_DASH_DOT_DOT
542       * @see #BORDER_MEDIUM_DASH_DOT_DOT
543       * @see #BORDER_SLANTED_DASH_DOT
544       */
545  
546      public void setBorderLeft(short border)
547      {
548          format.setIndentNotParentBorder(true);
549          format.setBorderLeft(border);
550      }
551  
552      /**
553       * get the type of border to use for the left border of the cell
554       * @return border type
555       * @see #BORDER_NONE
556       * @see #BORDER_THIN
557       * @see #BORDER_MEDIUM
558       * @see #BORDER_DASHED
559       * @see #BORDER_DOTTED
560       * @see #BORDER_THICK
561       * @see #BORDER_DOUBLE
562       * @see #BORDER_HAIR
563       * @see #BORDER_MEDIUM_DASHED
564       * @see #BORDER_DASH_DOT
565       * @see #BORDER_MEDIUM_DASH_DOT
566       * @see #BORDER_DASH_DOT_DOT
567       * @see #BORDER_MEDIUM_DASH_DOT_DOT
568       * @see #BORDER_SLANTED_DASH_DOT
569       */
570  
571      public short getBorderLeft()
572      {
573          return format.getBorderLeft();
574      }
575  
576      /**
577       * set the type of border to use for the right border of the cell
578       * @param border type
579       * @see #BORDER_NONE
580       * @see #BORDER_THIN
581       * @see #BORDER_MEDIUM
582       * @see #BORDER_DASHED
583       * @see #BORDER_DOTTED
584       * @see #BORDER_THICK
585       * @see #BORDER_DOUBLE
586       * @see #BORDER_HAIR
587       * @see #BORDER_MEDIUM_DASHED
588       * @see #BORDER_DASH_DOT
589       * @see #BORDER_MEDIUM_DASH_DOT
590       * @see #BORDER_DASH_DOT_DOT
591       * @see #BORDER_MEDIUM_DASH_DOT_DOT
592       * @see #BORDER_SLANTED_DASH_DOT
593       */
594  
595      public void setBorderRight(short border)
596      {
597          format.setIndentNotParentBorder(true);
598          format.setBorderRight(border);
599      }
600  
601      /**
602       * get the type of border to use for the right border of the cell
603       * @return border type
604       * @see #BORDER_NONE
605       * @see #BORDER_THIN
606       * @see #BORDER_MEDIUM
607       * @see #BORDER_DASHED
608       * @see #BORDER_DOTTED
609       * @see #BORDER_THICK
610       * @see #BORDER_DOUBLE
611       * @see #BORDER_HAIR
612       * @see #BORDER_MEDIUM_DASHED
613       * @see #BORDER_DASH_DOT
614       * @see #BORDER_MEDIUM_DASH_DOT
615       * @see #BORDER_DASH_DOT_DOT
616       * @see #BORDER_MEDIUM_DASH_DOT_DOT
617       * @see #BORDER_SLANTED_DASH_DOT
618       */
619  
620      public short getBorderRight()
621      {
622          return format.getBorderRight();
623      }
624  
625      /**
626       * set the type of border to use for the top border of the cell
627       * @param border type
628       * @see #BORDER_NONE
629       * @see #BORDER_THIN
630       * @see #BORDER_MEDIUM
631       * @see #BORDER_DASHED
632       * @see #BORDER_DOTTED
633       * @see #BORDER_THICK
634       * @see #BORDER_DOUBLE
635       * @see #BORDER_HAIR
636       * @see #BORDER_MEDIUM_DASHED
637       * @see #BORDER_DASH_DOT
638       * @see #BORDER_MEDIUM_DASH_DOT
639       * @see #BORDER_DASH_DOT_DOT
640       * @see #BORDER_MEDIUM_DASH_DOT_DOT
641       * @see #BORDER_SLANTED_DASH_DOT
642       */
643  
644      public void setBorderTop(short border)
645      {
646          format.setIndentNotParentBorder(true);
647          format.setBorderTop(border);
648      }
649  
650      /**
651       * get the type of border to use for the top border of the cell
652       * @return border type
653       * @see #BORDER_NONE
654       * @see #BORDER_THIN
655       * @see #BORDER_MEDIUM
656       * @see #BORDER_DASHED
657       * @see #BORDER_DOTTED
658       * @see #BORDER_THICK
659       * @see #BORDER_DOUBLE
660       * @see #BORDER_HAIR
661       * @see #BORDER_MEDIUM_DASHED
662       * @see #BORDER_DASH_DOT
663       * @see #BORDER_MEDIUM_DASH_DOT
664       * @see #BORDER_DASH_DOT_DOT
665       * @see #BORDER_MEDIUM_DASH_DOT_DOT
666       * @see #BORDER_SLANTED_DASH_DOT
667       */
668  
669      public short getBorderTop()
670      {
671          return format.getBorderTop();
672      }
673  
674      /**
675       * set the type of border to use for the bottom border of the cell
676       * @param border type
677       * @see #BORDER_NONE
678       * @see #BORDER_THIN
679       * @see #BORDER_MEDIUM
680       * @see #BORDER_DASHED
681       * @see #BORDER_DOTTED
682       * @see #BORDER_THICK
683       * @see #BORDER_DOUBLE
684       * @see #BORDER_HAIR
685       * @see #BORDER_MEDIUM_DASHED
686       * @see #BORDER_DASH_DOT
687       * @see #BORDER_MEDIUM_DASH_DOT
688       * @see #BORDER_DASH_DOT_DOT
689       * @see #BORDER_MEDIUM_DASH_DOT_DOT
690       * @see #BORDER_SLANTED_DASH_DOT
691       */
692  
693      public void setBorderBottom(short border)
694      {
695          format.setIndentNotParentBorder(true);
696          format.setBorderBottom(border);
697      }
698  
699      /**
700       * get the type of border to use for the bottom border of the cell
701       * @return border type
702       * @see #BORDER_NONE
703       * @see #BORDER_THIN
704       * @see #BORDER_MEDIUM
705       * @see #BORDER_DASHED
706       * @see #BORDER_DOTTED
707       * @see #BORDER_THICK
708       * @see #BORDER_DOUBLE
709       * @see #BORDER_HAIR
710       * @see #BORDER_MEDIUM_DASHED
711       * @see #BORDER_DASH_DOT
712       * @see #BORDER_MEDIUM_DASH_DOT
713       * @see #BORDER_DASH_DOT_DOT
714       * @see #BORDER_MEDIUM_DASH_DOT_DOT
715       * @see #BORDER_SLANTED_DASH_DOT
716       */
717  
718      public short getBorderBottom()
719      {
720          return format.getBorderBottom();
721      }
722  
723      /**
724       * set the color to use for the left border
725       * @param color
726       */
727  
728      public void setLeftBorderColor(short color)
729      {
730          format.setLeftBorderPaletteIdx(color);
731      }
732  
733      /**
734       * get the color to use for the left border
735       * @return color
736       */
737  
738      public short getLeftBorderColor()
739      {
740          return format.getLeftBorderPaletteIdx();
741      }
742  
743      /**
744       * set the color to use for the right border
745       * @param color
746       */
747  
748      public void setRightBorderColor(short color)
749      {
750          format.setRightBorderPaletteIdx(color);
751      }
752  
753      /**
754       * get the color to use for the left border
755       * @return color
756       */
757  
758      public short getRightBorderColor()
759      {
760          return format.getRightBorderPaletteIdx();
761      }
762  
763      /**
764       * set the color to use for the top border
765       * @param color
766       */
767  
768      public void setTopBorderColor(short color)
769      {
770          format.setTopBorderPaletteIdx(color);
771      }
772  
773      /**
774       * get the color to use for the top border
775       * @return color
776       */
777  
778      public short getTopBorderColor()
779      {
780          return format.getTopBorderPaletteIdx();
781      }
782  
783      /**
784       * set the color to use for the bottom border
785       * @param color
786       */
787  
788      public void setBottomBorderColor(short color)
789      {
790          format.setBottomBorderPaletteIdx(color);
791      }
792  
793      /**
794       * get the color to use for the left border
795       * @return color
796       */
797  
798      public short getBottomBorderColor()
799      {
800          return format.getBottomBorderPaletteIdx();
801      }
802  
803      /**
804       * setting to one fills the cell with the foreground color... No idea about
805       * other values
806       *
807       * @see #NO_FILL
808       * @see #SOLID_FOREGROUND
809       * @see #FINE_DOTS
810       * @see #ALT_BARS
811       * @see #SPARSE_DOTS
812       * @see #THICK_HORZ_BANDS
813       * @see #THICK_VERT_BANDS
814       * @see #THICK_BACKWARD_DIAG
815       * @see #THICK_FORWARD_DIAG
816       * @see #BIG_SPOTS
817       * @see #BRICKS
818       * @see #THIN_HORZ_BANDS
819       * @see #THIN_VERT_BANDS
820       * @see #THIN_BACKWARD_DIAG
821       * @see #THIN_FORWARD_DIAG
822       * @see #SQUARES
823       * @see #DIAMONDS
824       *
825       * @param fp  fill pattern (set to 1 to fill w/foreground color)
826       */
827      public void setFillPattern(short fp)
828      {
829          format.setAdtlFillPattern(fp);
830      }
831  
832      /**
833       * get the fill pattern (??) - set to 1 to fill with foreground color
834       * @return fill pattern
835       */
836  
837      public short getFillPattern()
838      {
839          return format.getAdtlFillPattern();
840      }
841  
842      /**
843       * set the background fill color.
844       * <p>
845       * For example:
846       * <pre>
847       * cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
848       * cs.setFillBackgroundColor(HSSFCellStyle.RED);
849       * </pre>
850       * or, for the special case of SOLID_FILL:
851       * <pre>
852       * cs.setFillPattern(HSSFCellStyle.SOLID_FILL );
853       * cs.setFillForgroundColor(HSSFSeCellStyle.RED);
854       * </pre>
855       * It is necessary to set the fill style in order
856       * for the color to be shown in the cell.
857       *
858       * @param bg  color
859       */
860  
861      public void setFillBackgroundColor(short bg)
862      {
863          format.setFillBackground(bg);
864      }
865  
866      /**
867       * get the background fill color
868       * @return fill color
869       */
870  
871      public short getFillBackgroundColor()
872      {
873          return format.getFillBackground();
874      }
875  
876      /**
877       * set the foreground fill color
878       * @param bg  color
879       */
880  
881      public void setFillForegroundColor(short bg)
882      {
883          format.setFillForeground(bg);
884      }
885  
886      /**
887       * get the foreground fill color
888       * @return fill color
889       */
890  
891      public short getFillForegroundColor()
892      {
893          return format.getFillForeground();
894      }
895  
896  }
897