这是我的问题:如何将Excel文件中的单元格(字符串)值附加到JTextArea?
我尝试从Excel文件中循环的单元格中追加值。我用这部分代码:
Workbook workbook = new HSSFWorkbook(new FileInputStream(fileChooser.getSelectedFile()));
Sheet sheet = workbook.getSheetAt(0);
for(Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();)
{
Row row = rit.next();
for(Iterator<Cell> cit = row.cellIterator(); cit.hasNext();)
{
Cell cell = cit.next();
cell.setCellType(Cell.CELL_TYPE_STRING);
while(cit.hasNext())
{
notatnik.append(String.valueOf(cell.getSheet().toString()) + "\n");
}
System.out.print(cell.getStringCellValue() + "\t");
}
System.out.println();
}
但它只是回来值“1”或“[email protected]”。在Excel中我举例如下: 1 SP25 kp 5 6.5等
我该怎么办,从Excel中取回这个值到JTextArea?
PS。我使用POI 3.10库。
谢谢,我试了一下。 Noo我只使用“System.print.put(...)”检查此方法是否工作:) – 2014-10-17 18:01:49