You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CellStyle.java 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.usermodel;
  16. public interface CellStyle {
  17. /**
  18. * general (normal) horizontal alignment
  19. */
  20. public final static short ALIGN_GENERAL = 0x0;
  21. /**
  22. * left-justified horizontal alignment
  23. */
  24. public final static short ALIGN_LEFT = 0x1;
  25. /**
  26. * center horizontal alignment
  27. */
  28. public final static short ALIGN_CENTER = 0x2;
  29. /**
  30. * right-justified horizontal alignment
  31. */
  32. public final static short ALIGN_RIGHT = 0x3;
  33. /**
  34. * fill? horizontal alignment
  35. */
  36. public final static short ALIGN_FILL = 0x4;
  37. /**
  38. * justified horizontal alignment
  39. */
  40. public final static short ALIGN_JUSTIFY = 0x5;
  41. /**
  42. * center-selection? horizontal alignment
  43. */
  44. public final static short ALIGN_CENTER_SELECTION = 0x6;
  45. /**
  46. * top-aligned vertical alignment
  47. */
  48. public final static short VERTICAL_TOP = 0x0;
  49. /**
  50. * center-aligned vertical alignment
  51. */
  52. public final static short VERTICAL_CENTER = 0x1;
  53. /**
  54. * bottom-aligned vertical alignment
  55. */
  56. public final static short VERTICAL_BOTTOM = 0x2;
  57. /**
  58. * vertically justified vertical alignment
  59. */
  60. public final static short VERTICAL_JUSTIFY = 0x3;
  61. /**
  62. * No border
  63. */
  64. public final static short BORDER_NONE = 0x0;
  65. /**
  66. * Thin border
  67. */
  68. public final static short BORDER_THIN = 0x1;
  69. /**
  70. * Medium border
  71. */
  72. public final static short BORDER_MEDIUM = 0x2;
  73. /**
  74. * dash border
  75. */
  76. public final static short BORDER_DASHED = 0x3;
  77. /**
  78. * dot border
  79. */
  80. public final static short BORDER_HAIR = 0x7;
  81. /**
  82. * Thick border
  83. */
  84. public final static short BORDER_THICK = 0x5;
  85. /**
  86. * double-line border
  87. */
  88. public final static short BORDER_DOUBLE = 0x6;
  89. /**
  90. * hair-line border
  91. */
  92. public final static short BORDER_DOTTED = 0x4;
  93. /**
  94. * Medium dashed border
  95. */
  96. public final static short BORDER_MEDIUM_DASHED = 0x8;
  97. /**
  98. * dash-dot border
  99. */
  100. public final static short BORDER_DASH_DOT = 0x9;
  101. /**
  102. * medium dash-dot border
  103. */
  104. public final static short BORDER_MEDIUM_DASH_DOT = 0xA;
  105. /**
  106. * dash-dot-dot border
  107. */
  108. public final static short BORDER_DASH_DOT_DOT = 0xB;
  109. /**
  110. * medium dash-dot-dot border
  111. */
  112. public final static short BORDER_MEDIUM_DASH_DOT_DOT = 0xC;
  113. /**
  114. * slanted dash-dot border
  115. */
  116. public final static short BORDER_SLANTED_DASH_DOT = 0xD;
  117. /** No background */
  118. public final static short NO_FILL = 0;
  119. /** Solidly filled */
  120. public final static short SOLID_FOREGROUND = 1;
  121. /** Small fine dots */
  122. public final static short FINE_DOTS = 2;
  123. /** Wide dots */
  124. public final static short ALT_BARS = 3;
  125. /** Sparse dots */
  126. public final static short SPARSE_DOTS = 4;
  127. /** Thick horizontal bands */
  128. public final static short THICK_HORZ_BANDS = 5;
  129. /** Thick vertical bands */
  130. public final static short THICK_VERT_BANDS = 6;
  131. /** Thick backward facing diagonals */
  132. public final static short THICK_BACKWARD_DIAG = 7;
  133. /** Thick forward facing diagonals */
  134. public final static short THICK_FORWARD_DIAG = 8;
  135. /** Large spots */
  136. public final static short BIG_SPOTS = 9;
  137. /** Brick-like layout */
  138. public final static short BRICKS = 10;
  139. /** Thin horizontal bands */
  140. public final static short THIN_HORZ_BANDS = 11;
  141. /** Thin vertical bands */
  142. public final static short THIN_VERT_BANDS = 12;
  143. /** Thin backward diagonal */
  144. public final static short THIN_BACKWARD_DIAG = 13;
  145. /** Thin forward diagonal */
  146. public final static short THIN_FORWARD_DIAG = 14;
  147. /** Squares */
  148. public final static short SQUARES = 15;
  149. /** Diamonds */
  150. public final static short DIAMONDS = 16;
  151. /** Less Dots */
  152. public final static short LESS_DOTS = 17;
  153. /** Least Dots */
  154. public final static short LEAST_DOTS = 18;
  155. /**
  156. * get the index within the Workbook (sequence within the collection of ExtnededFormat objects)
  157. * @return unique index number of the underlying record this style represents (probably you don't care
  158. * unless you're comparing which one is which)
  159. */
  160. short getIndex();
  161. /**
  162. * set the data format (must be a valid format)
  163. * @see DataFormat
  164. */
  165. void setDataFormat(short fmt);
  166. /**
  167. * get the index of the format
  168. * @see DataFormat
  169. */
  170. short getDataFormat();
  171. /**
  172. * Get the format string
  173. */
  174. public String getDataFormatString();
  175. /**
  176. * set the font for this style
  177. * @param font a font object created or retreived from the Workbook object
  178. * @see Workbook#createFont()
  179. * @see Workbook#getFontAt(short)
  180. */
  181. void setFont(Font font);
  182. /**
  183. * gets the index of the font for this style
  184. * @see Workbook#getFontAt(short)
  185. */
  186. short getFontIndex();
  187. /**
  188. * set the cell's using this style to be hidden
  189. * @param hidden - whether the cell using this style should be hidden
  190. */
  191. void setHidden(boolean hidden);
  192. /**
  193. * get whether the cell's using this style are to be hidden
  194. * @return hidden - whether the cell using this style should be hidden
  195. */
  196. boolean getHidden();
  197. /**
  198. * set the cell's using this style to be locked
  199. * @param locked - whether the cell using this style should be locked
  200. */
  201. void setLocked(boolean locked);
  202. /**
  203. * get whether the cell's using this style are to be locked
  204. * @return hidden - whether the cell using this style should be locked
  205. */
  206. boolean getLocked();
  207. /**
  208. * set the type of horizontal alignment for the cell
  209. * @param align - the type of alignment
  210. * @see #ALIGN_GENERAL
  211. * @see #ALIGN_LEFT
  212. * @see #ALIGN_CENTER
  213. * @see #ALIGN_RIGHT
  214. * @see #ALIGN_FILL
  215. * @see #ALIGN_JUSTIFY
  216. * @see #ALIGN_CENTER_SELECTION
  217. */
  218. void setAlignment(short align);
  219. /**
  220. * get the type of horizontal alignment for the cell
  221. * @return align - the type of alignment
  222. * @see #ALIGN_GENERAL
  223. * @see #ALIGN_LEFT
  224. * @see #ALIGN_CENTER
  225. * @see #ALIGN_RIGHT
  226. * @see #ALIGN_FILL
  227. * @see #ALIGN_JUSTIFY
  228. * @see #ALIGN_CENTER_SELECTION
  229. */
  230. short getAlignment();
  231. /**
  232. * Set whether the text should be wrapped.
  233. * Setting this flag to <code>true</code> make all content visible
  234. * whithin a cell by displaying it on multiple lines
  235. *
  236. * @param wrapped wrap text or not
  237. */
  238. void setWrapText(boolean wrapped);
  239. /**
  240. * get whether the text should be wrapped
  241. * @return wrap text or not
  242. */
  243. boolean getWrapText();
  244. /**
  245. * set the type of vertical alignment for the cell
  246. * @param align the type of alignment
  247. * @see #VERTICAL_TOP
  248. * @see #VERTICAL_CENTER
  249. * @see #VERTICAL_BOTTOM
  250. * @see #VERTICAL_JUSTIFY
  251. */
  252. void setVerticalAlignment(short align);
  253. /**
  254. * get the type of vertical alignment for the cell
  255. * @return align the type of alignment
  256. * @see #VERTICAL_TOP
  257. * @see #VERTICAL_CENTER
  258. * @see #VERTICAL_BOTTOM
  259. * @see #VERTICAL_JUSTIFY
  260. */
  261. short getVerticalAlignment();
  262. /**
  263. * set the degree of rotation for the text in the cell
  264. * @param rotation degrees (between -90 and 90 degrees)
  265. */
  266. void setRotation(short rotation);
  267. /**
  268. * get the degree of rotation for the text in the cell
  269. * @return rotation degrees (between -90 and 90 degrees)
  270. */
  271. short getRotation();
  272. /**
  273. * set the number of spaces to indent the text in the cell
  274. * @param indent - number of spaces
  275. */
  276. void setIndention(short indent);
  277. /**
  278. * get the number of spaces to indent the text in the cell
  279. * @return indent - number of spaces
  280. */
  281. short getIndention();
  282. /**
  283. * set the type of border to use for the left border of the cell
  284. * @param border type
  285. * @see #BORDER_NONE
  286. * @see #BORDER_THIN
  287. * @see #BORDER_MEDIUM
  288. * @see #BORDER_DASHED
  289. * @see #BORDER_DOTTED
  290. * @see #BORDER_THICK
  291. * @see #BORDER_DOUBLE
  292. * @see #BORDER_HAIR
  293. * @see #BORDER_MEDIUM_DASHED
  294. * @see #BORDER_DASH_DOT
  295. * @see #BORDER_MEDIUM_DASH_DOT
  296. * @see #BORDER_DASH_DOT_DOT
  297. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  298. * @see #BORDER_SLANTED_DASH_DOT
  299. */
  300. void setBorderLeft(short border);
  301. /**
  302. * get the type of border to use for the left border of the cell
  303. * @return border type
  304. * @see #BORDER_NONE
  305. * @see #BORDER_THIN
  306. * @see #BORDER_MEDIUM
  307. * @see #BORDER_DASHED
  308. * @see #BORDER_DOTTED
  309. * @see #BORDER_THICK
  310. * @see #BORDER_DOUBLE
  311. * @see #BORDER_HAIR
  312. * @see #BORDER_MEDIUM_DASHED
  313. * @see #BORDER_DASH_DOT
  314. * @see #BORDER_MEDIUM_DASH_DOT
  315. * @see #BORDER_DASH_DOT_DOT
  316. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  317. * @see #BORDER_SLANTED_DASH_DOT
  318. */
  319. short getBorderLeft();
  320. /**
  321. * set the type of border to use for the right border of the cell
  322. * @param border type
  323. * @see #BORDER_NONE
  324. * @see #BORDER_THIN
  325. * @see #BORDER_MEDIUM
  326. * @see #BORDER_DASHED
  327. * @see #BORDER_DOTTED
  328. * @see #BORDER_THICK
  329. * @see #BORDER_DOUBLE
  330. * @see #BORDER_HAIR
  331. * @see #BORDER_MEDIUM_DASHED
  332. * @see #BORDER_DASH_DOT
  333. * @see #BORDER_MEDIUM_DASH_DOT
  334. * @see #BORDER_DASH_DOT_DOT
  335. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  336. * @see #BORDER_SLANTED_DASH_DOT
  337. */
  338. void setBorderRight(short border);
  339. /**
  340. * get the type of border to use for the right border of the cell
  341. * @return border type
  342. * @see #BORDER_NONE
  343. * @see #BORDER_THIN
  344. * @see #BORDER_MEDIUM
  345. * @see #BORDER_DASHED
  346. * @see #BORDER_DOTTED
  347. * @see #BORDER_THICK
  348. * @see #BORDER_DOUBLE
  349. * @see #BORDER_HAIR
  350. * @see #BORDER_MEDIUM_DASHED
  351. * @see #BORDER_DASH_DOT
  352. * @see #BORDER_MEDIUM_DASH_DOT
  353. * @see #BORDER_DASH_DOT_DOT
  354. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  355. * @see #BORDER_SLANTED_DASH_DOT
  356. */
  357. short getBorderRight();
  358. /**
  359. * set the type of border to use for the top border of the cell
  360. * @param border type
  361. * @see #BORDER_NONE
  362. * @see #BORDER_THIN
  363. * @see #BORDER_MEDIUM
  364. * @see #BORDER_DASHED
  365. * @see #BORDER_DOTTED
  366. * @see #BORDER_THICK
  367. * @see #BORDER_DOUBLE
  368. * @see #BORDER_HAIR
  369. * @see #BORDER_MEDIUM_DASHED
  370. * @see #BORDER_DASH_DOT
  371. * @see #BORDER_MEDIUM_DASH_DOT
  372. * @see #BORDER_DASH_DOT_DOT
  373. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  374. * @see #BORDER_SLANTED_DASH_DOT
  375. */
  376. void setBorderTop(short border);
  377. /**
  378. * get the type of border to use for the top border of the cell
  379. * @return border type
  380. * @see #BORDER_NONE
  381. * @see #BORDER_THIN
  382. * @see #BORDER_MEDIUM
  383. * @see #BORDER_DASHED
  384. * @see #BORDER_DOTTED
  385. * @see #BORDER_THICK
  386. * @see #BORDER_DOUBLE
  387. * @see #BORDER_HAIR
  388. * @see #BORDER_MEDIUM_DASHED
  389. * @see #BORDER_DASH_DOT
  390. * @see #BORDER_MEDIUM_DASH_DOT
  391. * @see #BORDER_DASH_DOT_DOT
  392. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  393. * @see #BORDER_SLANTED_DASH_DOT
  394. */
  395. short getBorderTop();
  396. /**
  397. * set the type of border to use for the bottom border of the cell
  398. * @param border type
  399. * @see #BORDER_NONE
  400. * @see #BORDER_THIN
  401. * @see #BORDER_MEDIUM
  402. * @see #BORDER_DASHED
  403. * @see #BORDER_DOTTED
  404. * @see #BORDER_THICK
  405. * @see #BORDER_DOUBLE
  406. * @see #BORDER_HAIR
  407. * @see #BORDER_MEDIUM_DASHED
  408. * @see #BORDER_DASH_DOT
  409. * @see #BORDER_MEDIUM_DASH_DOT
  410. * @see #BORDER_DASH_DOT_DOT
  411. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  412. * @see #BORDER_SLANTED_DASH_DOT
  413. */
  414. void setBorderBottom(short border);
  415. /**
  416. * get the type of border to use for the bottom border of the cell
  417. * @return border type
  418. * @see #BORDER_NONE
  419. * @see #BORDER_THIN
  420. * @see #BORDER_MEDIUM
  421. * @see #BORDER_DASHED
  422. * @see #BORDER_DOTTED
  423. * @see #BORDER_THICK
  424. * @see #BORDER_DOUBLE
  425. * @see #BORDER_HAIR
  426. * @see #BORDER_MEDIUM_DASHED
  427. * @see #BORDER_DASH_DOT
  428. * @see #BORDER_MEDIUM_DASH_DOT
  429. * @see #BORDER_DASH_DOT_DOT
  430. * @see #BORDER_MEDIUM_DASH_DOT_DOT
  431. * @see #BORDER_SLANTED_DASH_DOT
  432. */
  433. short getBorderBottom();
  434. /**
  435. * set the color to use for the left border
  436. * @param color The index of the color definition
  437. */
  438. void setLeftBorderColor(short color);
  439. /**
  440. * get the color to use for the left border
  441. */
  442. short getLeftBorderColor();
  443. /**
  444. * set the color to use for the right border
  445. * @param color The index of the color definition
  446. */
  447. void setRightBorderColor(short color);
  448. /**
  449. * get the color to use for the left border
  450. * @return the index of the color definition
  451. */
  452. short getRightBorderColor();
  453. /**
  454. * set the color to use for the top border
  455. * @param color The index of the color definition
  456. */
  457. void setTopBorderColor(short color);
  458. /**
  459. * get the color to use for the top border
  460. * @return hhe index of the color definition
  461. */
  462. short getTopBorderColor();
  463. /**
  464. * set the color to use for the bottom border
  465. * @param color The index of the color definition
  466. */
  467. void setBottomBorderColor(short color);
  468. /**
  469. * get the color to use for the left border
  470. * @return the index of the color definition
  471. */
  472. short getBottomBorderColor();
  473. /**
  474. * setting to one fills the cell with the foreground color... No idea about
  475. * other values
  476. *
  477. * @see #NO_FILL
  478. * @see #SOLID_FOREGROUND
  479. * @see #FINE_DOTS
  480. * @see #ALT_BARS
  481. * @see #SPARSE_DOTS
  482. * @see #THICK_HORZ_BANDS
  483. * @see #THICK_VERT_BANDS
  484. * @see #THICK_BACKWARD_DIAG
  485. * @see #THICK_FORWARD_DIAG
  486. * @see #BIG_SPOTS
  487. * @see #BRICKS
  488. * @see #THIN_HORZ_BANDS
  489. * @see #THIN_VERT_BANDS
  490. * @see #THIN_BACKWARD_DIAG
  491. * @see #THIN_FORWARD_DIAG
  492. * @see #SQUARES
  493. * @see #DIAMONDS
  494. *
  495. * @param fp fill pattern (set to 1 to fill w/foreground color)
  496. */
  497. void setFillPattern(short fp);
  498. /**
  499. * get the fill pattern (??) - set to 1 to fill with foreground color
  500. * @return fill pattern
  501. */
  502. short getFillPattern();
  503. /**
  504. * set the background fill color.
  505. *
  506. * @param bg color
  507. */
  508. void setFillBackgroundColor(short bg);
  509. /**
  510. * get the background fill color, if the fill
  511. * is defined with an indexed color.
  512. * @return fill color index, or 0 if not indexed (XSSF only)
  513. */
  514. short getFillBackgroundColor();
  515. /**
  516. * Gets the color object representing the current
  517. * background fill, resolving indexes using
  518. * the supplied workbook.
  519. * This will work for both indexed and rgb
  520. * defined colors.
  521. */
  522. Color getFillBackgroundColorColor();
  523. /**
  524. * set the foreground fill color
  525. * <i>Note: Ensure Foreground color is set prior to background color.</i>
  526. * @param bg color
  527. */
  528. void setFillForegroundColor(short bg);
  529. /**
  530. * get the foreground fill color, if the fill
  531. * is defined with an indexed color.
  532. * @return fill color, or 0 if not indexed (XSSF only)
  533. */
  534. short getFillForegroundColor();
  535. /**
  536. * Gets the color object representing the current
  537. * foreground fill, resolving indexes using
  538. * the supplied workbook.
  539. * This will work for both indexed and rgb
  540. * defined colors.
  541. */
  542. Color getFillForegroundColorColor();
  543. /**
  544. * Clones all the style information from another
  545. * CellStyle, onto this one. This
  546. * CellStyle will then have all the same
  547. * properties as the source, but the two may
  548. * be edited independently.
  549. * Any stylings on this CellStyle will be lost!
  550. *
  551. * The source CellStyle could be from another
  552. * Workbook if you like. This allows you to
  553. * copy styles from one Workbook to another.
  554. *
  555. * However, both of the CellStyles will need
  556. * to be of the same type (HSSFCellStyle or
  557. * XSSFCellStyle)
  558. */
  559. public void cloneStyleFrom(CellStyle source);
  560. }