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    * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createCellStyle()
72    * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(short)
73    * @see org.apache.poi.hssf.usermodel.HSSFCell#setCellStyle(HSSFCellStyle)
74    */
75   
76   public class HSSFCellStyle
77       implements HSSFColorConstants
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_DOTTED              = 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_HAIR                = 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 (only builtin formats are supported)
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 built in 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
478       */
479  
480      public void setRotation(short rotation)
481      {
482          format.setRotation(rotation);
483      }
484  
485      /**
486       * get the degree of rotation for the text in the cell
487       * @return rotation degrees
488       */
489  
490      public short getRotation()
491      {
492          return format.getRotation();
493      }
494  
495      /**
496       * set the number of spaces to indent the text in the cell
497       * @param indent - number of spaces
498       */
499  
500      public void setIndention(short indent)
501      {
502          format.setIndent(indent);
503      }
504  
505      /**
506       * get the number of spaces to indent the text in the cell
507       * @return indent - number of spaces
508       */
509  
510      public short getIndention()
511      {
512          return format.getIndent();
513      }
514  
515      /**
516       * set the type of border to use for the left border of the cell
517       * @param border type
518       * @see #BORDER_NONE
519       * @see #BORDER_THIN
520       * @see #BORDER_MEDIUM
521       * @see #BORDER_DASHED
522       * @see #BORDER_DOTTED
523       * @see #BORDER_THICK
524       * @see #BORDER_DOUBLE
525       * @see #BORDER_HAIR
526       * @see #BORDER_MEDIUM_DASHED
527       * @see #BORDER_DASH_DOT
528       * @see #BORDER_MEDIUM_DASH_DOT
529       * @see #BORDER_DASH_DOT_DOT
530       * @see #BORDER_MEDIUM_DASH_DOT_DOT
531       * @see #BORDER_SLANTED_DASH_DOT
532       */
533  
534      public void setBorderLeft(short border)
535      {
536          format.setIndentNotParentBorder(true);
537          format.setBorderLeft(border);
538      }
539  
540      /**
541       * get the type of border to use for the left border of the cell
542       * @return border type
543       * @see #BORDER_NONE
544       * @see #BORDER_THIN
545       * @see #BORDER_MEDIUM
546       * @see #BORDER_DASHED
547       * @see #BORDER_DOTTED
548       * @see #BORDER_THICK
549       * @see #BORDER_DOUBLE
550       * @see #BORDER_HAIR
551       * @see #BORDER_MEDIUM_DASHED
552       * @see #BORDER_DASH_DOT
553       * @see #BORDER_MEDIUM_DASH_DOT
554       * @see #BORDER_DASH_DOT_DOT
555       * @see #BORDER_MEDIUM_DASH_DOT_DOT
556       * @see #BORDER_SLANTED_DASH_DOT
557       */
558  
559      public short getBorderLeft()
560      {
561          return format.getBorderLeft();
562      }
563  
564      /**
565       * set the type of border to use for the right border of the cell
566       * @param border type
567       * @see #BORDER_NONE
568       * @see #BORDER_THIN
569       * @see #BORDER_MEDIUM
570       * @see #BORDER_DASHED
571       * @see #BORDER_DOTTED
572       * @see #BORDER_THICK
573       * @see #BORDER_DOUBLE
574       * @see #BORDER_HAIR
575       * @see #BORDER_MEDIUM_DASHED
576       * @see #BORDER_DASH_DOT
577       * @see #BORDER_MEDIUM_DASH_DOT
578       * @see #BORDER_DASH_DOT_DOT
579       * @see #BORDER_MEDIUM_DASH_DOT_DOT
580       * @see #BORDER_SLANTED_DASH_DOT
581       */
582  
583      public void setBorderRight(short border)
584      {
585          format.setIndentNotParentBorder(true);
586          format.setBorderRight(border);
587      }
588  
589      /**
590       * get the type of border to use for the right border of the cell
591       * @return border type
592       * @see #BORDER_NONE
593       * @see #BORDER_THIN
594       * @see #BORDER_MEDIUM
595       * @see #BORDER_DASHED
596       * @see #BORDER_DOTTED
597       * @see #BORDER_THICK
598       * @see #BORDER_DOUBLE
599       * @see #BORDER_HAIR
600       * @see #BORDER_MEDIUM_DASHED
601       * @see #BORDER_DASH_DOT
602       * @see #BORDER_MEDIUM_DASH_DOT
603       * @see #BORDER_DASH_DOT_DOT
604       * @see #BORDER_MEDIUM_DASH_DOT_DOT
605       * @see #BORDER_SLANTED_DASH_DOT
606       */
607  
608      public short getBorderRight()
609      {
610          return format.getBorderRight();
611      }
612  
613      /**
614       * set the type of border to use for the top border of the cell
615       * @param border type
616       * @see #BORDER_NONE
617       * @see #BORDER_THIN
618       * @see #BORDER_MEDIUM
619       * @see #BORDER_DASHED
620       * @see #BORDER_DOTTED
621       * @see #BORDER_THICK
622       * @see #BORDER_DOUBLE
623       * @see #BORDER_HAIR
624       * @see #BORDER_MEDIUM_DASHED
625       * @see #BORDER_DASH_DOT
626       * @see #BORDER_MEDIUM_DASH_DOT
627       * @see #BORDER_DASH_DOT_DOT
628       * @see #BORDER_MEDIUM_DASH_DOT_DOT
629       * @see #BORDER_SLANTED_DASH_DOT
630       */
631  
632      public void setBorderTop(short border)
633      {
634          format.setIndentNotParentBorder(true);
635          format.setBorderTop(border);
636      }
637  
638      /**
639       * get the type of border to use for the top border of the cell
640       * @return border type
641       * @see #BORDER_NONE
642       * @see #BORDER_THIN
643       * @see #BORDER_MEDIUM
644       * @see #BORDER_DASHED
645       * @see #BORDER_DOTTED
646       * @see #BORDER_THICK
647       * @see #BORDER_DOUBLE
648       * @see #BORDER_HAIR
649       * @see #BORDER_MEDIUM_DASHED
650       * @see #BORDER_DASH_DOT
651       * @see #BORDER_MEDIUM_DASH_DOT
652       * @see #BORDER_DASH_DOT_DOT
653       * @see #BORDER_MEDIUM_DASH_DOT_DOT
654       * @see #BORDER_SLANTED_DASH_DOT
655       */
656  
657      public short getBorderTop()
658      {
659          return format.getBorderTop();
660      }
661  
662      /**
663       * set the type of border to use for the bottom border of the cell
664       * @param border type
665       * @see #BORDER_NONE
666       * @see #BORDER_THIN
667       * @see #BORDER_MEDIUM
668       * @see #BORDER_DASHED
669       * @see #BORDER_DOTTED
670       * @see #BORDER_THICK
671       * @see #BORDER_DOUBLE
672       * @see #BORDER_HAIR
673       * @see #BORDER_MEDIUM_DASHED
674       * @see #BORDER_DASH_DOT
675       * @see #BORDER_MEDIUM_DASH_DOT
676       * @see #BORDER_DASH_DOT_DOT
677       * @see #BORDER_MEDIUM_DASH_DOT_DOT
678       * @see #BORDER_SLANTED_DASH_DOT
679       */
680  
681      public void setBorderBottom(short border)
682      {
683          format.setIndentNotParentBorder(true);
684          format.setBorderBottom(border);
685      }
686  
687      /**
688       * get the type of border to use for the bottom border of the cell
689       * @return border type
690       * @see #BORDER_NONE
691       * @see #BORDER_THIN
692       * @see #BORDER_MEDIUM
693       * @see #BORDER_DASHED
694       * @see #BORDER_DOTTED
695       * @see #BORDER_THICK
696       * @see #BORDER_DOUBLE
697       * @see #BORDER_HAIR
698       * @see #BORDER_MEDIUM_DASHED
699       * @see #BORDER_DASH_DOT
700       * @see #BORDER_MEDIUM_DASH_DOT
701       * @see #BORDER_DASH_DOT_DOT
702       * @see #BORDER_MEDIUM_DASH_DOT_DOT
703       * @see #BORDER_SLANTED_DASH_DOT
704       */
705  
706      public short getBorderBottom()
707      {
708          return format.getBorderBottom();
709      }
710  
711      /**
712       * set the color to use for the left border
713       * @param color
714       */
715  
716      public void setLeftBorderColor(short color)
717      {
718          format.setLeftBorderPaletteIdx(color);
719      }
720  
721      /**
722       * get the color to use for the left border
723       * @return color
724       */
725  
726      public short getLeftBorderColor()
727      {
728          return format.getLeftBorderPaletteIdx();
729      }
730  
731      /**
732       * set the color to use for the right border
733       * @param color
734       */
735  
736      public void setRightBorderColor(short color)
737      {
738          format.setRightBorderPaletteIdx(color);
739      }
740  
741      /**
742       * get the color to use for the left border
743       * @return color
744       */
745  
746      public short getRightBorderColor()
747      {
748          return format.getRightBorderPaletteIdx();
749      }
750  
751      /**
752       * set the color to use for the top border
753       * @param color
754       */
755  
756      public void setTopBorderColor(short color)
757      {
758          format.setTopBorderPaletteIdx(color);
759      }
760  
761      /**
762       * get the color to use for the top border
763       * @return color
764       */
765  
766      public short getTopBorderColor()
767      {
768          return format.getTopBorderPaletteIdx();
769      }
770  
771      /**
772       * set the color to use for the bottom border
773       * @param color
774       */
775  
776      public void setBottomBorderColor(short color)
777      {
778          format.setBottomBorderPaletteIdx(color);
779      }
780  
781      /**
782       * get the color to use for the left border
783       * @return color
784       */
785  
786      public short getBottomBorderColor()
787      {
788          return format.getBottomBorderPaletteIdx();
789      }
790  
791      /**
792       * setting to one fills the cell with the foreground color... No idea about
793       * other values
794       *
795       * @see #NO_FILL
796       * @see #SOLID_FOREGROUND
797       * @see #FINE_DOTS
798       * @see #ALT_BARS
799       * @see #SPARSE_DOTS
800       * @see #THICK_HORZ_BANDS
801       * @see #THICK_VERT_BANDS
802       * @see #THICK_BACKWARD_DIAG
803       * @see #THICK_FORWARD_DIAG
804       * @see #BIG_SPOTS
805       * @see #BRICKS
806       * @see #THIN_HORZ_BANDS
807       * @see #THIN_VERT_BANDS
808       * @see #THIN_BACKWARD_DIAG
809       * @see #THIN_FORWARD_DIAG
810       * @see #SQUARES
811       * @see #DIAMONDS
812       *
813       * @param fp  fill pattern (set to 1 to fill w/foreground color)
814       */
815      public void setFillPattern(short fp)
816      {
817          format.setAdtlFillPattern(fp);
818      }
819  
820      /**
821       * get the fill pattern (??) - set to 1 to fill with foreground color
822       * @return fill pattern
823       */
824  
825      public short getFillPattern()
826      {
827          return format.getAdtlFillPattern();
828      }
829  
830      /**
831       * set the background fill color.
832       * <p>
833       * For example:
834       * <pre>
835       * cs.setFillPattern(HSSFCellStyle.FINE_DOTS );
836       * cs.setFillBackgroundColor(HSSFCellStyle.RED);
837       * </pre>
838       * or, for the special case of SOLID_FILL:
839       * <pre>
840       * cs.setFillPattern(HSSFCellStyle.SOLID_FILL );
841       * cs.setFillForgroundColor(HSSFSeCellStyle.RED);
842       * </pre>
843       * It is necessary to set the fill style in order
844       * for the color to be shown in the cell.
845       *
846       * @param bg  color
847       */
848  
849      public void setFillBackgroundColor(short bg)
850      {
851          format.setFillBackground(bg);
852      }
853  
854      /**
855       * get the background fill color
856       * @return fill color
857       */
858  
859      public short getFillBackgroundColor()
860      {
861          return format.getFillBackground();
862      }
863  
864      /**
865       * set the foreground fill color
866       * @param bg  color
867       */
868  
869      public void setFillForegroundColor(short bg)
870      {
871          format.setFillForeground(bg);
872      }
873  
874      /**
875       * get the foreground fill color
876       * @return fill color
877       */
878  
879      public short getFillForegroundColor()
880      {
881          return format.getFillForeground();
882      }
883  
884  }
885