专注于excel中的第一个单元格

时间:2021-09-06 22:20: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.

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

3 个解决方案

#1


2  

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

#2


2  

Similar question with the original poster posting about the solution he found in the POI mailing list archive.

与他在POI邮件列表档案中找到的解决方案的原始海报张贴相似的问题。

#3


2  

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

我最近使用POI 3.14偶然发现了同样的问题。对我来说,这工作:

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

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

#1


2  

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

#2


2  

Similar question with the original poster posting about the solution he found in the POI mailing list archive.

与他在POI邮件列表档案中找到的解决方案的原始海报张贴相似的问题。

#3


2  

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

我最近使用POI 3.14偶然发现了同样的问题。对我来说,这工作:

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

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