Reputation: 39
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file));
HSSFSheet s = wb.getSheetAt(0);
wb.setActiveSheet(0);
s.showInPane(0, 0);
FileOutputStream out = new FileOutputStream(file);
wb.write(out);
out.close();
I am using above code for taking focus to first cell (when I open excel first cell shouldd be selected). It is opening the excel correctly because of showInPane
, but selecting the first cell is not working.
Upvotes: 3
Views: 4174
Reputation: 21
I recently stumbled on the same problem using POI 3.14. For me this worked:
sheet.setActiveCell(new CellAddress(0, 0));
Upvotes: 2
Reputation: 6554
Something like this
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file));
HSSFSheet s = wb.getSheetAt(0);
s.setActive(true);
HSSFRow row = s.getRow(0);
HSSFCell cell = row.getCell(0);
cell.setAsActiveCell();
FileOutputStream out = new FileOutputStream(file);
Upvotes: 2