专注于excel中的第一个单元格 [英] Focus on first cell in excel

查看:27
本文介绍了专注于excel中的第一个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我使用上面的代码将焦点移到第一个单元格(当我打开 excel 时应该选择第一个单元格).由于 showInPane,它正确打开了 excel,但选择第一个单元格不起作用.

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.

推荐答案

我最近在使用 POI 3.14 时偶然发现了同样的问题.对我来说这有效:

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

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

这篇关于专注于excel中的第一个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆