【发布时间】:2019-03-14 17:49:05
【问题描述】:
我正在 Netbeans 上使用 Java 开发一个小应用程序,我需要将 Excel 文件的数据导出到一个数组,然后处理这个数组。 为了得到excel,我使用Apache POI,我可以在consol中显示excel文件的值。
但是,我需要将它放在一个数组中,目前我不知道如何使用迭代器,因为我正在将 excel 数据放入一个迭代器中。
Workbook workbook = WorkbookFactory.create(new File(pathConfig1));
//File
Iterator<Sheet> sheetIterator = workbook.sheetIterator();
Sheet sheet = workbook.getSheetAt(nbSheet1);
//Get index sheet user
Iterator<Row> rowIterator = sheet.rowIterator();
int nbLine= sheet.getLastRowNum() +1;
//Number of Lines
int nbCol = sheet.getRow(0).getLastCellNum();
// Number of columns
String [][]data= new String[nbLine][nbCol];
//Array for the data
从这一点来看,我真的不知道如何导出数组中的数据... 任何想法 ?
我想使用 2 循环,但我不知道如何增加我的迭代器...
【问题讨论】:
标签: java arrays excel iterator