Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set print title rows in excel sheet using POI? [closed]

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

like image 413
BezrA Avatar asked Sep 05 '13 13:09

BezrA


People also ask

How do you keep the title row in Excel when printing?

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.

How do I lock cells in Excel using Apache POI?

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("");

How do I wrap text in Excel using Apache POI?

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.


1 Answers

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"));
like image 86
rgettman Avatar answered Nov 13 '22 23:11

rgettman