我在我的Struts 1.3.10项目中使用Apache-poi 3.9。 我有两个错误,当我在这个功能编译:Apache-poi“编译错误:类型不匹配”
private boolean parserHSSFSheet(HSSFSheet pageAccord, StringBuffer idPaa, StringBuffer idGroupe,
StringBuffer idFournisseur, StringBuffer idFamille, StringBuffer periode, Map<Integer, Marque> mapMarque,
Map<Integer, Ristournable> mapRistournable, Map<Integer, PerimetreProduitEnum> mapTypeDeclaration,
Map<Integer, FamilleDeProduitsNomenclature> mapFamille, Map<Integer, String> mapMarqueProduit,
TreeMap<Integer, TreeMap<Integer, BigDecimal>> mapColonneAdherentMontant,
TreeMap<Integer, BigDecimal> mapAdherentQuantite) throws Exception {
...
for (Iterator<HSSFRow> rit = pageAccord.rowIterator(); rit.hasNext();) {
HSSFRow row = (HSSFRow) rit.next();
String typeCellule = "";
for (Iterator<HSSFCell> cit = (Iterator<HSSFCell>) row.cellIterator(); cit.hasNext();) {
HSSFCell cell = cit.next();
if (cell.getCellNum() == ((short) 0)) {
...
}
错误:
pageAccord.rowIterator();
Type mismatch: cannot convert from Iterator to Iterator
而且
(Iterator<HSSFCell>) row.cellIterator();
Cannot cast from Iterator to Iterator
按http://poi.apache.org/spreadsheet/如果你有一个'File',quick-guide.html#FileInputStream不使用'InputStream'! – Gagravarr
从3.14版本的POI依赖关系解决了这个问题,如果有人使用低于版本,那么这是解决方案。我正在使用3.9库到我的项目,文件不可能。 –