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

查看:138
本文介绍了专注于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,而是选择第一个单元格不起作用。

解决方案

我最近偶然发现使用POI 3.14的同样的问题。
对我来说这是有效的:



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


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.

解决方案

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天全站免登陆