开发者

Focus on first cell in excel

开发者 https://www.devze.com 2023-03-04 22:14 出处:网络
HSSFW开发者_运维问答orkbook wb = new HSSFWorkbook(new FileInputStream(file)); HSSFSheet s = wb.getSheetAt(0);
HSSFW开发者_运维问答orkbook 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.


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


I recently stumbled on the same problem using POI 3.14. For me this worked:

sheet.setActiveCell(new CellAddress(0, 0));

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号