[英]How to read and write simultaneously from excel?
How to read and write simultaneously from excel? 如何同时从Excel读取和写入? Scenario: Search "Facebook","Yahoo" in google search bar and write the title.
场景:在Google搜索栏中搜索“ Facebook”,“ Yahoo”并输入标题。 For Both reading data and writing the title same excel should be used.
对于读取数据和写入标题都应使用相同的excel。 Currently using Apache POI for file-handling.
当前使用Apache POI进行文件处理。
To read excel cell data use smth like this: 要读取excel单元格数据,请使用smth,如下所示:
File excel = null;
FileInputStream file = null;
try {
excel = new File(dir + "\\" + filename + ".xls");
file = new FileInputStream(excel);
Workbook workbook = WorkbookFactory.create(file);
Sheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
// Cell data logic
}
}
} catch (FileNotFoundException fn) {
fail(fn.getMessage());
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
file.close();
}
How to write date here is a good example: click 这里的日期写法是一个很好的例子: 单击
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.