导入:
public List<Shipment> readXls(InputStream is,Integer userId,Integer prodId) throws IOException,
InvalidFormatException {
List<Shipment> shipments=new ArrayList<Shipment>();
HSSFWorkbook book = new HSSFWorkbook(is);
HSSFSheet sheet = book.getSheetAt(0);
tRowNum()+1; i++) {
HSSFRow row = sheet.getRow(i);
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
String uuid = row.getCell(0).getStringCellValue(); //名称
String dealerName = row.getCell(1).getStringCellValue(); //url
String prodName = row.getCell(2).getStringCellValue();
Shipment shipment=new Shipment();
shipment.setUuid(uuid);
shipment.setDealerName(dealerName);
shipment.setProdName(prodName);
shipment.setUserId(userId);
shipment.setProdId(prodId);
shipment.setCreated(new Date());
shipment.setUpdated(new Date());
shipments.add(shipment);
}
for (Shipment shipment : shipments) {
System.err.println(shipment);
}
return shipments;
}
原文:https://www.cnblogs.com/kongfanbing/p/11599854.html