java读写excel,解决poi包中没有org.apache.poi.ss.usermodel.CellType的问题

POI版本为3.8;
jar包导入之后XSSFWorkbook可以正常使用了,但出现了The import org.apache.poi.ss.usermodel.CellType cannot be resolved 
代码中 
cellRowName.setCellType(CellType.STRING); // 设置单元格值的类型 
style.setAlignment(HorizontalAlignment.CENTER); // 设置水平对齐的样式为居中对齐; 
 报错,原来是代码所用POI版本低的缘故;
高版本的import org.apache.poi.ss.usermodel.CellType变为了import org.apache.poi.ss.usermodel.Cell; 
同时cellRowName.setCellType(CellType.STRING);变为了cellRowName.setCellType(Cell.CELL_TYPE_STRING);

你可能感兴趣的:(java)