<span style="white-space:pre"> </span>InputStream is=new FileInputStream("C:\\Users\\DuoNuo\\Desktop\\新三板\\新闻\\baidu.com.xls");
Workbook wb=new XSSFWorkbook(is);
Sheet sheet=wb.getSheetAt(0);
//忽略表头读取行
for(int i=1;i<=sheet.getLastRowNum();i++){
BaiDuNewsEntity entity=new BaiDuNewsEntity();
Row row=sheet.getRow(i);
Cell company=row.getCell(1);
Cell title=row.getCell(2);
Cell source=row.getCell(3);
Cell date=row.getCell(4);
Cell url=row.getCell(5);
entity.setCompany(company==null?"":company.getStringCellValue());
entity.setTitle(title==null?"":title.getStringCellValue());
entity.setSource(source==null?"":source.getStringCellValue());
entity.setDate(date==null?"":date.getStringCellValue());
entity.setUrl(url==null?"":url.getStringCellValue());
System.out.println(entity.toString());
java读取xls表格数据
最新推荐文章于 2021-07-09 17:10:03 发布