Ths showInPane() method does not do what I expect you think it does. It
actually determines which of the sheets rows will appear in the freeze pane,
it does not scroll the display up so that you can see, for example, row 40
displayed on the worksheet when the user opens it using Excel.
Instead, try this.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package workbookprotection;
import java.io.*;
import org.apache.poi.hssf.usermodel.*;
/**
*
* @author win user
*/
public class ActiveCellTest {
public ActiveCellTest(String filename) throws IOException {
File file = null;
FileOutputStream fos = null;
HSSFWorkbook workbook = null;
HSSFSheet sheet = null;
HSSFRow row = null;
HSSFCell cell = null;
int rowIndex = 0;
int colIndex = 0;
int numCols = 15;
int numRows = 50;
try {
workbook = new HSSFWorkbook();
sheet = workbook.createSheet("Active Cell Test");
while(rowIndex < numRows) {
row = sheet.createRow(rowIndex);
while(colIndex < numCols) {
cell = row.createCell(colIndex);
cell.setCellValue(rowIndex + ", " + colIndex);
colIndex++;
}
rowIndex++;
colIndex = 0;
}
// Create the freeze pane. Thismethod has four parameters.
// The first defines the index number of the column that should
be
// locked. Passing zero will not lock any columns, pass 1 to
lock
// lock column A, 2 to lock A and B, etc.
// The second parameter defines the number of rows to lock. Pass
1
// to lock row 1, 2 to lock rows 1 and 2, etc.
// The fourth parameter defines the index number of the left
most
// column that is visible in the pane. Pass 0 to start at column
// A, 1 to start at column B, etc
// The fourth parameter defines the index number of the row
which
// will be shown as the first row in the display. Pass 0 to show
// the first row, 1 to show the second, etc.
sheet.createFreezePane(0, 4, 0, 10);
file = new File(filename);
fos = new FileOutputStream(file);
workbook.write(fos);
}
finally {
if(fos != null) {
fos.close();
fos = null;
}
}
}
}
Yours
Mark B
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/ShowInPane-with-rows-locked-tp3423129p3424961.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]