Save This Page
Home » jexcelapi_2_6_8 » jxl.write » [javadoc | source]
    1   /*********************************************************************
    2   *
    3   *      Copyright (C) 2001 Andrew Khan
    4   *
    5   * This library is free software; you can redistribute it and/or
    6   * modify it under the terms of the GNU Lesser General Public
    7   * License as published by the Free Software Foundation; either
    8   * version 2.1 of the License, or (at your option) any later version.
    9   *
   10   * This library is distributed in the hope that it will be useful,
   11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13   * Lesser General Public License for more details.
   14   *
   15   * You should have received a copy of the GNU Lesser General Public
   16   * License along with this library; if not, write to the Free Software
   17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   18   ***************************************************************************/
   19   
   20   package jxl.write;
   21   
   22   import jxl.biff.DisplayFormat;
   23   import jxl.format.Alignment;
   24   import jxl.format.Border;
   25   import jxl.format.BorderLineStyle;
   26   import jxl.format.CellFormat;
   27   import jxl.format.Colour;
   28   import jxl.format.Orientation;
   29   import jxl.format.Pattern;
   30   import jxl.format.VerticalAlignment;
   31   import jxl.write.biff.CellXFRecord;
   32   
   33   /**
   34    * A user specified cell format, which may be reused across many cells.
   35    * The constructors takes parameters, such as font details and the numerical
   36    * date formats, which specify to Excel how cells with this format should be
   37    * displayed.
   38    * Once a CellFormat has been added to a Cell which has been added to
   39    * a sheet, then the CellFormat becomes immutable (to prevent unforeseen
   40    * effects on other cells which share the same format).  Attempts to
   41    * call the various set... functions on a WritableCellFormat after this
   42    * time will result in a runtime exception.
   43    */
   44   public class WritableCellFormat extends CellXFRecord
   45   {
   46     /**
   47      * A default constructor, which uses the default font and format.
   48      * This constructor should be used in conjunction with the more
   49      * advanced two-phase methods setAlignment, setBorder etc.
   50      */
   51     public WritableCellFormat()
   52     {
   53       this(WritableWorkbook.ARIAL_10_PT, NumberFormats.DEFAULT);
   54     }
   55   
   56     /**
   57      * A CellFormat which specifies the font for cells with this format
   58      *
   59      * @param font the font
   60      */
   61     public WritableCellFormat(WritableFont font)
   62     {
   63       this(font, NumberFormats.DEFAULT);
   64     }
   65   
   66     /**
   67      * A constructor which specifies a date/number format for Cells which
   68      * use this format object
   69      *
   70      * @param format the format
   71      */
   72     public WritableCellFormat(DisplayFormat format)
   73     {
   74       this(WritableWorkbook.ARIAL_10_PT, format);
   75     }
   76   
   77     /**
   78      * A constructor which specifies the font and date/number format for cells
   79      * which wish to use this format
   80      *
   81      * @param font the font
   82      * @param format the date/number format
   83      */
   84     public WritableCellFormat(WritableFont font, DisplayFormat format)
   85     {
   86       super(font, format);
   87     }
   88   
   89     /**
   90      * A public copy constructor which can be used for copy formats between
   91      * different sheets
   92      * @param format the cell format to copy
   93      */
   94     public WritableCellFormat(CellFormat format)
   95     {
   96       super(format);
   97     }
   98   
   99     /**
  100      * Sets the horizontal alignment for this format
  101      *
  102      * @param a the alignment
  103      * @exception WriteException
  104      */
  105     public void setAlignment(Alignment a) throws WriteException
  106     {
  107       super.setAlignment(a);
  108     }
  109   
  110     /**
  111      * Sets the vertical alignment for this format
  112      *
  113      * @param va the vertical alignment
  114      * @exception WriteException
  115      */
  116     public void setVerticalAlignment(VerticalAlignment va) throws WriteException
  117     {
  118       super.setVerticalAlignment(va);
  119     }
  120   
  121     /**
  122      * Sets the text orientation for this format
  123      *
  124      * @param o the orientation
  125      * @exception WriteException
  126      */
  127     public void setOrientation(Orientation o) throws WriteException
  128     {
  129       super.setOrientation(o);
  130     }
  131   
  132     /**
  133      * Sets the wrap indicator for this format.  If the wrap is set to TRUE, then
  134      * Excel will wrap data in cells with this format so that it fits within the
  135      * cell boundaries
  136      *
  137      * @param w the wrap flag
  138      * @exception jxl.write.WriteException
  139      */
  140     public void setWrap(boolean w) throws WriteException
  141     {
  142       super.setWrap(w);
  143     }
  144   
  145     /**
  146      * Sets the specified border for this format
  147      *
  148      * @param b the border
  149      * @param ls the border line style
  150      * @exception jxl.write.WriteException
  151      */
  152     public void setBorder(Border b, BorderLineStyle ls) throws WriteException
  153     {
  154      super.setBorder(b, ls, Colour.BLACK);
  155     }
  156   
  157     /**
  158      * Sets the specified border for this format
  159      *
  160      * @param b the border
  161      * @param ls the border line style
  162      * @param c the colour of the specified border
  163      * @exception jxl.write.WriteException
  164      */
  165     public void setBorder(Border b, BorderLineStyle ls, Colour c)
  166       throws WriteException
  167     {
  168       super.setBorder(b, ls, c);
  169     }
  170   
  171     /**
  172      * Sets the background colour for this cell format
  173      *
  174      * @param c the bacground colour
  175      * @exception jxl.write.WriteException
  176      */
  177     public void setBackground(Colour c) throws WriteException
  178     {
  179       this.setBackground(c, Pattern.SOLID);
  180     }
  181   
  182     /**
  183      * Sets the background colour and pattern for this cell format
  184      *
  185      * @param c the colour
  186      * @param p the pattern
  187      * @exception jxl.write.WriteException
  188      */
  189     public void setBackground(Colour c, Pattern p) throws WriteException
  190     {
  191       super.setBackground(c, p);
  192     }
  193   
  194     /**
  195      * Sets the shrink to fit flag
  196      *
  197      * @param s shrink to fit flag
  198      * @exception WriteException
  199      */
  200     public void setShrinkToFit(boolean s) throws WriteException
  201     {
  202       super.setShrinkToFit(s);
  203     }
  204   
  205     /**
  206      * Sets the indentation of the cell text
  207      *
  208      * @param i the indentation
  209      */
  210     public void setIndentation(int i) throws WriteException
  211     {
  212       super.setIndentation(i);
  213     }
  214   
  215   
  216     /**
  217      * Sets whether or not this XF record locks the cell.  For this to
  218      * have any effect, the sheet containing cells with this format must
  219      * also be locke3d
  220      *
  221      * @param l the locked flag
  222      * @exception WriteException
  223      */
  224     public void setLocked(boolean l) throws WriteException
  225     {
  226       super.setLocked(l);
  227     }
  228   
  229   }
  230   
  231   
  232   
  233   
  234   
  235   

Save This Page
Home » jexcelapi_2_6_8 » jxl.write » [javadoc | source]