KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > WritableCellFormat


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.write.biff.CellXFRecord;
24 import jxl.format.Colour;
25 import jxl.format.Alignment;
26 import jxl.format.VerticalAlignment;
27 import jxl.format.Border;
28 import jxl.format.BorderLineStyle;
29 import jxl.format.Pattern;
30 import jxl.format.Orientation;
31 import jxl.format.CellFormat;
32
33
34 /**
35  * A user specified cell format, which may be reused across many cells.
36  * The constructors takes parameters, such as font details and the numerical
37  * date formats, which specify to Excel how cells with this format should be
38  * displayed.
39  * Once a CellFormat has been added to a Cell which has been added to
40  * a sheet, then the CellFormat becomes immutable (to prevent unforeseen
41  * effects on other cells which share the same format). Attempts to
42  * call the various set... functions on a WritableCellFormat after this
43  * time will result in a runtime exception.
44  */

45 public class WritableCellFormat extends CellXFRecord
46 {
47   /**
48    * A default constructor, which uses the default font and format.
49    * This constructor should be used in conjunction with the more
50    * advanced two-phase methods setAlignment, setBorder etc.
51    */

52   public WritableCellFormat()
53   {
54     this(WritableWorkbook.ARIAL_10_PT, NumberFormats.DEFAULT);
55   }
56
57   /**
58    * A CellFormat which specifies the font for cells with this format
59    *
60    * @param font the font
61    */

62   public WritableCellFormat(WritableFont font)
63   {
64     this(font, NumberFormats.DEFAULT);
65   }
66
67   /**
68    * A constructor which specifies a date/number format for Cells which
69    * use this format object
70    *
71    * @param format the format
72    */

73   public WritableCellFormat(DisplayFormat format)
74   {
75     this(WritableWorkbook.ARIAL_10_PT, format);
76   }
77
78   /**
79    * A constructor which specifies the font and date/number format for cells
80    * which wish to use this format
81    *
82    * @param font the font
83    * @param format the date/number format
84    */

85   public WritableCellFormat(WritableFont font, DisplayFormat format)
86   {
87     super(font, format);
88   }
89
90   /**
91    * A public copy constructor which can be used for copy formats between
92    * different sheets
93    * @param format the cell format to copy
94    */

95   public WritableCellFormat(CellFormat format)
96   {
97     super(format);
98   }
99
100   /**
101    * Sets the horizontal alignment for this format
102    *
103    * @param a the alignment
104    * @exception WriteException
105    */

106   public void setAlignment(Alignment a) throws WriteException
107   {
108     super.setAlignment(a);
109   }
110
111   /**
112    * Sets the vertical alignment for this format
113    *
114    * @param va the vertical alignment
115    * @exception WriteException
116    */

117   public void setVerticalAlignment(VerticalAlignment va) throws WriteException
118   {
119     super.setVerticalAlignment(va);
120   }
121
122   /**
123    * Sets the text orientation for this format
124    *
125    * @param o the orientation
126    * @exception WriteException
127    */

128   public void setOrientation(Orientation o) throws WriteException
129   {
130     super.setOrientation(o);
131   }
132
133   /**
134    * Sets the wrap indicator for this format. If the wrap is set to TRUE, then
135    * Excel will wrap data in cells with this format so that it fits within the
136    * cell boundaries
137    *
138    * @param w the wrap flag
139    * @exception jxl.write.WriteException
140    */

141   public void setWrap(boolean w) throws WriteException
142   {
143     super.setWrap(w);
144   }
145
146   /**
147    * Sets the specified border for this format
148    *
149    * @param b the border
150    * @param ls the border line style
151    * @exception jxl.write.WriteException
152    */

153   public void setBorder(Border b, BorderLineStyle ls) throws WriteException
154   {
155    super.setBorder(b, ls, Colour.BLACK);
156   }
157
158   /**
159    * Sets the specified border for this format
160    *
161    * @param b the border
162    * @param ls the border line style
163    * @param c the colour of the specified border
164    * @exception jxl.write.WriteException
165    */

166   public void setBorder(Border b, BorderLineStyle ls, Colour c)
167     throws WriteException
168   {
169     super.setBorder(b, ls, c);
170   }
171
172   /**
173    * Sets the background colour for this cell format
174    *
175    * @param c the bacground colour
176    * @exception jxl.write.WriteException
177    */

178   public void setBackground(Colour c) throws WriteException
179   {
180     this.setBackground(c, Pattern.SOLID);
181   }
182
183   /**
184    * Sets the background colour and pattern for this cell format
185    *
186    * @param c the colour
187    * @param p the pattern
188    * @exception jxl.write.WriteException
189    */

190   public void setBackground(Colour c, Pattern p) throws WriteException
191   {
192     super.setBackground(c, p);
193   }
194
195   /**
196    * Sets the shrink to fit flag
197    *
198    * @param s shrink to fit flag
199    * @exception WriteException
200    */

201   public void setShrinkToFit(boolean s) throws WriteException
202   {
203     super.setShrinkToFit(s);
204   }
205
206   /**
207    * Sets the indentation of the cell text
208    *
209    * @param i the indentation
210    */

211   public void setIndentation(int i) throws WriteException
212   {
213     super.setIndentation(i);
214   }
215
216
217   /**
218    * Sets whether or not this XF record locks the cell. For this to
219    * have any effect, the sheet containing cells with this format must
220    * also be locke3d
221    *
222    * @param l the locked flag
223    * @exception WriteException
224    */

225   public void setLocked(boolean l) throws WriteException
226   {
227     super.setLocked(l);
228   }
229
230 }
231
232
233
234
235
236
237
Popular Tags