I'd like to set print title rows so header would be printed on the top of every page I'm using POI 2.5.1
Print row or column titles on every pageOn the Page Layout tab, in the Page Setup group, click Page Setup. Under Print Titles, click in Rows to repeat at top or Columns to repeat at left and select the column or row that contains the titles you want to repeat. Click OK. On the File menu, click Print.
Create two CellStyles, one with setLocked(true) and other with setLocked(false). Then apply the locked style for all the cells in the column which needs to be locked, and the unlocked style for all the other cells. Protect the sheet using sheet. protectSheet("");
setWrapText(true); cell. setCellStyle(cellStyle); Saving a file generated with the above code and viewing it in Microsoft Excel will show multiline text in a cell.
First, don't use such an old version of POI. The latest stable version as of this writing is 3.9.
To answer your actual question, you can use the setRepeatingRows
method in the Sheet
interface. (As of Apache POI 3.5, .xlsx is supported with the org.apache.poi.xssf.*
packages. A common interface was developed in the org.apache.poi.ss.*
packages, and almost everything "HSSF" has been extracted into common interfaces, e.g. HSSFSheet
implements Sheet
. Similarly, almost everything "XSSF" implements those same interfaces also.)
In fact, the Busy Developer's Guide contains an example of its usage:
// Set the rows to repeat from row 4 to 5 on the first sheet.
sheet1.setRepeatingRows(CellRangeAddress.valueOf("4:5"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With