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 { 78 private ExtendedFormatRecord format = null; 79 private short index = 0; 80 private short fontindex = 0; 81 82 /** 83 * general (normal) horizontal alignment 84 */ 85 86 public final static short ALIGN_GENERAL = 0x0; 87 88 /** 89 * left-justified horizontal alignment 90 */ 91 92 public final static short ALIGN_LEFT = 0x1; 93 94 /** 95 * center horizontal alignment 96 */ 97 98 public final static short ALIGN_CENTER = 0x2; 99 100 /** 101 * right-justified horizontal alignment 102 */ 103 104 public final static short ALIGN_RIGHT = 0x3; 105 106 /** 107 * fill? horizontal alignment 108 */ 109 110 public final static short ALIGN_FILL = 0x4; 111 112 /** 113 * justified horizontal alignment 114 */ 115 116 public final static short ALIGN_JUSTIFY = 0x5; 117 118 /** 119 * center-selection? horizontal alignment 120 */ 121 122 public final static short ALIGN_CENTER_SELECTION = 0x6; 123 124 /** 125 * top-aligned vertical alignment 126 */ 127 128 public final static short VERTICAL_TOP = 0x0; 129 130 /** 131 * center-aligned vertical alignment 132 */ 133 134 public final static short VERTICAL_CENTER = 0x1; 135 136 /** 137 * bottom-aligned vertical alignment 138 */ 139 140 public final static short VERTICAL_BOTTOM = 0x2; 141 142 /** 143 * vertically justified vertical alignment 144 */ 145 146 public final static short VERTICAL_JUSTIFY = 0x3; 147 148 /** 149 * No border 150 */ 151 152 public final static short BORDER_NONE = 0x0; 153 154 /** 155 * Thin border 156 */ 157 158 public final static short BORDER_THIN = 0x1; 159 160 /** 161 * Medium border 162 */ 163 164 public final static short BORDER_MEDIUM = 0x2; 165 166 /** 167 * dash border 168 */ 169 170 public final static short BORDER_DASHED = 0x3; 171 172 /** 173 * dot border 174 */ 175 176 public final static short BORDER_DOTTED = 0x4; 177 178 /** 179 * Thick border 180 */ 181 182 public final static short BORDER_THICK = 0x5; 183 184 /** 185 * double-line border 186 */ 187 188 public final static short BORDER_DOUBLE = 0x6; 189 190 /** 191 * hair-line border 192 */ 193 194 public final static short BORDER_HAIR = 0x7; 195 196 /** 197 * Medium dashed border 198 */ 199 200 public final static short BORDER_MEDIUM_DASHED = 0x8; 201 202 /** 203 * dash-dot border 204 */ 205 206 public final static short BORDER_DASH_DOT = 0x9; 207 208 /** 209 * medium dash-dot border 210 */ 211 212 public final static short BORDER_MEDIUM_DASH_DOT = 0xA; 213 214 /** 215 * dash-dot-dot border 216 */ 217 218 public final static short BORDER_DASH_DOT_DOT = 0xB; 219 220 /** 221 * medium dash-dot-dot border 222 */ 223 224 public final static short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; 225 226 /** 227 * slanted dash-dot border 228 */ 229 230 public final static short BORDER_SLANTED_DASH_DOT = 0xD; 231 232 /** No background */ 233 public final static short NO_FILL = 0 ; 234 /** Solidly filled */ 235 public final static short SOLID_FOREGROUND = 1 ; 236 /** Small fine dots */ 237 public final static short FINE_DOTS = 2 ; 238 /** Wide dots */ 239 public final static short ALT_BARS = 3 ; 240 /** Sparse dots */ 241 public final static short SPARSE_DOTS = 4 ; 242 /** Thick horizontal bands */ 243 public final static short THICK_HORZ_BANDS = 5 ; 244 /** Thick vertical bands */ 245 public final static short THICK_VERT_BANDS = 6 ; 246 /** Thick backward facing diagonals */ 247 public final static short THICK_BACKWARD_DIAG = 7 ; 248 /** Thick forward facing diagonals */ 249 public final static short THICK_FORWARD_DIAG = 8 ; 250 /** Large spots */ 251 public final static short BIG_SPOTS = 9 ; 252 /** Brick-like layout */ 253 public final static short BRICKS = 10 ; 254 /** Thin horizontal bands */ 255 public final static short THIN_HORZ_BANDS = 11 ; 256 /** Thin vertical bands */ 257 public final static short THIN_VERT_BANDS = 12 ; 258 /** Thin backward diagonal */ 259 public final static short THIN_BACKWARD_DIAG = 13 ; 260 /** Thin forward diagonal */ 261 public final static short THIN_FORWARD_DIAG = 14 ; 262 /** Squares */ 263 public final static short SQUARES = 15 ; 264 /** Diamonds */ 265 public final static short DIAMONDS = 16 ; 266 267 268 /** Creates new HSSFCellStyle why would you want to do this?? */ 269 270 protected HSSFCellStyle(short index, ExtendedFormatRecord rec) 271 { 272 this.index = index; 273 format = rec; 274 } 275 276 /** 277 * get the index within the HSSFWorkbook (sequence within the collection of ExtnededFormat objects) 278 * @return unique index number of the underlying record this style represents (probably you don't care 279 * unless you're comparing which one is which) 280 */ 281 282 public short getIndex() 283 { 284 return index; 285 } 286 287 /** 288 * set the data format (only builtin formats are supported) 289 * @see org.apache.poi.hssf.usermodel.HSSFDataFormat 290 */ 291 292 public void setDataFormat(short fmt) 293 { 294 format.setFormatIndex(fmt); 295 } 296 297 /** 298 * get the index of the built in format 299 * @see org.apache.poi.hssf.usermodel.HSSFDataFormat 300 */ 301 302 public short getDataFormat() 303 { 304 return format.getFormatIndex(); 305 } 306 307 /** 308 * set the font for this style 309 * @param font a font object created or retreived from the HSSFWorkbook object 310 * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont() 311 * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) 312 */ 313 314 public void setFont(HSSFFont font) 315 { 316 format.setIndentNotParentFont(true); 317 fontindex = font.getIndex(); 318 format.setFontIndex(fontindex); 319 } 320 321 public short getFontIndex() 322 { 323 return format.getFontIndex(); 324 } 325 326 /** 327 * set the cell's using this style to be hidden 328 * @param hidden - whether the cell using this style should be hidden 329 */ 330 331 public void setHidden(boolean hidden) 332 { 333 format.setIndentNotParentCellOptions(true); 334 format.setHidden(hidden); 335 } 336 337 /** 338 * get whether the cell's using this style are to be hidden 339 * @return hidden - whether the cell using this style should be hidden 340 */ 341 342 public boolean getHidden() 343 { 344 return format.isHidden(); 345 } 346 347 /** 348 * set the cell's using this style to be locked 349 * @param locked - whether the cell using this style should be locked 350 */ 351 352 public void setLocked(boolean locked) 353 { 354 format.setIndentNotParentCellOptions(true); 355 format.setLocked(locked); 356 } 357 358 /** 359 * get whether the cell's using this style are to be locked 360 * @return hidden - whether the cell using this style should be locked 361 */ 362 363 public boolean getLocked() 364 { 365 return format.isLocked(); 366 } 367 368 /** 369 * set the type of horizontal alignment for the cell 370 * @param align - the type of alignment 371 * @see #ALIGN_GENERAL 372 * @see #ALIGN_LEFT 373 * @see #ALIGN_CENTER 374 * @see #ALIGN_RIGHT 375 * @see #ALIGN_FILL 376 * @see #ALIGN_JUSTIFY 377 * @see #ALIGN_CENTER_SELECTION 378 */ 379 380 public void setAlignment(short align) 381 { 382 format.setIndentNotParentAlignment(true); 383 format.setAlignment(align); 384 } 385 386 /** 387 * get the type of horizontal alignment for the cell 388 * @return align - the type of alignment 389 * @see #ALIGN_GENERAL 390 * @see #ALIGN_LEFT 391 * @see #ALIGN_CENTER 392 * @see #ALIGN_RIGHT 393 * @see #ALIGN_FILL 394 * @see #ALIGN_JUSTIFY 395 * @see #ALIGN_CENTER_SELECTION 396 */ 397 398 public short getAlignment() 399 { 400 return format.getAlignment(); 401 } 402 403 /** 404 * get whether this cell is to be part of a merged block of cells 405 * 406 * @returns merged or not 407 */ 408 409 // public boolean getMergeCells() 410 // { 411 // return format.getMergeCells(); 412 // } 413 414 /** 415 * set whether this cell is to be part of a merged block of cells 416 * 417 * @param merge merged or not 418 */ 419 420 // public void setMergeCells(boolean merge) 421 // { 422 // format.setMergeCells(merge); 423 // } 424 425 /** 426 * set whether the text should be wrapped 427 * @param wrapped wrap text or not 428 */ 429 430 public void setWrapText(boolean wrapped) 431 { 432 format.setIndentNotParentAlignment(true); 433 format.setWrapText(wrapped); 434 } 435 436 /** 437 * get whether the text should be wrapped 438 * @return wrap text or not 439 */ 440 441 public boolean getWrapText() 442 { 443 return format.getWrapText(); 444 } 445 446 /** 447 * set the type of vertical alignment for the cell 448 * @param align the type of alignment 449 * @see #VERTICAL_TOP 450 * @see #VERTICAL_CENTER 451 * @see #VERTICAL_BOTTOM 452 * @see #VERTICAL_JUSTIFY 453 */ 454 455 public void setVerticalAlignment(short align) 456 { 457 format.setVerticalAlignment(align); 458 } 459 460 /** 461 * get the type of vertical alignment for the cell 462 * @return align the type of alignment 463 * @see #VERTICAL_TOP 464 * @see #VERTICAL_CENTER 465 * @see #VERTICAL_BOTTOM 466 * @see #VERTICAL_JUSTIFY 467 */ 468 469 public short getVerticalAlignment() 470 { 471 return format.getVerticalAlignment(); 472 } 473 474 /** 475 * set the degree of rotation for the text in the cell 476 * @param rotation degrees 477 */ 478 479 public void setRotation(short rotation) 480 { 481 format.setRotation(rotation); 482 } 483 484 /** 485 * get the degree of rotation for the text in the cell 486 * @return rotation degrees 487 */ 488 489 public short getRotation() 490 { 491 return format.getRotation(); 492 } 493 494 /** 495 * set the number of spaces to indent the text in the cell 496 * @param indent - number of spaces 497 */ 498 499 public void setIndention(short indent) 500 { 501 format.setIndent(indent); 502 } 503 504 /** 505 * get the number of spaces to indent the text in the cell 506 * @return indent - number of spaces 507 */ 508 509 public short getIndention() 510 { 511 return format.getIndent(); 512 } 513 514 /** 515 * set the type of border to use for the left border of the cell 516 * @param border type 517 * @see #BORDER_NONE 518 * @see #BORDER_THIN 519 * @see #BORDER_MEDIUM 520 * @see #BORDER_DASHED 521 * @see #BORDER_DOTTED 522 * @see #BORDER_THICK 523 * @see #BORDER_DOUBLE 524 * @see #BORDER_HAIR 525 * @see #BORDER_MEDIUM_DASHED 526 * @see #BORDER_DASH_DOT 527 * @see #BORDER_MEDIUM_DASH_DOT 528 * @see #BORDER_DASH_DOT_DOT 529 * @see #BORDER_MEDIUM_DASH_DOT_DOT 530 * @see #BORDER_SLANTED_DASH_DOT 531 */ 532 533 public void setBorderLeft(short border) 534 { 535 format.setIndentNotParentBorder(true); 536 format.setBorderLeft(border); 537 } 538 539 /** 540 * get the type of border to use for the left border of the cell 541 * @return border type 542 * @see #BORDER_NONE 543 * @see #BORDER_THIN 544 * @see #BORDER_MEDIUM 545 * @see #BORDER_DASHED 546 * @see #BORDER_DOTTED 547 * @see #BORDER_THICK 548 * @see #BORDER_DOUBLE 549 * @see #BORDER_HAIR 550 * @see #BORDER_MEDIUM_DASHED 551 * @see #BORDER_DASH_DOT 552 * @see #BORDER_MEDIUM_DASH_DOT 553 * @see #BORDER_DASH_DOT_DOT 554 * @see #BORDER_MEDIUM_DASH_DOT_DOT 555 * @see #BORDER_SLANTED_DASH_DOT 556 */ 557 558 public short getBorderLeft() 559 { 560 return format.getBorderLeft(); 561 } 562 563 /** 564 * set the type of border to use for the right border of the cell 565 * @param border type 566 * @see #BORDER_NONE 567 * @see #BORDER_THIN 568 * @see #BORDER_MEDIUM 569 * @see #BORDER_DASHED 570 * @see #BORDER_DOTTED 571 * @see #BORDER_THICK 572 * @see #BORDER_DOUBLE 573 * @see #BORDER_HAIR 574 * @see #BORDER_MEDIUM_DASHED 575 * @see #BORDER_DASH_DOT 576 * @see #BORDER_MEDIUM_DASH_DOT 577 * @see #BORDER_DASH_DOT_DOT 578 * @see #BORDER_MEDIUM_DASH_DOT_DOT 579 * @see #BORDER_SLANTED_DASH_DOT 580 */ 581 582 public void setBorderRight(short border) 583 { 584 format.setIndentNotParentBorder(true); 585 format.setBorderRight(border); 586 } 587 588 /** 589 * get the type of border to use for the right border of the cell 590 * @return border type 591 * @see #BORDER_NONE 592 * @see #BORDER_THIN 593 * @see #BORDER_MEDIUM 594 * @see #BORDER_DASHED 595 * @see #BORDER_DOTTED 596 * @see #BORDER_THICK 597 * @see #BORDER_DOUBLE 598 * @see #BORDER_HAIR 599 * @see #BORDER_MEDIUM_DASHED 600 * @see #BORDER_DASH_DOT 601 * @see #BORDER_MEDIUM_DASH_DOT 602 * @see #BORDER_DASH_DOT_DOT 603 * @see #BORDER_MEDIUM_DASH_DOT_DOT 604 * @see #BORDER_SLANTED_DASH_DOT 605 */ 606 607 public short getBorderRight() 608 { 609 return format.getBorderRight(); 610 } 611 612 /** 613 * set the type of border to use for the top border of the cell 614 * @param border type 615 * @see #BORDER_NONE 616 * @see #BORDER_THIN 617 * @see #BORDER_MEDIUM 618 * @see #BORDER_DASHED 619 * @see #BORDER_DOTTED 620 * @see #BORDER_THICK 621 * @see #BORDER_DOUBLE 622 * @see #BORDER_HAIR 623 * @see #BORDER_MEDIUM_DASHED 624 * @see #BORDER_DASH_DOT 625 * @see #BORDER_MEDIUM_DASH_DOT 626 * @see #BORDER_DASH_DOT_DOT 627 * @see #BORDER_MEDIUM_DASH_DOT_DOT 628 * @see #BORDER_SLANTED_DASH_DOT 629 */ 630 631 public void setBorderTop(short border) 632 { 633 format.setIndentNotParentBorder(true); 634 format.setBorderTop(border); 635 } 636 637 /** 638 * get the type of border to use for the top border of the cell 639 * @return border type 640 * @see #BORDER_NONE 641 * @see #BORDER_THIN 642 * @see #BORDER_MEDIUM 643 * @see #BORDER_DASHED 644 * @see #BORDER_DOTTED 645 * @see #BORDER_THICK 646 * @see #BORDER_DOUBLE 647 * @see #BORDER_HAIR 648 * @see #BORDER_MEDIUM_DASHED 649 * @see #BORDER_DASH_DOT 650 * @see #BORDER_MEDIUM_DASH_DOT 651 * @see #BORDER_DASH_DOT_DOT 652 * @see #BORDER_MEDIUM_DASH_DOT_DOT 653 * @see #BORDER_SLANTED_DASH_DOT 654 */ 655 656 public short getBorderTop() 657 { 658 return format.getBorderTop(); 659 } 660 661 /** 662 * set the type of border to use for the bottom border of the cell 663 * @param border type 664 * @see #BORDER_NONE 665 * @see #BORDER_THIN 666 * @see #BORDER_MEDIUM 667 * @see #BORDER_DASHED 668 * @see #BORDER_DOTTED 669 * @see #BORDER_THICK 670 * @see #BORDER_DOUBLE 671 * @see #BORDER_HAIR 672 * @see #BORDER_MEDIUM_DASHED 673 * @see #BORDER_DASH_DOT 674 * @see #BORDER_MEDIUM_DASH_DOT 675 * @see #BORDER_DASH_DOT_DOT 676 * @see #BORDER_MEDIUM_DASH_DOT_DOT 677 * @see #BORDER_SLANTED_DASH_DOT 678 */ 679 680 public void setBorderBottom(short border) 681 { 682 format.setIndentNotParentBorder(true); 683 format.setBorderBottom(border); 684 } 685 686 /** 687 * get the type of border to use for the bottom border of the cell 688 * @return border type 689 * @see #BORDER_NONE 690 * @see #BORDER_THIN 691 * @see #BORDER_MEDIUM 692 * @see #BORDER_DASHED 693 * @see #BORDER_DOTTED 694 * @see #BORDER_THICK 695 * @see #BORDER_DOUBLE 696 * @see #BORDER_HAIR 697 * @see #BORDER_MEDIUM_DASHED 698 * @see #BORDER_DASH_DOT 699 * @see #BORDER_MEDIUM_DASH_DOT 700 * @see #BORDER_DASH_DOT_DOT 701 * @see #BORDER_MEDIUM_DASH_DOT_DOT 702 * @see #BORDER_SLANTED_DASH_DOT 703 */ 704 705 public short getBorderBottom() 706 { 707 return format.getBorderBottom(); 708 } 709 710 /** 711 * set the color to use for the left border 712 * @param color 713 */ 714 715 public void setLeftBorderColor(short color) 716 { 717 format.setLeftBorderPaletteIdx(color); 718 } 719 720 /** 721 * get the color to use for the left border 722 * @return color 723 */ 724 725 public short getLeftBorderColor() 726 { 727 return format.getLeftBorderPaletteIdx(); 728 } 729 730 /** 731 * set the color to use for the right border 732 * @param color 733 */ 734 735 public void setRightBorderColor(short color) 736 { 737 format.setRightBorderPaletteIdx(color); 738 } 739 740 /** 741 * get the color to use for the left border 742 * @return color 743 */ 744 745 public short getRightBorderColor() 746 { 747 return format.getRightBorderPaletteIdx(); 748 } 749 750 /** 751 * set the color to use for the top border 752 * @param color 753 */ 754 755 public void setTopBorderColor(short color) 756 { 757 format.setTopBorderPaletteIdx(color); 758 } 759 760 /** 761 * get the color to use for the top border 762 * @return color 763 */ 764 765 public short getTopBorderColor() 766 { 767 return format.getTopBorderPaletteIdx(); 768 } 769 770 /** 771 * set the color to use for the bottom border 772 * @param color 773 */ 774 775 public void setBottomBorderColor(short color) 776 { 777 format.setBottomBorderPaletteIdx(color); 778 } 779 780 /** 781 * get the color to use for the left border 782 * @return color 783 */ 784 785 public short getBottomBorderColor() 786 { 787 return format.getBottomBorderPaletteIdx(); 788 } 789 790 /** 791 * setting to one fills the cell with the foreground color... No idea about 792 * other values 793 * 794 * @see #NO_FILL 795 * @see #SOLID_FOREGROUND 796 * @see #FINE_DOTS 797 * @see #ALT_BARS 798 * @see #SPARSE_DOTS 799 * @see #THICK_HORZ_BANDS 800 * @see #THICK_VERT_BANDS 801 * @see #THICK_BACKWARD_DIAG 802 * @see #THICK_FORWARD_DIAG 803 * @see #BIG_SPOTS 804 * @see #BRICKS 805 * @see #THIN_HORZ_BANDS 806 * @see #THIN_VERT_BANDS 807 * @see #THIN_BACKWARD_DIAG 808 * @see #THIN_FORWARD_DIAG 809 * @see #SQUARES 810 * @see #DIAMONDS 811 * 812 * @param fp fill pattern (set to 1 to fill w/foreground color) 813 */ 814 public void setFillPattern(short fp) 815 { 816 format.setAdtlFillPattern(fp); 817 } 818 819 /** 820 * get the fill pattern (??) - set to 1 to fill with foreground color 821 * @return fill pattern 822 */ 823 824 public short getFillPattern() 825 { 826 return format.getAdtlFillPattern(); 827 } 828 829 /** 830 * set the background fill color. 831 * <p> 832 * For example: 833 * <pre> 834 * cs.setFillPattern(HSSFCellStyle.FINE_DOTS ); 835 * cs.setFillBackgroundColor(HSSFCellStyle.RED); 836 * </pre> 837 * or, for the special case of SOLID_FILL: 838 * <pre> 839 * cs.setFillPattern(HSSFCellStyle.SOLID_FILL ); 840 * cs.setFillForgroundColor(HSSFSeCellStyle.RED); 841 * </pre> 842 * It is necessary to set the fill style in order 843 * for the color to be shown in the cell. 844 * 845 * @param bg color 846 */ 847 848 public void setFillBackgroundColor(short bg) 849 { 850 format.setFillBackground(bg); 851 } 852 853 /** 854 * get the background fill color 855 * @return fill color 856 */ 857 858 public short getFillBackgroundColor() 859 { 860 return format.getFillBackground(); 861 } 862 863 /** 864 * set the foreground fill color 865 * @param bg color 866 */ 867 868 public void setFillForegroundColor(short bg) 869 { 870 format.setFillForeground(bg); 871 } 872 873 /** 874 * get the foreground fill color 875 * @return fill color 876 */ 877 878 public short getFillForegroundColor() 879 { 880 return format.getFillForeground(); 881 } 882 883 } 884