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.

Sheet.java 35KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  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. import java.util.Iterator;
  17. import java.util.List;
  18. import org.apache.poi.hssf.util.PaneInformation;
  19. import org.apache.poi.ss.util.CellRangeAddress;
  20. /**
  21. * High level representation of a Excel worksheet.
  22. *
  23. * <p>
  24. * Sheets are the central structures within a workbook, and are where a user does most of his spreadsheet work.
  25. * The most common type of sheet is the worksheet, which is represented as a grid of cells. Worksheet cells can
  26. * contain text, numbers, dates, and formulas. Cells can also be formatted.
  27. * </p>
  28. */
  29. public interface Sheet extends Iterable<Row> {
  30. /* Constants for margins */
  31. public static final short LeftMargin = 0;
  32. public static final short RightMargin = 1;
  33. public static final short TopMargin = 2;
  34. public static final short BottomMargin = 3;
  35. public static final short HeaderMargin = 4;
  36. public static final short FooterMargin = 5;
  37. public static final byte PANE_LOWER_RIGHT = (byte) 0;
  38. public static final byte PANE_UPPER_RIGHT = (byte) 1;
  39. public static final byte PANE_LOWER_LEFT = (byte) 2;
  40. public static final byte PANE_UPPER_LEFT = (byte) 3;
  41. /**
  42. * Create a new row within the sheet and return the high level representation
  43. *
  44. * @param rownum row number
  45. * @return high level Row object representing a row in the sheet
  46. * @see #removeRow(Row)
  47. */
  48. Row createRow(int rownum);
  49. /**
  50. * Remove a row from this sheet. All cells contained in the row are removed as well
  51. *
  52. * @param row representing a row to remove.
  53. */
  54. void removeRow(Row row);
  55. /**
  56. * Returns the logical row (not physical) 0-based. If you ask for a row that is not
  57. * defined you get a null. This is to say row 4 represents the fifth row on a sheet.
  58. *
  59. * @param rownum row to get (0-based)
  60. * @return Row representing the rownumber or null if its not defined on the sheet
  61. */
  62. Row getRow(int rownum);
  63. /**
  64. * Returns the number of physically defined rows (NOT the number of rows in the sheet)
  65. *
  66. * @return the number of physically defined rows in this sheet
  67. */
  68. int getPhysicalNumberOfRows();
  69. /**
  70. * Gets the first row on the sheet
  71. *
  72. * @return the number of the first logical row on the sheet (0-based)
  73. */
  74. int getFirstRowNum();
  75. /**
  76. * Gets the last row on the sheet
  77. *
  78. * @return last row contained n this sheet (0-based)
  79. */
  80. int getLastRowNum();
  81. /**
  82. * Get the visibility state for a given column
  83. *
  84. * @param columnIndex - the column to get (0-based)
  85. * @param hidden - the visiblity state of the column
  86. */
  87. void setColumnHidden(int columnIndex, boolean hidden);
  88. /**
  89. * Get the hidden state for a given column
  90. *
  91. * @param columnIndex - the column to set (0-based)
  92. * @return hidden - <code>false</code> if the column is visible
  93. */
  94. boolean isColumnHidden(int columnIndex);
  95. /**
  96. * Sets whether the worksheet is displayed from right to left instead of from left to right.
  97. *
  98. * @param value true for right to left, false otherwise.
  99. */
  100. public void setRightToLeft(boolean value);
  101. /**
  102. * Whether the text is displayed in right-to-left mode in the window
  103. *
  104. * @return whether the text is displayed in right-to-left mode in the window
  105. */
  106. public boolean isRightToLeft();
  107. /**
  108. * Set the width (in units of 1/256th of a character width)
  109. *
  110. * <p>
  111. * The maximum column width for an individual cell is 255 characters.
  112. * This value represents the number of characters that can be displayed
  113. * in a cell that is formatted with the standard font (first font in the workbook).
  114. * </p>
  115. *
  116. * <p>
  117. * Character width is defined as the maximum digit width
  118. * of the numbers <code>0, 1, 2, ... 9</code> as rendered
  119. * using the default font (first font in the workbook).
  120. * <br/>
  121. * Unless you are using a very special font, the default character is '0' (zero),
  122. * this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)
  123. * </p>
  124. *
  125. * <p>
  126. * Please note, that the width set by this method includes 4 pixels of margin padding (two on each side),
  127. * plus 1 pixel padding for the gridlines (Section 3.3.1.12 of the OOXML spec).
  128. * This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).
  129. * </p>
  130. * <p>
  131. * To compute the actual number of visible characters,
  132. * Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):
  133. * </p>
  134. * <code>
  135. * width = Truncate([{Number of Visible Characters} *
  136. * {Maximum Digit Width} + {5 pixel padding}]/{Maximum Digit Width}*256)/256
  137. * </code>
  138. * <p>Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi).
  139. * If you set a column width to be eight characters wide, e.g. <code>setColumnWidth(columnIndex, 8*256)</code>,
  140. * then the actual value of visible characters (the value shown in Excel) is derived from the following equation:
  141. * <code>
  142. Truncate([numChars*7+5]/7*256)/256 = 8;
  143. * </code>
  144. *
  145. * which gives <code>7.29</code>.
  146. *
  147. * @param columnIndex - the column to set (0-based)
  148. * @param width - the width in units of 1/256th of a character width
  149. * @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters)
  150. */
  151. void setColumnWidth(int columnIndex, int width);
  152. /**
  153. * get the width (in units of 1/256th of a character width )
  154. *
  155. * <p>
  156. * Character width is defined as the maximum digit width
  157. * of the numbers <code>0, 1, 2, ... 9</code> as rendered
  158. * using the default font (first font in the workbook)
  159. * </p>
  160. *
  161. * @param columnIndex - the column to get (0-based)
  162. * @return width - the width in units of 1/256th of a character width
  163. */
  164. int getColumnWidth(int columnIndex);
  165. /**
  166. * get the width in pixel
  167. *
  168. * <p>
  169. * Please note, that this method works correctly only for workbooks
  170. * with the default font size (Arial 10pt for .xls and Calibri 11pt for .xlsx).
  171. * If the default font is changed the column width can be streched
  172. * </p>
  173. *
  174. * @param columnIndex - the column to set (0-based)
  175. * @return width in pixels
  176. */
  177. float getColumnWidthInPixels(int columnIndex);
  178. /**
  179. * Set the default column width for the sheet (if the columns do not define their own width)
  180. * in characters
  181. *
  182. * @param width default column width measured in characters
  183. */
  184. void setDefaultColumnWidth(int width);
  185. /**
  186. * Get the default column width for the sheet (if the columns do not define their own width)
  187. * in characters
  188. *
  189. * @return default column width measured in characters
  190. */
  191. int getDefaultColumnWidth();
  192. /**
  193. * Get the default row height for the sheet (if the rows do not define their own height) in
  194. * twips (1/20 of a point)
  195. *
  196. * @return default row height measured in twips (1/20 of a point)
  197. */
  198. short getDefaultRowHeight();
  199. /**
  200. * Get the default row height for the sheet (if the rows do not define their own height) in
  201. * points.
  202. *
  203. * @return default row height in points
  204. */
  205. float getDefaultRowHeightInPoints();
  206. /**
  207. * Set the default row height for the sheet (if the rows do not define their own height) in
  208. * twips (1/20 of a point)
  209. *
  210. * @param height default row height measured in twips (1/20 of a point)
  211. */
  212. void setDefaultRowHeight(short height);
  213. /**
  214. * Set the default row height for the sheet (if the rows do not define their own height) in
  215. * points
  216. * @param height default row height
  217. */
  218. void setDefaultRowHeightInPoints(float height);
  219. /**
  220. * Returns the CellStyle that applies to the given
  221. * (0 based) column, or null if no style has been
  222. * set for that column
  223. */
  224. public CellStyle getColumnStyle(int column);
  225. /**
  226. * Sets the CellStyle that applies to the given
  227. * (0 based) column.
  228. */
  229. // public CellStyle setColumnStyle(int column, CellStyle style);
  230. /**
  231. * Adds a merged region of cells (hence those cells form one)
  232. *
  233. * @param region (rowfrom/colfrom-rowto/colto) to merge
  234. * @return index of this region
  235. */
  236. int addMergedRegion(CellRangeAddress region);
  237. /**
  238. * Determines whether the output is vertically centered on the page.
  239. *
  240. * @param value true to vertically center, false otherwise.
  241. */
  242. void setVerticallyCenter(boolean value);
  243. /**
  244. * Determines whether the output is horizontally centered on the page.
  245. *
  246. * @param value true to horizontally center, false otherwise.
  247. */
  248. void setHorizontallyCenter(boolean value);
  249. /**
  250. * Determine whether printed output for this sheet will be horizontally centered.
  251. */
  252. boolean getHorizontallyCenter();
  253. /**
  254. * Determine whether printed output for this sheet will be vertically centered.
  255. */
  256. boolean getVerticallyCenter();
  257. /**
  258. * Removes a merged region of cells (hence letting them free)
  259. *
  260. * @param index of the region to unmerge
  261. */
  262. void removeMergedRegion(int index);
  263. /**
  264. * Returns the number of merged regions
  265. *
  266. * @return number of merged regions
  267. */
  268. int getNumMergedRegions();
  269. /**
  270. * Returns the merged region at the specified index
  271. *
  272. * @return the merged region at the specified index
  273. */
  274. public CellRangeAddress getMergedRegion(int index);
  275. /**
  276. * Returns an iterator of the physical rows
  277. *
  278. * @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not
  279. * be the third row if say for instance the second row is undefined.
  280. */
  281. Iterator<Row> rowIterator();
  282. /**
  283. * Control if Excel should be asked to recalculate all formulas on this sheet
  284. * when the workbook is opened.
  285. *
  286. * <p>
  287. * Calculating the formula values with {@link FormulaEvaluator} is the
  288. * recommended solution, but this may be used for certain cases where
  289. * evaluation in POI is not possible.
  290. * </p>
  291. *
  292. * To force recalcuation of formulas in the entire workbook
  293. * use {@link Workbook#setForceFormulaRecalculation(boolean)} instead.
  294. *
  295. * @param value true if the application will perform a full recalculation of
  296. * this worksheet values when the workbook is opened
  297. *
  298. * @see Workbook#setForceFormulaRecalculation(boolean)
  299. */
  300. void setForceFormulaRecalculation(boolean value);
  301. /**
  302. * Whether Excel will be asked to recalculate all formulas in this sheet when the
  303. * workbook is opened.
  304. */
  305. boolean getForceFormulaRecalculation();
  306. /**
  307. * Flag indicating whether the sheet displays Automatic Page Breaks.
  308. *
  309. * @param value <code>true</code> if the sheet displays Automatic Page Breaks.
  310. */
  311. void setAutobreaks(boolean value);
  312. /**
  313. * Set whether to display the guts or not
  314. *
  315. * @param value - guts or no guts
  316. */
  317. void setDisplayGuts(boolean value);
  318. /**
  319. * Set whether the window should show 0 (zero) in cells containing zero value.
  320. * When false, cells with zero value appear blank instead of showing the number zero.
  321. *
  322. * @param value whether to display or hide all zero values on the worksheet
  323. */
  324. void setDisplayZeros(boolean value);
  325. /**
  326. * Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
  327. * When false, cells with zero value appear blank instead of showing the number zero.
  328. *
  329. * @return whether all zero values on the worksheet are displayed
  330. */
  331. boolean isDisplayZeros();
  332. /**
  333. * Flag indicating whether the Fit to Page print option is enabled.
  334. *
  335. * @param value <code>true</code> if the Fit to Page print option is enabled.
  336. */
  337. void setFitToPage(boolean value);
  338. /**
  339. * Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
  340. *
  341. * <p>
  342. * When true a summary row is inserted below the detailed data being summarized and a
  343. * new outline level is established on that row.
  344. * </p>
  345. * <p>
  346. * When false a summary row is inserted above the detailed data being summarized and a new outline level
  347. * is established on that row.
  348. * </p>
  349. * @param value <code>true</code> if row summaries appear below detail in the outline
  350. */
  351. void setRowSumsBelow(boolean value);
  352. /**
  353. * Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
  354. *
  355. * <p>
  356. * When true a summary column is inserted to the right of the detailed data being summarized
  357. * and a new outline level is established on that column.
  358. * </p>
  359. * <p>
  360. * When false a summary column is inserted to the left of the detailed data being
  361. * summarized and a new outline level is established on that column.
  362. * </p>
  363. * @param value <code>true</code> if col summaries appear right of the detail in the outline
  364. */
  365. void setRowSumsRight(boolean value);
  366. /**
  367. * Flag indicating whether the sheet displays Automatic Page Breaks.
  368. *
  369. * @return <code>true</code> if the sheet displays Automatic Page Breaks.
  370. */
  371. boolean getAutobreaks();
  372. /**
  373. * Get whether to display the guts or not,
  374. * default value is true
  375. *
  376. * @return boolean - guts or no guts
  377. */
  378. boolean getDisplayGuts();
  379. /**
  380. * Flag indicating whether the Fit to Page print option is enabled.
  381. *
  382. * @return <code>true</code> if the Fit to Page print option is enabled.
  383. */
  384. boolean getFitToPage();
  385. /**
  386. * Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
  387. *
  388. * <p>
  389. * When true a summary row is inserted below the detailed data being summarized and a
  390. * new outline level is established on that row.
  391. * </p>
  392. * <p>
  393. * When false a summary row is inserted above the detailed data being summarized and a new outline level
  394. * is established on that row.
  395. * </p>
  396. * @return <code>true</code> if row summaries appear below detail in the outline
  397. */
  398. boolean getRowSumsBelow();
  399. /**
  400. * Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
  401. *
  402. * <p>
  403. * When true a summary column is inserted to the right of the detailed data being summarized
  404. * and a new outline level is established on that column.
  405. * </p>
  406. * <p>
  407. * When false a summary column is inserted to the left of the detailed data being
  408. * summarized and a new outline level is established on that column.
  409. * </p>
  410. * @return <code>true</code> if col summaries appear right of the detail in the outline
  411. */
  412. boolean getRowSumsRight();
  413. /**
  414. * Gets the flag indicating whether this sheet displays the lines
  415. * between rows and columns to make editing and reading easier.
  416. *
  417. * @return <code>true</code> if this sheet displays gridlines.
  418. * @see #isPrintGridlines() to check if printing of gridlines is turned on or off
  419. */
  420. boolean isPrintGridlines();
  421. /**
  422. * Sets the flag indicating whether this sheet should display the lines
  423. * between rows and columns to make editing and reading easier.
  424. * To turn printing of gridlines use {@link #setPrintGridlines(boolean)}
  425. *
  426. *
  427. * @param show <code>true</code> if this sheet should display gridlines.
  428. * @see #setPrintGridlines(boolean)
  429. */
  430. void setPrintGridlines(boolean show);
  431. /**
  432. * Gets the print setup object.
  433. *
  434. * @return The user model for the print setup object.
  435. */
  436. PrintSetup getPrintSetup();
  437. /**
  438. * Gets the user model for the default document header.
  439. * <p/>
  440. * Note that XSSF offers more kinds of document headers than HSSF does
  441. * </p>
  442. * @return the document header. Never <code>null</code>
  443. */
  444. Header getHeader();
  445. /**
  446. * Gets the user model for the default document footer.
  447. * <p/>
  448. * Note that XSSF offers more kinds of document footers than HSSF does.
  449. *
  450. * @return the document footer. Never <code>null</code>
  451. */
  452. Footer getFooter();
  453. /**
  454. * Sets a flag indicating whether this sheet is selected.
  455. *<p>
  456. * Note: multiple sheets can be selected, but only one sheet can be active at one time.
  457. *</p>
  458. * @param value <code>true</code> if this sheet is selected
  459. * @see Workbook#setActiveSheet(int)
  460. */
  461. void setSelected(boolean value);
  462. /**
  463. * Gets the size of the margin in inches.
  464. *
  465. * @param margin which margin to get
  466. * @return the size of the margin
  467. */
  468. double getMargin(short margin);
  469. /**
  470. * Sets the size of the margin in inches.
  471. *
  472. * @param margin which margin to get
  473. * @param size the size of the margin
  474. */
  475. void setMargin(short margin, double size);
  476. /**
  477. * Answer whether protection is enabled or disabled
  478. *
  479. * @return true => protection enabled; false => protection disabled
  480. */
  481. boolean getProtect();
  482. /**
  483. * Sets the protection enabled as well as the password
  484. * @param password to set for protection. Pass <code>null</code> to remove protection
  485. */
  486. public void protectSheet(String password);
  487. /**
  488. * Answer whether scenario protection is enabled or disabled
  489. *
  490. * @return true => protection enabled; false => protection disabled
  491. */
  492. boolean getScenarioProtect();
  493. /**
  494. * Sets the zoom magnication for the sheet. The zoom is expressed as a
  495. * fraction. For example to express a zoom of 75% use 3 for the numerator
  496. * and 4 for the denominator.
  497. *
  498. * @param numerator The numerator for the zoom magnification.
  499. * @param denominator The denominator for the zoom magnification.
  500. */
  501. void setZoom(int numerator, int denominator);
  502. /**
  503. * The top row in the visible view when the sheet is
  504. * first viewed after opening it in a viewer
  505. *
  506. * @return short indicating the rownum (0 based) of the top row
  507. */
  508. short getTopRow();
  509. /**
  510. * The left col in the visible view when the sheet is
  511. * first viewed after opening it in a viewer
  512. *
  513. * @return short indicating the rownum (0 based) of the top row
  514. */
  515. short getLeftCol();
  516. /**
  517. * Sets desktop window pane display area, when the
  518. * file is first opened in a viewer.
  519. *
  520. * @param toprow the top row to show in desktop window pane
  521. * @param leftcol the left column to show in desktop window pane
  522. */
  523. void showInPane(int toprow, int leftcol);
  524. /**
  525. * Sets desktop window pane display area, when the
  526. * file is first opened in a viewer.
  527. *
  528. * @param toprow the top row to show in desktop window pane
  529. * @param leftcol the left column to show in desktop window pane
  530. * @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
  531. */
  532. @Deprecated
  533. void showInPane(short toprow, short leftcol);
  534. /**
  535. * Shifts rows between startRow and endRow n number of rows.
  536. * If you use a negative number, it will shift rows up.
  537. * Code ensures that rows don't wrap around.
  538. *
  539. * Calls shiftRows(startRow, endRow, n, false, false);
  540. *
  541. * <p>
  542. * Additionally shifts merged regions that are completely defined in these
  543. * rows (ie. merged 2 cells on a row to be shifted).
  544. * @param startRow the row to start shifting
  545. * @param endRow the row to end shifting
  546. * @param n the number of rows to shift
  547. */
  548. void shiftRows(int startRow, int endRow, int n);
  549. /**
  550. * Shifts rows between startRow and endRow n number of rows.
  551. * If you use a negative number, it will shift rows up.
  552. * Code ensures that rows don't wrap around
  553. *
  554. * <p>
  555. * Additionally shifts merged regions that are completely defined in these
  556. * rows (ie. merged 2 cells on a row to be shifted).
  557. * <p>
  558. * @param startRow the row to start shifting
  559. * @param endRow the row to end shifting
  560. * @param n the number of rows to shift
  561. * @param copyRowHeight whether to copy the row height during the shift
  562. * @param resetOriginalRowHeight whether to set the original row's height to the default
  563. */
  564. void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight);
  565. /**
  566. * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
  567. * <p>
  568. * If both colSplit and rowSplit are zero then the existing freeze pane is removed
  569. * </p>
  570. * @param colSplit Horizonatal position of split.
  571. * @param rowSplit Vertical position of split.
  572. * @param leftmostColumn Left column visible in right pane.
  573. * @param topRow Top row visible in bottom pane
  574. */
  575. void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow);
  576. /**
  577. * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
  578. * <p>
  579. * If both colSplit and rowSplit are zero then the existing freeze pane is removed
  580. * </p>
  581. * @param colSplit Horizonatal position of split.
  582. * @param rowSplit Vertical position of split.
  583. */
  584. void createFreezePane(int colSplit, int rowSplit);
  585. /**
  586. * Creates a split pane. Any existing freezepane or split pane is overwritten.
  587. * @param xSplitPos Horizonatal position of split (in 1/20th of a point).
  588. * @param ySplitPos Vertical position of split (in 1/20th of a point).
  589. * @param topRow Top row visible in bottom pane
  590. * @param leftmostColumn Left column visible in right pane.
  591. * @param activePane Active pane. One of: PANE_LOWER_RIGHT,
  592. * PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
  593. * @see #PANE_LOWER_LEFT
  594. * @see #PANE_LOWER_RIGHT
  595. * @see #PANE_UPPER_LEFT
  596. * @see #PANE_UPPER_RIGHT
  597. */
  598. void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane);
  599. /**
  600. * Returns the information regarding the currently configured pane (split or freeze)
  601. *
  602. * @return null if no pane configured, or the pane information.
  603. */
  604. PaneInformation getPaneInformation();
  605. /**
  606. * Sets whether the gridlines are shown in a viewer
  607. *
  608. * @param show whether to show gridlines or not
  609. */
  610. void setDisplayGridlines(boolean show);
  611. /**
  612. * Returns if gridlines are displayed
  613. *
  614. * @return whether gridlines are displayed
  615. */
  616. boolean isDisplayGridlines();
  617. /**
  618. * Sets whether the formulas are shown in a viewer
  619. *
  620. * @param show whether to show formulas or not
  621. */
  622. void setDisplayFormulas(boolean show);
  623. /**
  624. * Returns if formulas are displayed
  625. *
  626. * @return whether formulas are displayed
  627. */
  628. boolean isDisplayFormulas();
  629. /**
  630. * Sets whether the RowColHeadings are shown in a viewer
  631. *
  632. * @param show whether to show RowColHeadings or not
  633. */
  634. void setDisplayRowColHeadings(boolean show);
  635. /**
  636. * Returns if RowColHeadings are displayed.
  637. * @return whether RowColHeadings are displayed
  638. */
  639. boolean isDisplayRowColHeadings();
  640. /**
  641. * Sets a page break at the indicated row
  642. * Breaks occur above the specified row and left of the specified column inclusive.
  643. *
  644. * For example, <code>sheet.setColumnBreak(2);</code> breaks the sheet into two parts
  645. * with columns A,B,C in the first and D,E,... in the second. Simuilar, <code>sheet.setRowBreak(2);</code>
  646. * breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
  647. * and rows starting with rownum=4 in the second.
  648. *
  649. * @param row the row to break, inclusive
  650. */
  651. void setRowBreak(int row);
  652. /**
  653. * Determines if there is a page break at the indicated row
  654. * @param row FIXME: Document this!
  655. * @return FIXME: Document this!
  656. */
  657. boolean isRowBroken(int row);
  658. /**
  659. * Removes the page break at the indicated row
  660. * @param row
  661. */
  662. void removeRowBreak(int row);
  663. /**
  664. * Retrieves all the horizontal page breaks
  665. * @return all the horizontal page breaks, or null if there are no row page breaks
  666. */
  667. int[] getRowBreaks();
  668. /**
  669. * Retrieves all the vertical page breaks
  670. * @return all the vertical page breaks, or null if there are no column page breaks
  671. */
  672. int[] getColumnBreaks();
  673. /**
  674. * Sets a page break at the indicated column.
  675. * Breaks occur above the specified row and left of the specified column inclusive.
  676. *
  677. * For example, <code>sheet.setColumnBreak(2);</code> breaks the sheet into two parts
  678. * with columns A,B,C in the first and D,E,... in the second. Simuilar, <code>sheet.setRowBreak(2);</code>
  679. * breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
  680. * and rows starting with rownum=4 in the second.
  681. *
  682. * @param column the column to break, inclusive
  683. */
  684. void setColumnBreak(int column);
  685. /**
  686. * Determines if there is a page break at the indicated column
  687. * @param column FIXME: Document this!
  688. * @return FIXME: Document this!
  689. */
  690. boolean isColumnBroken(int column);
  691. /**
  692. * Removes a page break at the indicated column
  693. * @param column
  694. */
  695. void removeColumnBreak(int column);
  696. /**
  697. * Expands or collapses a column group.
  698. *
  699. * @param columnNumber One of the columns in the group.
  700. * @param collapsed true = collapse group, false = expand group.
  701. */
  702. void setColumnGroupCollapsed(int columnNumber, boolean collapsed);
  703. /**
  704. * Create an outline for the provided column range.
  705. *
  706. * @param fromColumn beginning of the column range.
  707. * @param toColumn end of the column range.
  708. */
  709. void groupColumn(int fromColumn, int toColumn);
  710. /**
  711. * Ungroup a range of columns that were previously groupped
  712. *
  713. * @param fromColumn start column (0-based)
  714. * @param toColumn end column (0-based)
  715. */
  716. void ungroupColumn(int fromColumn, int toColumn);
  717. /**
  718. * Tie a range of rows together so that they can be collapsed or expanded
  719. *
  720. * @param fromRow start row (0-based)
  721. * @param toRow end row (0-based)
  722. */
  723. void groupRow(int fromRow, int toRow);
  724. /**
  725. * Ungroup a range of rows that were previously groupped
  726. *
  727. * @param fromRow start row (0-based)
  728. * @param toRow end row (0-based)
  729. */
  730. void ungroupRow(int fromRow, int toRow);
  731. /**
  732. * Set view state of a groupped range of rows
  733. *
  734. * @param row start row of a groupped range of rows (0-based)
  735. * @param collapse whether to expand/collapse the detail rows
  736. */
  737. void setRowGroupCollapsed(int row, boolean collapse);
  738. /**
  739. * Sets the default column style for a given column. POI will only apply this style to new cells added to the sheet.
  740. *
  741. * @param column the column index
  742. * @param style the style to set
  743. */
  744. void setDefaultColumnStyle(int column, CellStyle style);
  745. /**
  746. * Adjusts the column width to fit the contents.
  747. *
  748. * <p>
  749. * This process can be relatively slow on large sheets, so this should
  750. * normally only be called once per column, at the end of your
  751. * processing.
  752. * </p>
  753. * You can specify whether the content of merged cells should be considered or ignored.
  754. * Default is to ignore merged cells.
  755. *
  756. * @param column the column index
  757. */
  758. void autoSizeColumn(int column);
  759. /**
  760. * Adjusts the column width to fit the contents.
  761. * <p>
  762. * This process can be relatively slow on large sheets, so this should
  763. * normally only be called once per column, at the end of your
  764. * processing.
  765. * </p>
  766. * You can specify whether the content of merged cells should be considered or ignored.
  767. * Default is to ignore merged cells.
  768. *
  769. * @param column the column index
  770. * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column
  771. */
  772. void autoSizeColumn(int column, boolean useMergedCells);
  773. /**
  774. * Returns cell comment for the specified row and column
  775. *
  776. * @return cell comment or <code>null</code> if not found
  777. */
  778. Comment getCellComment(int row, int column);
  779. /**
  780. * Creates the top-level drawing patriarch.
  781. * <p>This may then be used to add graphics or charts.</p>
  782. * <p>Note that this will normally have the effect of removing
  783. * any existing drawings on this sheet.</p>
  784. *
  785. * @return The new drawing patriarch.
  786. */
  787. Drawing createDrawingPatriarch();
  788. /**
  789. * Return the parent workbook
  790. *
  791. * @return the parent workbook
  792. */
  793. Workbook getWorkbook();
  794. /**
  795. * Returns the name of this sheet
  796. *
  797. * @return the name of this sheet
  798. */
  799. String getSheetName();
  800. /**
  801. * Note - this is not the same as whether the sheet is focused (isActive)
  802. * @return <code>true</code> if this sheet is currently selected
  803. */
  804. boolean isSelected();
  805. /**
  806. * Sets array formula to specified region for result.
  807. *
  808. * @param formula text representation of the formula
  809. * @param range Region of array formula for result.
  810. * @return the {@link CellRange} of cells affected by this change
  811. */
  812. CellRange<? extends Cell> setArrayFormula(String formula, CellRangeAddress range);
  813. /**
  814. * Remove a Array Formula from this sheet. All cells contained in the Array Formula range are removed as well
  815. *
  816. * @param cell any cell within Array Formula range
  817. * @return the {@link CellRange} of cells affected by this change
  818. */
  819. CellRange<? extends Cell> removeArrayFormula(Cell cell);
  820. public DataValidationHelper getDataValidationHelper();
  821. /**
  822. * Returns the list of DataValidation in the sheet.
  823. * @return list of DataValidation in the sheet
  824. */
  825. public List<? extends DataValidation> getDataValidations();
  826. /**
  827. * Creates a data validation object
  828. * @param dataValidation The Data validation object settings
  829. */
  830. public void addValidationData(DataValidation dataValidation);
  831. /**
  832. * Enable filtering for a range of cells
  833. *
  834. * @param range the range of cells to filter
  835. */
  836. AutoFilter setAutoFilter(CellRangeAddress range);
  837. /**
  838. * The 'Conditional Formatting' facet for this <tt>Sheet</tt>
  839. *
  840. * @return conditional formatting rule for this sheet
  841. */
  842. SheetConditionalFormatting getSheetConditionalFormatting();
  843. /**
  844. * Gets the repeating rows used when printing the sheet, as found in
  845. * File->PageSetup->Sheet.
  846. * <p/>
  847. * Repeating rows cover a range of contiguous rows, e.g.:
  848. * <pre>
  849. * Sheet1!$1:$1
  850. * Sheet2!$5:$8
  851. * </pre>
  852. * The {@link CellRangeAddress} returned contains a column part which spans
  853. * all columns, and a row part which specifies the contiguous range of
  854. * repeating rows.
  855. * <p/>
  856. * If the Sheet does not have any repeating rows defined, null is returned.
  857. *
  858. * @return an {@link CellRangeAddress} containing the repeating rows for the
  859. * Sheet, or null.
  860. */
  861. CellRangeAddress getRepeatingRows();
  862. /**
  863. * Gets the repeating columns used when printing the sheet, as found in
  864. * File->PageSetup->Sheet.
  865. * <p/>
  866. * Repeating columns cover a range of contiguous columns, e.g.:
  867. * <pre>
  868. * Sheet1!$A:$A
  869. * Sheet2!$C:$F
  870. * </pre>
  871. * The {@link CellRangeAddress} returned contains a row part which spans all
  872. * rows, and a column part which specifies the contiguous range of
  873. * repeating columns.
  874. * <p/>
  875. * If the Sheet does not have any repeating columns defined, null is
  876. * returned.
  877. *
  878. * @return an {@link CellRangeAddress} containing the repeating columns for
  879. * the Sheet, or null.
  880. */
  881. CellRangeAddress getRepeatingColumns();
  882. /**
  883. * Sets the repeating rows used when printing the sheet, as found in
  884. * File->PageSetup->Sheet.
  885. * <p/>
  886. * Repeating rows cover a range of contiguous rows, e.g.:
  887. * <pre>
  888. * Sheet1!$1:$1
  889. * Sheet2!$5:$8</pre>
  890. * The parameter {@link CellRangeAddress} should specify a column part
  891. * which spans all columns, and a row part which specifies the contiguous
  892. * range of repeating rows, e.g.:
  893. * <pre>
  894. * sheet.setRepeatingRows(CellRangeAddress.valueOf("2:3"));</pre>
  895. * A null parameter value indicates that repeating rows should be removed
  896. * from the Sheet:
  897. * <pre>
  898. * sheet.setRepeatingRows(null);</pre>
  899. *
  900. * @param rowRangeRef a {@link CellRangeAddress} containing the repeating
  901. * rows for the Sheet, or null.
  902. */
  903. void setRepeatingRows(CellRangeAddress rowRangeRef);
  904. /**
  905. * Sets the repeating columns used when printing the sheet, as found in
  906. * File->PageSetup->Sheet.
  907. * <p/>
  908. * Repeating columns cover a range of contiguous columns, e.g.:
  909. * <pre>
  910. * Sheet1!$A:$A
  911. * Sheet2!$C:$F</pre>
  912. * The parameter {@link CellRangeAddress} should specify a row part
  913. * which spans all rows, and a column part which specifies the contiguous
  914. * range of repeating columns, e.g.:
  915. * <pre>
  916. * sheet.setRepeatingColumns(CellRangeAddress.valueOf("B:C"));</pre>
  917. * A null parameter value indicates that repeating columns should be removed
  918. * from the Sheet:
  919. * <pre>
  920. * sheet.setRepeatingColumns(null);</pre>
  921. *
  922. * @param columnRangeRef a {@link CellRangeAddress} containing the repeating
  923. * columns for the Sheet, or null.
  924. */
  925. void setRepeatingColumns(CellRangeAddress columnRangeRef);
  926. }