【发布时间】:2017-04-20 00:17:31
【问题描述】:
我想使用 apache poi 从 excel 中读取数据并将该数据存储到二维字符串数组中。使用下面的代码,我将显示数据,但我想存储数据。
public static void main(String[] args) throws Exception {
File f = new File("C:/Users/SYKAMREDDY/Desktop/testData.xls");
FileInputStream fis = new FileInputStream(f);
HSSFWorkbook wb = new HSSFWorkbook(fis);
HSSFSheet sh = wb.getSheet("Data");
int rc=sh.getLastRowNum()-sh.getFirstRowNum();
for (int i = 1; i < rc; i++) {
Row r = sh.getRow(i);
for (int j = 1; j < r.getLastCellNum(); j++) {
String s = r.getCell(j).getStringCellValue();
System.out.print(s+" ");
}
System.out.println();
}
}
【问题讨论】:
-
您面临的问题是什么?如果是,数据是否被成功读取,您希望达到什么目的?