Lines 30-38
Link Here
|
30 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment; |
30 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment; |
31 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellProtection; |
31 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellProtection; |
32 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf; |
32 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf; |
33 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; |
|
|
34 |
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType; |
35 |
|
33 |
|
|
|
34 |
/** |
35 |
* |
36 |
* High level representation of the style of a cell in a sheet of a workbook. |
37 |
* |
38 |
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createCellStyle() |
39 |
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getCellStyleAt(short) |
40 |
* @see org.apache.poi.xssf.usermodel.XSSFCell#setCellStyle(XSSFCellStyle) |
41 |
*/ |
36 |
|
42 |
|
37 |
public class XSSFCellStyle implements CellStyle { |
43 |
public class XSSFCellStyle implements CellStyle { |
38 |
|
44 |
|
Lines 66-71
Link Here
|
66 |
public CTXf getCoreXf() { |
72 |
public CTXf getCoreXf() { |
67 |
return cellXf; |
73 |
return cellXf; |
68 |
} |
74 |
} |
|
|
75 |
|
69 |
/** |
76 |
/** |
70 |
* Used so that StylesSource can figure out our location |
77 |
* Used so that StylesSource can figure out our location |
71 |
*/ |
78 |
*/ |
Lines 117-430
Link Here
|
117 |
} |
124 |
} |
118 |
throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle"); |
125 |
throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle"); |
119 |
} |
126 |
} |
|
|
127 |
|
120 |
public void cloneStyleFrom(XSSFCellStyle source) { |
128 |
public void cloneStyleFrom(XSSFCellStyle source) { |
121 |
throw new IllegalStateException("TODO"); |
129 |
throw new IllegalStateException("TODO"); |
122 |
} |
130 |
} |
123 |
|
131 |
|
|
|
132 |
/** |
133 |
* get the type of horizontal alignment for the cell |
134 |
* @see #ALIGN_GENERAL |
135 |
* @see #ALIGN_LEFT |
136 |
* @see #ALIGN_CENTER |
137 |
* @see #ALIGN_RIGHT |
138 |
* @see #ALIGN_FILL |
139 |
* @see #ALIGN_JUSTIFY |
140 |
* @see #ALIGN_CENTER_SELECTION |
141 |
* @return short - the type of alignment |
142 |
*/ |
124 |
public short getAlignment() { |
143 |
public short getAlignment() { |
125 |
return (short)(getAlignmentEnum().ordinal()); |
144 |
return (short)(getAlignmentEnum().ordinal()); |
126 |
} |
145 |
} |
127 |
|
146 |
|
|
|
147 |
/** |
148 |
* get the type of horizontal alignment for the cell |
149 |
* @return HorizontalAlignment - the type of alignment |
150 |
*/ |
128 |
public HorizontalAlignment getAlignmentEnum() { |
151 |
public HorizontalAlignment getAlignmentEnum() { |
129 |
return getCellAlignment().getHorizontal(); |
152 |
return getCellAlignment().getHorizontal(); |
130 |
} |
153 |
} |
131 |
|
154 |
|
|
|
155 |
/** |
156 |
* get the type of border to use for the bottom border of the cell |
157 |
* @return short - border type |
158 |
* @see #BORDER_NONE |
159 |
* @see #BORDER_THIN |
160 |
* @see #BORDER_MEDIUM |
161 |
* @see #BORDER_DASHED |
162 |
* @see #BORDER_DOTTED |
163 |
* @see #BORDER_THICK |
164 |
* @see #BORDER_DOUBLE |
165 |
* @see #BORDER_HAIR |
166 |
* @see #BORDER_MEDIUM_DASHED |
167 |
* @see #BORDER_DASH_DOT |
168 |
* @see #BORDER_MEDIUM_DASH_DOT |
169 |
* @see #BORDER_DASH_DOT_DOT |
170 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
171 |
* @see #BORDER_SLANTED_DASH_DOT |
172 |
*/ |
132 |
public short getBorderBottom() { |
173 |
public short getBorderBottom() { |
133 |
return getBorderStyleAsShort(BorderSide.BOTTOM); |
174 |
return (short) (getBorderStyleEnum(BorderSide.BOTTOM).ordinal()); |
134 |
} |
175 |
} |
135 |
|
176 |
|
|
|
177 |
/** |
178 |
* get the type of border to use for the bottom border of the cell as String |
179 |
* @return String - border type as string |
180 |
*/ |
136 |
public String getBorderBottomAsString() { |
181 |
public String getBorderBottomAsString() { |
137 |
return getBorderStyleAsString(BorderSide.BOTTOM); |
182 |
return getBorderStyleAsString(BorderSide.BOTTOM); |
138 |
} |
183 |
} |
139 |
|
184 |
|
|
|
185 |
/** |
186 |
* get the type of border to use for the bottom border of the cell |
187 |
* @return BoerderStyle - border type as string |
188 |
*/ |
189 |
public BorderStyle getBorderBottomEnum() { |
190 |
return getBorderStyleEnum(BorderSide.BOTTOM); |
191 |
} |
192 |
|
193 |
/** |
194 |
* get the type of border to use for the left border of the cell |
195 |
* @return short - border type |
196 |
* @see #BORDER_NONE |
197 |
* @see #BORDER_THIN |
198 |
* @see #BORDER_MEDIUM |
199 |
* @see #BORDER_DASHED |
200 |
* @see #BORDER_DOTTED |
201 |
* @see #BORDER_THICK |
202 |
* @see #BORDER_DOUBLE |
203 |
* @see #BORDER_HAIR |
204 |
* @see #BORDER_MEDIUM_DASHED |
205 |
* @see #BORDER_DASH_DOT |
206 |
* @see #BORDER_MEDIUM_DASH_DOT |
207 |
* @see #BORDER_DASH_DOT_DOT |
208 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
209 |
* @see #BORDER_SLANTED_DASH_DOT |
210 |
*/ |
140 |
public short getBorderLeft() { |
211 |
public short getBorderLeft() { |
141 |
return getBorderStyleAsShort(BorderSide.LEFT); |
212 |
return (short) (getBorderStyleEnum(BorderSide.LEFT).ordinal()); |
142 |
} |
213 |
} |
143 |
|
214 |
|
|
|
215 |
/** |
216 |
* get the type of border to use for the left border of the cell as String |
217 |
* @return String - border type as string |
218 |
*/ |
144 |
public String getBorderLeftAsString() { |
219 |
public String getBorderLeftAsString() { |
145 |
return getBorderStyleAsString(BorderSide.LEFT); |
220 |
return getBorderStyleAsString(BorderSide.LEFT); |
146 |
} |
221 |
} |
147 |
|
222 |
|
|
|
223 |
/** |
224 |
* get the type of border to use for the left border of the cell |
225 |
* @return BoerderStyle - border type as string |
226 |
*/ |
227 |
public BorderStyle getBorderLeftEnum() { |
228 |
return getBorderStyleEnum(BorderSide.LEFT); |
229 |
} |
230 |
|
231 |
/** |
232 |
* get the type of border to use for the right border of the cell |
233 |
* @return short - border type |
234 |
* @see #BORDER_NONE |
235 |
* @see #BORDER_THIN |
236 |
* @see #BORDER_MEDIUM |
237 |
* @see #BORDER_DASHED |
238 |
* @see #BORDER_DOTTED |
239 |
* @see #BORDER_THICK |
240 |
* @see #BORDER_DOUBLE |
241 |
* @see #BORDER_HAIR |
242 |
* @see #BORDER_MEDIUM_DASHED |
243 |
* @see #BORDER_DASH_DOT |
244 |
* @see #BORDER_MEDIUM_DASH_DOT |
245 |
* @see #BORDER_DASH_DOT_DOT |
246 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
247 |
* @see #BORDER_SLANTED_DASH_DOT |
248 |
*/ |
148 |
public short getBorderRight() { |
249 |
public short getBorderRight() { |
149 |
return getBorderStyleAsShort(BorderSide.RIGHT); |
250 |
return (short) (getBorderStyleEnum(BorderSide.RIGHT).ordinal()); |
150 |
} |
251 |
} |
151 |
|
252 |
|
|
|
253 |
/** |
254 |
* get the type of border to use for the right border of the cell as String |
255 |
* @return String - border type as string |
256 |
*/ |
152 |
public String getBorderRightAsString() { |
257 |
public String getBorderRightAsString() { |
153 |
return getBorderStyleAsString(BorderSide.RIGHT); |
258 |
return getBorderStyleAsString(BorderSide.RIGHT); |
154 |
} |
259 |
} |
155 |
|
260 |
|
|
|
261 |
/** |
262 |
* get the type of border to use for the right border of the cell |
263 |
* @return BoerderStyle - border type as string |
264 |
*/ |
265 |
public BorderStyle getBorderRightEnum() { |
266 |
return getBorderStyleEnum(BorderSide.RIGHT); |
267 |
} |
268 |
|
269 |
/** |
270 |
* get the type of border to use for the top border of the cell |
271 |
* @return short - border type |
272 |
* @see #BORDER_NONE |
273 |
* @see #BORDER_THIN |
274 |
* @see #BORDER_MEDIUM |
275 |
* @see #BORDER_DASHED |
276 |
* @see #BORDER_DOTTED |
277 |
* @see #BORDER_THICK |
278 |
* @see #BORDER_DOUBLE |
279 |
* @see #BORDER_HAIR |
280 |
* @see #BORDER_MEDIUM_DASHED |
281 |
* @see #BORDER_DASH_DOT |
282 |
* @see #BORDER_MEDIUM_DASH_DOT |
283 |
* @see #BORDER_DASH_DOT_DOT |
284 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
285 |
* @see #BORDER_SLANTED_DASH_DOT |
286 |
*/ |
156 |
public short getBorderTop() { |
287 |
public short getBorderTop() { |
157 |
return getBorderStyleAsShort(BorderSide.TOP); |
288 |
return (short) (getBorderStyleEnum(BorderSide.TOP).ordinal()); |
158 |
} |
289 |
} |
159 |
|
290 |
|
|
|
291 |
/** |
292 |
* get the type of border to use for the top border of the cell as String |
293 |
* @return String - border type as string |
294 |
*/ |
160 |
public String getBorderTopAsString() { |
295 |
public String getBorderTopAsString() { |
161 |
return getBorderStyleAsString(BorderSide.TOP); |
296 |
return getBorderStyleAsString(BorderSide.TOP); |
162 |
} |
297 |
} |
|
|
298 |
|
299 |
/** |
300 |
* get the type of border to use for the top border of the cell |
301 |
* @return BoerderStyle - border type as string |
302 |
*/ |
303 |
public BorderStyle getBorderTopEnum() { |
304 |
return getBorderStyleEnum(BorderSide.TOP); |
305 |
} |
163 |
|
306 |
|
|
|
307 |
/** |
308 |
* set the color to use for the bottom border |
309 |
* Color is optional. When missing, IndexedColors.AUTOMATIC is implied. |
310 |
* @return short - color The index of the color definition |
311 |
* @see IndexedColors |
312 |
*/ |
164 |
public short getBottomBorderColor() { |
313 |
public short getBottomBorderColor() { |
165 |
return getBorderColorIndexed(BorderSide.BOTTOM); |
314 |
return getBorderColorIndexed(BorderSide.BOTTOM); |
166 |
} |
315 |
} |
167 |
|
316 |
|
|
|
317 |
/** |
318 |
* get the index of the number format (numFmt) record used by this cell format. |
319 |
*/ |
168 |
public short getDataFormat() { |
320 |
public short getDataFormat() { |
169 |
return (short)cellXf.getNumFmtId(); |
321 |
return (short)cellXf.getNumFmtId(); |
170 |
} |
322 |
} |
|
|
323 |
|
324 |
/** |
325 |
* Get the contents of the format string, by looking up |
326 |
* the StylesSource |
327 |
* |
328 |
* @return the number format string |
329 |
*/ |
171 |
public String getDataFormatString() { |
330 |
public String getDataFormatString() { |
172 |
return stylesSource.getNumberFormatAt(getDataFormat()); |
331 |
return stylesSource.getNumberFormatAt(getDataFormat()); |
173 |
} |
332 |
} |
174 |
|
333 |
|
|
|
334 |
/** |
335 |
* Get the background fill color. |
336 |
* Note - many cells are actually filled with a foreground |
337 |
* fill, not a background fill - see {@link #getFillForegroundColor()} |
338 |
* @see IndexedColors |
339 |
* @return short - fill color |
340 |
*/ |
175 |
public short getFillBackgroundColor() { |
341 |
public short getFillBackgroundColor() { |
176 |
return (short) getCellFill().getFillBackgroundColor().getIndexed(); |
342 |
return (short) getCellFill().getFillBackgroundColor().getIndexed(); |
177 |
} |
343 |
} |
178 |
|
344 |
|
|
|
345 |
/** |
346 |
* Get the background fill color. |
347 |
* Note - many cells are actually filled with a foreground |
348 |
* fill, not a background fill - see {@link #getFillForegroundColor()} |
349 |
* @see org.apache.poi.hssf.usermodel.XSSFColor#getRgb() |
350 |
* @return XSSFColor - fill color |
351 |
*/ |
179 |
public XSSFColor getFillBackgroundRgbColor() { |
352 |
public XSSFColor getFillBackgroundRgbColor() { |
180 |
return getCellFill().getFillBackgroundColor(); |
353 |
return getCellFill().getFillBackgroundColor(); |
181 |
} |
354 |
} |
182 |
|
355 |
|
|
|
356 |
/** |
357 |
* Get the foreground fill color. |
358 |
* Many cells are filled with this, instead of a |
359 |
* background color ({@link #getFillBackgroundColor()}) |
360 |
* @see IndexedColors |
361 |
* @return short - fill color |
362 |
*/ |
183 |
public short getFillForegroundColor() { |
363 |
public short getFillForegroundColor() { |
184 |
return (short) getCellFill().getFillForegroundColor().getIndexed(); |
364 |
return (short) getCellFill().getFillForegroundColor().getIndexed(); |
185 |
} |
365 |
} |
186 |
|
366 |
|
|
|
367 |
/** |
368 |
* Get the foreground fill color. |
369 |
* Many cells are filled with this, instead of a |
370 |
* background color ({@link #getFillBackgroundColor()}) |
371 |
* @return XSSFColor - fill color |
372 |
*/ |
187 |
public XSSFColor getFillForegroundRgbColor() { |
373 |
public XSSFColor getFillForegroundRgbColor() { |
188 |
return getCellFill().getFillForegroundColor(); |
374 |
return getCellFill().getFillForegroundColor(); |
189 |
} |
375 |
} |
190 |
|
376 |
|
|
|
377 |
/** |
378 |
* get the fill pattern |
379 |
* @return short - fill pattern |
380 |
* |
381 |
* @see #NO_FILL |
382 |
* @see #SOLID_FOREGROUND |
383 |
* @see #FINE_DOTS |
384 |
* @see #ALT_BARS |
385 |
* @see #SPARSE_DOTS |
386 |
* @see #THICK_HORZ_BANDS |
387 |
* @see #THICK_VERT_BANDS |
388 |
* @see #THICK_BACKWARD_DIAG |
389 |
* @see #THICK_FORWARD_DIAG |
390 |
* @see #BIG_SPOTS |
391 |
* @see #BRICKS |
392 |
* @see #THIN_HORZ_BANDS |
393 |
* @see #THIN_VERT_BANDS |
394 |
* @see #THIN_BACKWARD_DIAG |
395 |
* @see #THIN_FORWARD_DIAG |
396 |
* @see #SQUARES |
397 |
* @see #DIAMONDS |
398 |
*/ |
191 |
public short getFillPattern() { |
399 |
public short getFillPattern() { |
192 |
int fp= getCellFill().getPatternType().intValue(); |
400 |
return (short) getCellFill().getPatternType().ordinal(); |
193 |
switch (fp) { |
|
|
194 |
case STPatternType.INT_NONE: |
195 |
return CellStyle.NO_FILL; |
196 |
case STPatternType.INT_SOLID: |
197 |
return CellStyle.SOLID_FOREGROUND; |
198 |
case STPatternType.INT_LIGHT_GRAY: |
199 |
return CellStyle.FINE_DOTS; |
200 |
case STPatternType.INT_DARK_GRID: |
201 |
return CellStyle.ALT_BARS; |
202 |
case STPatternType.INT_DARK_GRAY: |
203 |
return CellStyle.SPARSE_DOTS; |
204 |
case STPatternType.INT_DARK_HORIZONTAL: |
205 |
return CellStyle.THICK_HORZ_BANDS; |
206 |
case STPatternType.INT_DARK_VERTICAL: |
207 |
return CellStyle.THICK_VERT_BANDS; |
208 |
case STPatternType.INT_DARK_UP: |
209 |
return CellStyle.THICK_BACKWARD_DIAG; |
210 |
case STPatternType.INT_DARK_DOWN: |
211 |
return CellStyle.THICK_FORWARD_DIAG; |
212 |
case STPatternType.INT_GRAY_0625: |
213 |
return CellStyle.BIG_SPOTS; |
214 |
case STPatternType.INT_DARK_TRELLIS: |
215 |
return CellStyle.BRICKS; |
216 |
case STPatternType.INT_LIGHT_HORIZONTAL: |
217 |
return CellStyle.THIN_HORZ_BANDS; |
218 |
case STPatternType.INT_LIGHT_VERTICAL: |
219 |
return CellStyle.THIN_VERT_BANDS; |
220 |
case STPatternType.INT_LIGHT_UP: |
221 |
return CellStyle.THIN_BACKWARD_DIAG; |
222 |
case STPatternType.INT_LIGHT_DOWN: |
223 |
return CellStyle.THIN_FORWARD_DIAG; |
224 |
case STPatternType.INT_LIGHT_GRID: |
225 |
return CellStyle.SQUARES; |
226 |
case STPatternType.INT_LIGHT_TRELLIS: |
227 |
return CellStyle.DIAMONDS; |
228 |
case STPatternType.INT_GRAY_125: |
229 |
return CellStyle.LESS_DOTS; |
230 |
/* |
231 |
case STPatternType.INT_GRAY_0625: |
232 |
return CellStyle.LEAST_DOTS; |
233 |
*/ |
234 |
default: |
235 |
return CellStyle.NO_FILL; |
236 |
} |
237 |
// return (short) getCellFill().getPatternType().intValue(); |
238 |
} |
401 |
} |
239 |
|
402 |
|
|
|
403 |
/** |
404 |
* get the fill pattern |
405 |
* @return FillPatternType - fill pattern |
406 |
*/ |
407 |
public FillPatternType getFillPatternEnum() { |
408 |
return getCellFill().getPatternType(); |
409 |
} |
410 |
|
411 |
/** |
412 |
* gets the font for this style |
413 |
* @param parentWorkbook The XSSFWorkbook that this style belongs to |
414 |
* @return Font - font |
415 |
* @see org.apache.poi.xssf.usermodel.XSSFCellStyle#getFontIndex() |
416 |
* @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short) |
417 |
*/ |
240 |
public Font getFont(Workbook parentWorkbook) { |
418 |
public Font getFont(Workbook parentWorkbook) { |
241 |
return getFont(); |
419 |
return getFont(); |
242 |
} |
420 |
} |
243 |
|
421 |
|
|
|
422 |
/** |
423 |
* gets the font for this style |
424 |
* @return Font - font |
425 |
*/ |
244 |
public Font getFont() { |
426 |
public Font getFont() { |
245 |
if (font == null) { |
427 |
if (font == null) { |
246 |
font = (XSSFFont) ((StylesTable)stylesSource).getFontAt(getFontId()); |
428 |
font = (XSSFFont) ((StylesTable)stylesSource).getFontAt(getFontId()); |
247 |
} |
429 |
} |
248 |
return font; |
430 |
return font; |
249 |
} |
431 |
} |
250 |
|
432 |
|
|
|
433 |
/** |
434 |
* gets the index of the font for this style |
435 |
* @return short - font index |
436 |
* @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short) |
437 |
*/ |
251 |
public short getFontIndex() { |
438 |
public short getFontIndex() { |
252 |
return (short) getFontId(); |
439 |
return (short) getFontId(); |
253 |
} |
440 |
} |
254 |
|
441 |
|
|
|
442 |
/** |
443 |
* get whether the cell's using this style are to be hidden |
444 |
* @return boolean - whether the cell using this style is hidden |
445 |
*/ |
255 |
public boolean getHidden() { |
446 |
public boolean getHidden() { |
256 |
return getCellProtection().getHidden(); |
447 |
return getCellProtection().getHidden(); |
257 |
} |
448 |
} |
258 |
|
449 |
|
|
|
450 |
/** |
451 |
* get the number of spaces to indent the text in the cell |
452 |
* @return indent - number of spaces |
453 |
*/ |
259 |
public short getIndention() { |
454 |
public short getIndention() { |
260 |
return (short) getCellAlignment().getIndent(); |
455 |
return (short) getCellAlignment().getIndent(); |
261 |
} |
456 |
} |
262 |
|
457 |
|
|
|
458 |
/** |
459 |
* get the index within the StylesTable (sequence within the collection of CTXf elements) |
460 |
* @return unique index number of the underlying record this style represents |
461 |
*/ |
263 |
public short getIndex() { |
462 |
public short getIndex() { |
264 |
return (short) this.cellXfId; |
463 |
return (short) this.cellXfId; |
265 |
} |
464 |
} |
266 |
|
465 |
|
|
|
466 |
/** |
467 |
* set the color to use for the left border |
468 |
* Color is optional. When missing, IndexedColors.AUTOMATIC is implied. |
469 |
* @return short - color The index of the color definition |
470 |
* @see IndexedColors |
471 |
*/ |
267 |
public short getLeftBorderColor() { |
472 |
public short getLeftBorderColor() { |
268 |
return getBorderColorIndexed(BorderSide.LEFT); |
473 |
return getBorderColorIndexed(BorderSide.LEFT); |
269 |
} |
474 |
} |
270 |
|
475 |
|
|
|
476 |
/** |
477 |
* get whether the cell's using this style are locked |
478 |
* @return boolean - whether the cell using this style are locked |
479 |
*/ |
271 |
public boolean getLocked() { |
480 |
public boolean getLocked() { |
272 |
return getCellProtection().getLocked(); |
481 |
return getCellProtection().getLocked(); |
273 |
} |
482 |
} |
274 |
|
483 |
|
|
|
484 |
/** |
485 |
* set the color to use for the right border |
486 |
* Color is optional. When missing, IndexedColors.AUTOMATIC is implied. |
487 |
* @return short - color The index of the color definition |
488 |
* @see IndexedColors |
489 |
*/ |
275 |
public short getRightBorderColor() { |
490 |
public short getRightBorderColor() { |
276 |
return getBorderColorIndexed(BorderSide.RIGHT); |
491 |
return getBorderColorIndexed(BorderSide.RIGHT); |
277 |
} |
492 |
} |
278 |
|
493 |
|
|
|
494 |
/** |
495 |
* get the degree of rotation for the text in the cell |
496 |
* @return rotation degrees (between -90 and 90 degrees) |
497 |
*/ |
279 |
public short getRotation() { |
498 |
public short getRotation() { |
280 |
return (short) getCellAlignment().getTextRotation(); |
499 |
return (short) getCellAlignment().getTextRotation(); |
281 |
} |
500 |
} |
282 |
|
501 |
|
|
|
502 |
/** |
503 |
* set the color to use for the top border |
504 |
* Color is optional. When missing, IndexedColors.AUTOMATIC is implied. |
505 |
* @return short - color The index of the color definition |
506 |
* @see IndexedColors |
507 |
*/ |
283 |
public short getTopBorderColor() { |
508 |
public short getTopBorderColor() { |
284 |
return getBorderColorIndexed(BorderSide.TOP); |
509 |
return getBorderColorIndexed(BorderSide.TOP); |
285 |
} |
510 |
} |
286 |
|
511 |
|
|
|
512 |
/** |
513 |
* get the type of vertical alignment for the cell |
514 |
* @return align the type of alignment |
515 |
* @see #VERTICAL_TOP |
516 |
* @see #VERTICAL_CENTER |
517 |
* @see #VERTICAL_BOTTOM |
518 |
* @see #VERTICAL_JUSTIFY |
519 |
*/ |
287 |
public short getVerticalAlignment() { |
520 |
public short getVerticalAlignment() { |
288 |
return (short) (getVerticalAlignmentEnum().ordinal()); |
521 |
return (short) (getVerticalAlignmentEnum().ordinal()); |
289 |
} |
522 |
} |
290 |
|
523 |
|
|
|
524 |
/** |
525 |
* get the type of vertical alignment for the cell |
526 |
* @return VerticalAlignment - align the type of alignment |
527 |
* @see VerticalAlignment |
528 |
*/ |
291 |
public VerticalAlignment getVerticalAlignmentEnum() { |
529 |
public VerticalAlignment getVerticalAlignmentEnum() { |
292 |
return getCellAlignment().getVertical(); |
530 |
return getCellAlignment().getVertical(); |
293 |
} |
531 |
} |
294 |
|
532 |
|
|
|
533 |
/** |
534 |
* get whether the text should be wrapped |
535 |
* @param boolean - wrap text or not |
536 |
*/ |
295 |
public boolean getWrapText() { |
537 |
public boolean getWrapText() { |
296 |
return getCellAlignment().getWrapText(); |
538 |
return getCellAlignment().getWrapText(); |
297 |
} |
539 |
} |
298 |
|
540 |
|
|
|
541 |
/** |
542 |
* set the type of horizontal alignment for the cell |
543 |
* @param short align - the type of alignment |
544 |
* @see #ALIGN_GENERAL |
545 |
* @see #ALIGN_LEFT |
546 |
* @see #ALIGN_CENTER |
547 |
* @see #ALIGN_RIGHT |
548 |
* @see #ALIGN_FILL |
549 |
* @see #ALIGN_JUSTIFY |
550 |
* @see #ALIGN_CENTER_SELECTION |
551 |
*/ |
299 |
public void setAlignment(short align) { |
552 |
public void setAlignment(short align) { |
300 |
getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]); |
553 |
getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]); |
301 |
} |
554 |
} |
302 |
|
555 |
|
|
|
556 |
/** |
557 |
* set the type of horizontal alignment for the cell |
558 |
* @param HorizontalAlignment.Enum - the type of alignment |
559 |
* @see HorizontalAlignment |
560 |
*/ |
303 |
public void setAlignment(HorizontalAlignment align) { |
561 |
public void setAlignment(HorizontalAlignment align) { |
304 |
setAlignment((short)align.ordinal()); |
562 |
setAlignment((short)align.ordinal()); |
305 |
} |
563 |
} |
306 |
|
564 |
|
|
|
565 |
/** |
566 |
* set the type of border to use for the bottom border of the cell |
567 |
* @param border type |
568 |
* @see #BORDER_NONE |
569 |
* @see #BORDER_THIN |
570 |
* @see #BORDER_MEDIUM |
571 |
* @see #BORDER_DASHED |
572 |
* @see #BORDER_DOTTED |
573 |
* @see #BORDER_THICK |
574 |
* @see #BORDER_DOUBLE |
575 |
* @see #BORDER_HAIR |
576 |
* @see #BORDER_MEDIUM_DASHED |
577 |
* @see #BORDER_DASH_DOT |
578 |
* @see #BORDER_MEDIUM_DASH_DOT |
579 |
* @see #BORDER_DASH_DOT_DOT |
580 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
581 |
* @see #BORDER_SLANTED_DASH_DOT |
582 |
*/ |
307 |
public void setBorderBottom(short border) { |
583 |
public void setBorderBottom(short border) { |
308 |
setBorderBottomEnum(STBorderStyle.Enum.forInt(border)); |
584 |
getCellBorder().setBorderStyle(BorderSide.BOTTOM,BorderStyle.values()[border]); |
309 |
} |
585 |
} |
310 |
|
586 |
|
311 |
public void setBorderBottomEnum(STBorderStyle.Enum style) { |
587 |
/** |
312 |
getCellBorder().setBorderStyle(BorderSide.BOTTOM, style); |
588 |
* set the type of border to use for the bottom border of the cell |
|
|
589 |
* @param BorderStyle - border type |
590 |
*/ |
591 |
public void setBorderBottomEnum(BorderStyle border) { |
592 |
setBorderBottom((short)border.ordinal()); |
313 |
} |
593 |
} |
314 |
|
594 |
|
|
|
595 |
/** |
596 |
* set the type of border to use for the left border of the cell |
597 |
* @param border type |
598 |
* @see #BORDER_NONE |
599 |
* @see #BORDER_THIN |
600 |
* @see #BORDER_MEDIUM |
601 |
* @see #BORDER_DASHED |
602 |
* @see #BORDER_DOTTED |
603 |
* @see #BORDER_THICK |
604 |
* @see #BORDER_DOUBLE |
605 |
* @see #BORDER_HAIR |
606 |
* @see #BORDER_MEDIUM_DASHED |
607 |
* @see #BORDER_DASH_DOT |
608 |
* @see #BORDER_MEDIUM_DASH_DOT |
609 |
* @see #BORDER_DASH_DOT_DOT |
610 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
611 |
* @see #BORDER_SLANTED_DASH_DOT |
612 |
*/ |
315 |
public void setBorderLeft(short border) { |
613 |
public void setBorderLeft(short border) { |
316 |
setBorderLeftEnum(STBorderStyle.Enum.forInt(border)); |
614 |
getCellBorder().setBorderStyle(BorderSide.LEFT,BorderStyle.values()[border]); |
317 |
} |
615 |
} |
318 |
|
616 |
|
319 |
public void setBorderLeftEnum(STBorderStyle.Enum style) { |
617 |
/** |
320 |
getCellBorder().setBorderStyle(BorderSide.LEFT, style); |
618 |
* set the type of border to use for the left border of the cell |
|
|
619 |
* @param border type |
620 |
*/ |
621 |
public void setBorderLeftEnum(BorderStyle border) { |
622 |
setBorderLeft((short)border.ordinal()); |
321 |
} |
623 |
} |
322 |
|
624 |
|
|
|
625 |
/** |
626 |
* set the type of border to use for the right border of the cell |
627 |
* @param border type |
628 |
* @see #BORDER_NONE |
629 |
* @see #BORDER_THIN |
630 |
* @see #BORDER_MEDIUM |
631 |
* @see #BORDER_DASHED |
632 |
* @see #BORDER_DOTTED |
633 |
* @see #BORDER_THICK |
634 |
* @see #BORDER_DOUBLE |
635 |
* @see #BORDER_HAIR |
636 |
* @see #BORDER_MEDIUM_DASHED |
637 |
* @see #BORDER_DASH_DOT |
638 |
* @see #BORDER_MEDIUM_DASH_DOT |
639 |
* @see #BORDER_DASH_DOT_DOT |
640 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
641 |
* @see #BORDER_SLANTED_DASH_DOT |
642 |
*/ |
323 |
public void setBorderRight(short border) { |
643 |
public void setBorderRight(short border) { |
324 |
setBorderRightEnum(STBorderStyle.Enum.forInt(border)); |
644 |
getCellBorder().setBorderStyle(BorderSide.RIGHT,BorderStyle.values()[border]); |
325 |
} |
645 |
} |
326 |
|
646 |
|
327 |
public void setBorderRightEnum(STBorderStyle.Enum style) { |
647 |
/** |
328 |
getCellBorder().setBorderStyle(BorderSide.RIGHT, style); |
648 |
* set the type of border to use for the right border of the cell |
|
|
649 |
* @param border type |
650 |
*/ |
651 |
public void setBorderRightEnum(BorderStyle border) { |
652 |
setBorderRight((short)border.ordinal()); |
329 |
} |
653 |
} |
330 |
|
654 |
|
|
|
655 |
/** |
656 |
* set the type of border to use for the top border of the cell |
657 |
* @param border type |
658 |
* @see #BORDER_NONE |
659 |
* @see #BORDER_THIN |
660 |
* @see #BORDER_MEDIUM |
661 |
* @see #BORDER_DASHED |
662 |
* @see #BORDER_DOTTED |
663 |
* @see #BORDER_THICK |
664 |
* @see #BORDER_DOUBLE |
665 |
* @see #BORDER_HAIR |
666 |
* @see #BORDER_MEDIUM_DASHED |
667 |
* @see #BORDER_DASH_DOT |
668 |
* @see #BORDER_MEDIUM_DASH_DOT |
669 |
* @see #BORDER_DASH_DOT_DOT |
670 |
* @see #BORDER_MEDIUM_DASH_DOT_DOT |
671 |
* @see #BORDER_SLANTED_DASH_DOT |
672 |
*/ |
331 |
public void setBorderTop(short border) { |
673 |
public void setBorderTop(short border) { |
332 |
setBorderTopEnum(STBorderStyle.Enum.forInt(border)); |
674 |
getCellBorder().setBorderStyle(BorderSide.TOP,BorderStyle.values()[border]); |
333 |
} |
675 |
} |
334 |
|
676 |
|
335 |
public void setBorderTopEnum(STBorderStyle.Enum style) { |
677 |
/** |
336 |
getCellBorder().setBorderStyle(BorderSide.TOP, style); |
678 |
* set the type of border to use for the top border of the cell |
|
|
679 |
* @param border type |
680 |
*/ |
681 |
public void setBorderTopEnum(BorderStyle border) { |
682 |
setBorderTop((short)border.ordinal()); |
337 |
} |
683 |
} |
338 |
|
684 |
|
|
|
685 |
/** |
686 |
* set the color to use for the bottom border |
687 |
* @param color The index of the color definition |
688 |
* @see IndexedColors |
689 |
*/ |
339 |
public void setBottomBorderColor(short color) { |
690 |
public void setBottomBorderColor(short color) { |
340 |
setBorderColorIndexed(BorderSide.BOTTOM, color); |
691 |
setBorderColorIndexed(BorderSide.BOTTOM, color); |
341 |
} |
692 |
} |
342 |
|
693 |
|
|
|
694 |
/** |
695 |
* set the index of a data format |
696 |
*/ |
343 |
public void setDataFormat(short fmt) { |
697 |
public void setDataFormat(short fmt) { |
344 |
cellXf.setNumFmtId((long)fmt); |
698 |
cellXf.setNumFmtId((long)fmt); |
345 |
} |
699 |
} |
346 |
|
700 |
|
|
|
701 |
/** |
702 |
* set the background fill color represented as rgb values. |
703 |
* <p> |
704 |
* For example: |
705 |
* <pre> |
706 |
* cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); |
707 |
* cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); |
708 |
* </pre> |
709 |
* optionally a Foreground and background fill can be applied: |
710 |
* <i>Note: Ensure Foreground color is set prior to background</i> |
711 |
* <pre> |
712 |
* cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); |
713 |
* cs.setFillForegroundColor(IndexedColors.BLUE.getIndex()); |
714 |
* cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); |
715 |
* </pre> |
716 |
* or, for the special case of SOLID_FILL: |
717 |
* <pre> |
718 |
* cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND ); |
719 |
* cs.setFillForegroundColor(IndexedColors.RED.getIndex()); |
720 |
* </pre> |
721 |
* It is necessary to set the fill style in order |
722 |
* for the color to be shown in the cell. |
723 |
* |
724 |
* @param XSSFColor - bg color |
725 |
*/ |
347 |
public void setFillBackgroundRgbColor(XSSFColor color) { |
726 |
public void setFillBackgroundRgbColor(XSSFColor color) { |
348 |
cellFill=getCellFill(); |
727 |
cellFill=getCellFill(); |
349 |
cellFill.setFillBackgroundRgbColor(color); |
728 |
cellFill.setFillBackgroundRgbColor(color); |
350 |
} |
729 |
} |
351 |
|
730 |
|
|
|
731 |
/** |
732 |
* set the background fill color. |
733 |
* <p> |
734 |
* For example: |
735 |
* <pre> |
736 |
* cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); |
737 |
* cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); |
738 |
* </pre> |
739 |
* optionally a Foreground and background fill can be applied: |
740 |
* <i>Note: Ensure Foreground color is set prior to background</i> |
741 |
* <pre> |
742 |
* cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); |
743 |
* cs.setFillForegroundColor(IndexedColors.BLUE.getIndex()); |
744 |
* cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); |
745 |
* </pre> |
746 |
* or, for the special case of SOLID_FILL: |
747 |
* <pre> |
748 |
* cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND ); |
749 |
* cs.setFillForegroundColor(IndexedColors.RED.getIndex()); |
750 |
* </pre> |
751 |
* It is necessary to set the fill style in order |
752 |
* for the color to be shown in the cell. |
753 |
* |
754 |
* @param short - bg color |
755 |
*/ |
352 |
public void setFillBackgroundColor(short bg) { |
756 |
public void setFillBackgroundColor(short bg) { |
353 |
getCellFill().setFillBackgroundColor(bg); |
757 |
getCellFill().setFillBackgroundColor(bg); |
354 |
} |
758 |
} |
355 |
|
759 |
|
|
|
760 |
/** |
761 |
* set the foreground fill color represented as rgb values. |
762 |
* <i>Note: Ensure Foreground color is set prior to background color.</i> |
763 |
* @param XSSFColor - bg color |
764 |
*/ |
356 |
public void setFillForegroundRgbColor(XSSFColor color) { |
765 |
public void setFillForegroundRgbColor(XSSFColor color) { |
357 |
getCellFill().setFillForegroundRgbColor(color); |
766 |
getCellFill().setFillForegroundRgbColor(color); |
358 |
} |
767 |
} |
359 |
|
768 |
|
|
|
769 |
/** |
770 |
* set the foreground fill color |
771 |
* <i>Note: Ensure Foreground color is set prior to background color.</i> |
772 |
* @param short - bg color |
773 |
*/ |
360 |
public void setFillForegroundColor(short bg) { |
774 |
public void setFillForegroundColor(short bg) { |
361 |
getCellFill().setFillForegroundColor(bg); |
775 |
getCellFill().setFillForegroundColor(bg); |
362 |
} |
776 |
} |
363 |
|
777 |
|
|
|
778 |
/** |
779 |
* This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern), |
780 |
* fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element. |
781 |
* |
782 |
* @see #NO_FILL |
783 |
* @see #SOLID_FOREGROUND |
784 |
* @see #FINE_DOTS |
785 |
* @see #ALT_BARS |
786 |
* @see #SPARSE_DOTS |
787 |
* @see #THICK_HORZ_BANDS |
788 |
* @see #THICK_VERT_BANDS |
789 |
* @see #THICK_BACKWARD_DIAG |
790 |
* @see #THICK_FORWARD_DIAG |
791 |
* @see #BIG_SPOTS |
792 |
* @see #BRICKS |
793 |
* @see #THIN_HORZ_BANDS |
794 |
* @see #THIN_VERT_BANDS |
795 |
* @see #THIN_BACKWARD_DIAG |
796 |
* @see #THIN_FORWARD_DIAG |
797 |
* @see #SQUARES |
798 |
* @see #DIAMONDS |
799 |
* |
800 |
* @param fp fill pattern (set to 1 to fill w/foreground color) |
801 |
*/ |
364 |
public void setFillPattern(short fp) { |
802 |
public void setFillPattern(short fp) { |
365 |
cellFill=getCellFill(); |
803 |
getCellFill().setPatternType(FillPatternType.values()[fp]); |
366 |
switch (fp) { |
|
|
367 |
case CellStyle.NO_FILL: |
368 |
cellFill.setPatternType(STPatternType.NONE); |
369 |
break; |
370 |
case CellStyle.SOLID_FOREGROUND: |
371 |
cellFill.setPatternType(STPatternType.SOLID); |
372 |
break; |
373 |
case CellStyle.FINE_DOTS: |
374 |
cellFill.setPatternType(STPatternType.LIGHT_GRAY); |
375 |
break; |
376 |
case CellStyle.ALT_BARS: |
377 |
cellFill.setPatternType(STPatternType.DARK_GRID); |
378 |
break; |
379 |
case CellStyle.SPARSE_DOTS: |
380 |
cellFill.setPatternType(STPatternType.DARK_GRAY); |
381 |
break; |
382 |
case CellStyle.THICK_HORZ_BANDS: |
383 |
cellFill.setPatternType(STPatternType.DARK_HORIZONTAL); |
384 |
break; |
385 |
case CellStyle.THICK_VERT_BANDS: |
386 |
cellFill.setPatternType(STPatternType.DARK_VERTICAL); |
387 |
break; |
388 |
case CellStyle.THICK_BACKWARD_DIAG: |
389 |
cellFill.setPatternType(STPatternType.DARK_UP); |
390 |
break; |
391 |
case CellStyle.THICK_FORWARD_DIAG: |
392 |
cellFill.setPatternType(STPatternType.DARK_DOWN); |
393 |
break; |
394 |
case CellStyle.BIG_SPOTS: |
395 |
cellFill.setPatternType(STPatternType.GRAY_0625); |
396 |
break; |
397 |
case CellStyle.BRICKS: |
398 |
cellFill.setPatternType(STPatternType.DARK_TRELLIS); |
399 |
break; |
400 |
case CellStyle.THIN_HORZ_BANDS: |
401 |
cellFill.setPatternType(STPatternType.LIGHT_HORIZONTAL); |
402 |
break; |
403 |
case CellStyle.THIN_VERT_BANDS: |
404 |
cellFill.setPatternType(STPatternType.LIGHT_VERTICAL); |
405 |
break; |
406 |
case CellStyle.THIN_BACKWARD_DIAG: |
407 |
cellFill.setPatternType(STPatternType.LIGHT_UP); |
408 |
break; |
409 |
case CellStyle.THIN_FORWARD_DIAG: |
410 |
cellFill.setPatternType(STPatternType.LIGHT_DOWN); |
411 |
break; |
412 |
case CellStyle.SQUARES: |
413 |
cellFill.setPatternType(STPatternType.LIGHT_GRID); |
414 |
break; |
415 |
case CellStyle.DIAMONDS: |
416 |
cellFill.setPatternType(STPatternType.LIGHT_TRELLIS); |
417 |
break; |
418 |
case CellStyle.LESS_DOTS: |
419 |
cellFill.setPatternType(STPatternType.GRAY_125); |
420 |
break; |
421 |
case CellStyle.LEAST_DOTS: |
422 |
cellFill.setPatternType(STPatternType.GRAY_0625); |
423 |
break; |
424 |
default: throw new RuntimeException("Fill type ["+fp+"] not accepted"); |
425 |
} |
426 |
} |
804 |
} |
427 |
|
805 |
|
|
|
806 |
/** |
807 |
* This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern), |
808 |
* fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element. |
809 |
* |
810 |
* @param FillPatternType - fill pattern |
811 |
* |
812 |
*/ |
813 |
public void setFillPattern(FillPatternType pType) { |
814 |
setFillPattern((short)pType.ordinal()); |
815 |
} |
816 |
|
817 |
/** |
818 |
* set the font for this style |
819 |
* @param font a font object created or retreived from the XSSFWorkbook object |
820 |
* @see org.apache.poi.hssf.usermodel.XSSFWorkbook#createFont() |
821 |
* @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short) |
822 |
*/ |
428 |
public void setFont(Font font) { |
823 |
public void setFont(Font font) { |
429 |
if(font!=null){ |
824 |
if(font!=null){ |
430 |
long index=this.stylesSource.putFont(font); |
825 |
long index=this.stylesSource.putFont(font); |
Lines 433-481
Link Here
|
433 |
this.cellXf.setApplyFont(true); |
828 |
this.cellXf.setApplyFont(true); |
434 |
} |
829 |
} |
435 |
|
830 |
|
|
|
831 |
/** |
832 |
* set the cell's using this style to be hidden |
833 |
* @param boolean - whether the cell using this style should be hidden |
834 |
*/ |
436 |
public void setHidden(boolean hidden) { |
835 |
public void setHidden(boolean hidden) { |
437 |
getCellProtection().setHidden(hidden); |
836 |
getCellProtection().setHidden(hidden); |
438 |
} |
837 |
} |
439 |
|
838 |
|
|
|
839 |
/** |
840 |
* set the number of spaces to indent the text in the cell |
841 |
* @param indent - number of spaces |
842 |
*/ |
440 |
public void setIndention(short indent) { |
843 |
public void setIndention(short indent) { |
441 |
getCellAlignment().setIndent(indent); |
844 |
getCellAlignment().setIndent(indent); |
442 |
} |
845 |
} |
443 |
|
846 |
|
|
|
847 |
/** |
848 |
* set the color to use for the left border |
849 |
* @param color The index of the color definition |
850 |
* @see IndexedColors |
851 |
*/ |
444 |
public void setLeftBorderColor(short color) { |
852 |
public void setLeftBorderColor(short color) { |
445 |
setBorderColorIndexed(BorderSide.LEFT, color); |
853 |
setBorderColorIndexed(BorderSide.LEFT, color); |
446 |
} |
854 |
} |
447 |
|
855 |
|
448 |
|
856 |
/** |
449 |
private void setBorderColorIndexed(BorderSide side, XSSFColor color) { |
857 |
* set the cell's using this style to be locked |
450 |
this.cellBorder.setBorderColor(side, color); |
858 |
* @param boolean - whether the cell using this style should be locked |
451 |
} |
859 |
*/ |
452 |
|
|
|
453 |
|
454 |
public void setLocked(boolean locked) { |
860 |
public void setLocked(boolean locked) { |
455 |
getCellProtection().setLocked(locked); |
861 |
getCellProtection().setLocked(locked); |
456 |
} |
862 |
} |
457 |
|
863 |
|
458 |
|
864 |
/** |
|
|
865 |
* set the color to use for the right border |
866 |
* @param color The index of the color definition |
867 |
* @see IndexedColors |
868 |
*/ |
459 |
public void setRightBorderColor(short color) { |
869 |
public void setRightBorderColor(short color) { |
460 |
setBorderColorIndexed(BorderSide.RIGHT, color); |
870 |
setBorderColorIndexed(BorderSide.RIGHT, color); |
461 |
} |
871 |
} |
462 |
|
872 |
|
|
|
873 |
/** |
874 |
* set the degree of rotation for the text in the cell |
875 |
* @param short - rotation degrees (between -90 and 90 degrees) |
876 |
*/ |
463 |
public void setRotation(short rotation) { |
877 |
public void setRotation(short rotation) { |
464 |
getCellAlignment().setTextRotation(rotation); |
878 |
getCellAlignment().setTextRotation(rotation); |
465 |
} |
879 |
} |
466 |
|
880 |
|
|
|
881 |
|
882 |
/** |
883 |
* set the color to use for the top border |
884 |
* @param color The index of the color definition |
885 |
* @see IndexedColors |
886 |
*/ |
467 |
public void setTopBorderColor(short color) { |
887 |
public void setTopBorderColor(short color) { |
468 |
setBorderColorIndexed(BorderSide.TOP, color); |
888 |
setBorderColorIndexed(BorderSide.TOP, color); |
469 |
} |
889 |
} |
470 |
|
890 |
|
|
|
891 |
/** |
892 |
* set the type of vertical alignment for the cell |
893 |
* @param short - align the type of alignment |
894 |
* @see #VERTICAL_TOP |
895 |
* @see #VERTICAL_CENTER |
896 |
* @see #VERTICAL_BOTTOM |
897 |
* @see #VERTICAL_JUSTIFY |
898 |
* @see VerticalAlignment |
899 |
*/ |
471 |
public void setVerticalAlignment(short align) { |
900 |
public void setVerticalAlignment(short align) { |
472 |
getCellAlignment().setVertical(VerticalAlignment.values()[align]); |
901 |
getCellAlignment().setVertical(VerticalAlignment.values()[align]); |
473 |
} |
902 |
} |
474 |
|
903 |
|
|
|
904 |
/** |
905 |
* set the type of vertical alignment for the cell |
906 |
* @param VerticalAlignment - align the type of alignment |
907 |
*/ |
475 |
public void setVerticalAlignment(VerticalAlignment align) { |
908 |
public void setVerticalAlignment(VerticalAlignment align) { |
476 |
getCellAlignment().setVertical(align); |
909 |
getCellAlignment().setVertical(align); |
477 |
} |
910 |
} |
478 |
|
911 |
|
|
|
912 |
/** |
913 |
* set whether the text should be wrapped |
914 |
* @param boolean - wrap text or not |
915 |
*/ |
479 |
public void setWrapText(boolean wrapped) { |
916 |
public void setWrapText(boolean wrapped) { |
480 |
getCellAlignment().setWrapText(wrapped); |
917 |
getCellAlignment().setWrapText(wrapped); |
481 |
} |
918 |
} |
Lines 483-493
Link Here
|
483 |
public XSSFColor getBorderColor(BorderSide side) { |
920 |
public XSSFColor getBorderColor(BorderSide side) { |
484 |
return getCellBorder().getBorderColor(side); |
921 |
return getCellBorder().getBorderColor(side); |
485 |
} |
922 |
} |
486 |
|
923 |
|
|
|
924 |
/** |
925 |
* set the color to use for the selected border |
926 |
* @param BorderSide - side where to apply the color definition |
927 |
* @param XSSFColor - color rgb value of the color definition |
928 |
*/ |
487 |
public void setBorderColor(BorderSide side, XSSFColor color) { |
929 |
public void setBorderColor(BorderSide side, XSSFColor color) { |
488 |
getCellBorder().setBorderColor(side, color); |
930 |
getCellBorder().setBorderColor(side, color); |
489 |
} |
931 |
} |
490 |
|
932 |
|
|
|
933 |
/** |
934 |
* get the cellBorder object border to use for manage borders |
935 |
* @return XSSFCellBorder - cell border |
936 |
*/ |
491 |
private XSSFCellBorder getCellBorder() { |
937 |
private XSSFCellBorder getCellBorder() { |
492 |
if (cellBorder == null) { |
938 |
if (cellBorder == null) { |
493 |
// TODO make a common Cell Border object |
939 |
// TODO make a common Cell Border object |
Lines 505-518
Link Here
|
505 |
return cellBorder; |
951 |
return cellBorder; |
506 |
} |
952 |
} |
507 |
|
953 |
|
|
|
954 |
/** |
955 |
* get the index of the border to use for this cell style. |
956 |
* return -1 if no border is defined. |
957 |
* @return int - index of cell border |
958 |
*/ |
508 |
private int getBorderId() { |
959 |
private int getBorderId() { |
509 |
if (cellXf.isSetBorderId() && cellXf.getBorderId()>0) { |
960 |
if (cellXf.isSetBorderId() && cellXf.getBorderId()>0) { |
510 |
return (int) cellXf.getBorderId(); |
961 |
return (int) cellXf.getBorderId(); |
511 |
} |
962 |
} |
512 |
return -1; |
963 |
return -1; |
513 |
// return (int) cellStyleXf.getBorderId(); |
|
|
514 |
} |
964 |
} |
515 |
|
965 |
|
|
|
966 |
/** |
967 |
* get the cellFill object to use for manage fill |
968 |
* @return XSSFCellFill - cell fill |
969 |
*/ |
516 |
private XSSFCellFill getCellFill() { |
970 |
private XSSFCellFill getCellFill() { |
517 |
if (cellFill == null) { |
971 |
if (cellFill == null) { |
518 |
int fillId=getFillId(); |
972 |
int fillId=getFillId(); |
Lines 529-542
Link Here
|
529 |
return cellFill; |
983 |
return cellFill; |
530 |
} |
984 |
} |
531 |
|
985 |
|
|
|
986 |
/** |
987 |
* get the index of the fill to use for this cell style. |
988 |
* return -1 if no fill is defined. |
989 |
* @return int - index of cell fill |
990 |
*/ |
532 |
private int getFillId() { |
991 |
private int getFillId() { |
533 |
if (cellXf.isSetFillId() && cellXf.getFillId()>0) { |
992 |
if (cellXf.isSetFillId() && cellXf.getFillId()>0) { |
534 |
return (int) cellXf.getFillId(); |
993 |
return (int) cellXf.getFillId(); |
535 |
} |
994 |
} |
536 |
//return (int) cellStyleXf.getFillId(); |
|
|
537 |
return -1; |
995 |
return -1; |
538 |
} |
996 |
} |
539 |
|
997 |
|
|
|
998 |
/** |
999 |
* get the index of the font to use for this cell style. |
1000 |
* @return int - index of font |
1001 |
*/ |
540 |
private int getFontId() { |
1002 |
private int getFontId() { |
541 |
if (cellXf.isSetFontId()) { |
1003 |
if (cellXf.isSetFontId()) { |
542 |
return (int) cellXf.getFontId(); |
1004 |
return (int) cellXf.getFontId(); |
Lines 544-549
Link Here
|
544 |
return (int) cellStyleXf.getFontId(); |
1006 |
return (int) cellStyleXf.getFontId(); |
545 |
} |
1007 |
} |
546 |
|
1008 |
|
|
|
1009 |
/** |
1010 |
* get a cellProtection from the supplied XML definition |
1011 |
* @return CTCellProtection |
1012 |
*/ |
547 |
private CTCellProtection getCellProtection() { |
1013 |
private CTCellProtection getCellProtection() { |
548 |
if (cellXf.getProtection() == null) { |
1014 |
if (cellXf.getProtection() == null) { |
549 |
cellXf.addNewProtection(); |
1015 |
cellXf.addNewProtection(); |
Lines 551-556
Link Here
|
551 |
return cellXf.getProtection(); |
1017 |
return cellXf.getProtection(); |
552 |
} |
1018 |
} |
553 |
|
1019 |
|
|
|
1020 |
/** |
1021 |
* get the cellAlignment object to use for manage alignment |
1022 |
* @return XSSFCellAlignment - cell alignment |
1023 |
*/ |
554 |
public XSSFCellAlignment getCellAlignment() { |
1024 |
public XSSFCellAlignment getCellAlignment() { |
555 |
if (this.cellAlignment == null) { |
1025 |
if (this.cellAlignment == null) { |
556 |
this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment()); |
1026 |
this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment()); |
Lines 558-588
Link Here
|
558 |
return this.cellAlignment; |
1028 |
return this.cellAlignment; |
559 |
} |
1029 |
} |
560 |
|
1030 |
|
|
|
1031 |
|
1032 |
/** |
1033 |
* Return the CTCellAlignment instance for alignment |
1034 |
* |
1035 |
* @return CTCellAlignment |
1036 |
*/ |
561 |
private CTCellAlignment getCTCellAlignment() { |
1037 |
private CTCellAlignment getCTCellAlignment() { |
562 |
if (cellXf.getAlignment() == null) { |
1038 |
if (cellXf.getAlignment() == null) { |
563 |
cellXf.setAlignment(CTCellAlignment.Factory.newInstance()); |
1039 |
cellXf.setAlignment(CTCellAlignment.Factory.newInstance()); |
564 |
} |
1040 |
} |
565 |
return cellXf.getAlignment(); |
1041 |
return cellXf.getAlignment(); |
566 |
} |
1042 |
} |
567 |
|
1043 |
|
|
|
1044 |
/** |
1045 |
* get the index of the color to use for the border side specified. |
1046 |
* @parameter BorderSie -side |
1047 |
* @return short - index of color |
1048 |
*/ |
568 |
private short getBorderColorIndexed(BorderSide side) { |
1049 |
private short getBorderColorIndexed(BorderSide side) { |
569 |
return (short) getBorderColor(side).getIndexed(); |
1050 |
return (short) getBorderColor(side).getIndexed(); |
570 |
} |
1051 |
} |
571 |
|
1052 |
|
|
|
1053 |
/** |
1054 |
* set the index of the color to use for the border side specified. |
1055 |
* @parameter BorderSide -side |
1056 |
* @parameter int - color |
1057 |
* @see IndexedColors |
1058 |
*/ |
572 |
private void setBorderColorIndexed(BorderSide side, int color) { |
1059 |
private void setBorderColorIndexed(BorderSide side, int color) { |
573 |
getBorderColor(side).setIndexed(color); |
1060 |
getBorderColor(side).setIndexed(color); |
574 |
} |
1061 |
} |
575 |
|
1062 |
|
576 |
private short getBorderStyleAsShort(BorderSide side) { |
1063 |
/** |
577 |
return (short) (getBorderStyle(side).intValue() - 1); |
1064 |
* get the BorderStyle enum for the border side specified. |
|
|
1065 |
* @parameter BorderSide -side |
1066 |
* @return BorderStyle - index of color |
1067 |
*/ |
1068 |
private BorderStyle getBorderStyleEnum(BorderSide side) { |
1069 |
return getCellBorder().getBorderStyle(side); |
578 |
} |
1070 |
} |
579 |
|
1071 |
|
|
|
1072 |
/** |
1073 |
* get the BorderStyle enum for the border side specified. |
1074 |
* @parameter BorderSie -side |
1075 |
* @return short - index of color |
1076 |
*/ |
580 |
private String getBorderStyleAsString(BorderSide side) { |
1077 |
private String getBorderStyleAsString(BorderSide side) { |
581 |
return getBorderStyle(side).toString(); |
1078 |
return getCellBorder().getBorderStyleAsString(side); |
582 |
} |
1079 |
} |
|
|
1080 |
|
583 |
|
1081 |
|
584 |
private STBorderStyle.Enum getBorderStyle(BorderSide side) { |
|
|
585 |
return getCellBorder().getBorderStyle(side); |
586 |
} |
587 |
|
588 |
} |
1082 |
} |