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.

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