KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > WritableSheet


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 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.Sheet;
23 import jxl.Range;
24 import jxl.CellView;
25 import jxl.format.CellFormat;
26 import jxl.format.PageOrientation;
27 import jxl.format.PaperSize;
28
29 import jxl.write.biff.RowsExceededException;
30
31 /**
32  * Interface for a worksheet that may be modified. The most
33  * important modification for a sheet is to have cells added to it
34  */

35 public interface WritableSheet extends Sheet
36 {
37   /**
38    * Adds a cell to this sheet
39    * The RowsExceededException may be caught if client code wishes to
40    * explicitly trap the case where too many rows have been written
41    * to the current sheet. If this behaviour is not desired, it is
42    * sufficient simply to handle the WriteException, since this is a base
43    * class of RowsExceededException
44    *
45    * @param cell the cell to add
46    * @exception jxl.write..WriteException
47    * @exception jxl.write.biff.RowsExceededException
48    */

49   public void addCell(WritableCell cell)
50     throws WriteException, RowsExceededException;
51   /**
52    * Sets the name of this sheet
53    *
54    * @param name the name of the sheet
55    */

56   public void setName(String JavaDoc name);
57   /**
58    * Indicates whether or not this sheet is hidden
59    *
60    * @param hidden hidden flag
61    * @deprecated use the SheetSettings bean instead
62    */

63   public void setHidden(boolean hidden);
64   /**
65    * Indicates whether or not this sheet is protected
66    *
67    * @param prot Protected flag
68    * @deprecated use the SheetSettings bean instead
69    */

70   public void setProtected(boolean prot);
71
72   /**
73    * Sets the width of the column on this sheet, in characters. This causes
74    * Excel to resize the entire column.
75    * If the columns specified already has view information associated
76    * with it, then it is replaced by the new data
77    *
78    * @param col the column to be formatted
79    * @param width the width of the column
80    */

81   public void setColumnView(int col, int width);
82
83   /**
84    * Sets the width and style of every cell in the specified column.
85    * If the columns specified already has view information associated
86    * with it, then it is replaced by the new data
87    *
88    * @param col the column to be formatted
89    * @param format the format of every cell in the column
90    * @param width the width of the column, in characters
91    * @deprecated Use the CellView bean instead
92    */

93   public void setColumnView(int col, int width, CellFormat format);
94
95   /**
96    * Sets the view for this column
97    *
98    * @param col the column on which to set the view
99    * @param view the view to set
100    */

101   public void setColumnView(int col, CellView view);
102
103   /**
104    * Sets the height of the specified row, as well as its collapse status
105    *
106    * @param row the row to be formatted
107    * @param height the row height in characters
108    * @exception jxl.write.biff.RowsExceededException
109    */

110   public void setRowView(int row, int height)
111     throws RowsExceededException;
112
113   /**
114    * Sets the properties of the specified row
115    *
116    * @param row the row to be formatted
117    * @param collapsed indicates whether the row is collapsed
118    * @exception jxl.write.biff.RowsExceededException
119    */

120   public void setRowView(int row, boolean collapsed)
121     throws RowsExceededException;
122
123   /**
124    * Sets the height of the specified row, as well as its collapse status
125    *
126    * @param row the row to be formatted
127    * @param height the row height in characters
128    * @param collapsed indicates whether the row is collapsed
129    * @exception jxl.write.biff.RowsExceededException
130    */

131   public void setRowView(int row, int height,
132                          boolean collapsed)
133                          throws RowsExceededException;
134
135   /**
136    * Gets the writable cell from this sheet. Use of this method allows
137    * the returned cell to be modified by the users application
138    *
139    * @param column the column
140    * @param row the row
141    * @return the cell at the specified position
142    */

143   public WritableCell getWritableCell(int column, int row);
144
145   /**
146    * Gets the writable hyperlinks from this sheet. The hyperlinks
147    * that are returned may be modified by user applications
148    *
149    * @return the writable hyperlinks
150    */

151   public WritableHyperlink[] getWritableHyperlinks();
152
153   /**
154    * Inserts a blank row into this spreadsheet. If the row is out of range
155    * of the rows in the sheet, then no action is taken
156    *
157    * @param row the row to insert
158    */

159   public void insertRow(int row);
160
161   /**
162    * Inserts a blank column into this spreadsheet. If the column is out of
163    * range of the columns in the sheet, then no action is taken
164    *
165    * @param col the column to insert
166    */

167   public void insertColumn(int col);
168
169   /**
170    * Removes a column from this spreadsheet. If the column is out of range
171    * of the columns in the sheet, then no action is taken
172    *
173    * @param col the column to remove
174    */

175   public void removeColumn(int col);
176
177   /**
178    * Removes a row from this spreadsheet. If the row is out of
179    * range of the columns in the sheet, then no action is taken
180    *
181    * @param row the row to remove
182    */

183   public void removeRow(int row);
184
185   /**
186    * Merges the specified cells. Any clashes or intersections between
187    * merged cells are resolved when the spreadsheet is written out
188    *
189    * @param col1 the column number of the top left cell
190    * @param row1 the row number of the top left cell
191    * @param col2 the column number of the bottom right cell
192    * @param row2 the row number of the bottom right cell
193    * @return the Range object representing the merged cells
194    * @exception jxl.write..WriteException
195    * @exception jxl.write.biff.RowsExceededException
196    */

197   public Range mergeCells(int col1, int row1, int col2, int row2)
198     throws WriteException, RowsExceededException;
199
200   /**
201    * Unmerges the specified cells. The Range passed in should be one that
202    * has been previously returned as a result of the getMergedCells method
203    *
204    * @param r the range of cells to unmerge
205    */

206   public void unmergeCells(Range r);
207
208   /**
209    * Adds the specified hyperlink. Adding a hyperlink causes any populated
210    * cells in the range of the hyperlink to be set to empty
211    * If the cells which activate this hyperlink clash with any other cells,
212    * they are still added to the worksheet and it is left to Excel to
213    * handle this.
214    *
215    * @param h the hyperlink
216    * @exception jxl.write..WriteException
217    * @exception jxl.write.biff.RowsExceededException
218    */

219   public void addHyperlink(WritableHyperlink h)
220     throws WriteException, RowsExceededException;;
221
222   /**
223    * Removes the specified hyperlink. Note that if you merely set the
224    * cell contents to be an Empty cell, then the cells containing the
225    * hyperlink will still be active. The contents of the cell which
226    * activate the hyperlink are removed.
227    * The hyperlink passed in must be a hyperlink retrieved using the
228    * getHyperlinks method
229    *
230    * @param h the hyperlink to remove.
231    */

232   public void removeHyperlink(WritableHyperlink h);
233
234   /**
235    * Removes the specified hyperlink. Note that if you merely set the
236    * cell contents to be an Empty cell, then the cells containing the
237    * hyperlink will still be active.
238    * If the preserveLabel field is set, the cell contents of the
239    * hyperlink are preserved, although the hyperlink is deactivated. If
240    * this value is FALSE, the cell contents are removed
241    * The hyperlink passed in must be a hyperlink retrieved using the
242    * getHyperlinks method
243    *
244    * @param h the hyperlink to remove.
245    * @param preserveLabel if TRUE preserves the label contents, if FALSE
246    * removes them
247    */

248   public void removeHyperlink(WritableHyperlink h, boolean preserveLabel);
249
250   /**
251    * Sets the header for this page
252    *
253    * @param l the print header to print on the left side
254    * @param c the print header to print in the centre
255    * @param r the print header to print on the right hand side
256    * @deprecated use the SheetSettings bean
257    */

258   public void setHeader(String JavaDoc l, String JavaDoc c, String JavaDoc r);
259
260   /**
261    * Sets the footer for this page
262    *
263    * @param l the print header to print on the left side
264    * @param c the print header to print in the centre
265    * @param r the print header to print on the right hand side
266    * @deprecated use the SheetSettings bean
267    */

268   public void setFooter(String JavaDoc l, String JavaDoc c, String JavaDoc r);
269
270   /**
271    * Sets the page setup details
272    *
273    * @param p the page orientation
274    */

275   public void setPageSetup(PageOrientation p);
276
277   /**
278    * Sets the page setup details
279    *
280    * @param p the page orientation
281    * @param hm the header margin, in inches
282    * @param fm the footer margin, in inches
283    */

284   public void setPageSetup(PageOrientation p, double hm, double fm);
285
286   /**
287    * Sets the page setup details
288    *
289    * @param p the page orientation
290    * @param ps the paper size
291    * @param hm the header margin, in inches
292    * @param fm the footer margin, in inches
293    */

294   public void setPageSetup(PageOrientation p, PaperSize ps,
295                            double hm, double fm);
296
297   /**
298    * Forces a page break at the specified row
299    *
300    * @param row the row to break at
301    */

302   public void addRowPageBreak(int row);
303
304   /**
305    * Adds an image to the sheet
306    *
307    * @param image the image to add
308    */

309   public void addImage(WritableImage image);
310
311   /**
312    * Accessor for the number of images on the sheet
313    *
314    * @return the number of images on this sheet
315    */

316   public int getNumberOfImages();
317
318   /**
319    * Accessor for the image
320    *
321    * @param i the 0 based image number
322    * @return the image at the specified position
323    */

324   public WritableImage getImage(int i);
325
326   /**
327    * Removes the specified image from the sheet. The image passed in
328    * must be the same instance as that previously retrieved using the
329    * getImage() method
330    *
331    * @param wi the image to remove
332    */

333   public void removeImage(WritableImage wi);
334 }
335
336
337
Popular Tags