https://mvnrepository.com/tags/maven
maven仓库搜索jxl
注:xlsx格式 csv格式 转存为xls格式后使用
/**
*
* @param file 文件
* @param index 列
* @throws Exception
*/
public static List<Object> readColumn(File file, int index) throws Exception {
InputStream inputStream = new FileInputStream(file.getAbsoluteFile());
Workbook workbook = Workbook.getWorkbook(inputStream);
Sheet sheet = workbook.getSheet(0);
int rows = sheet.getRows();
ArrayList<Object> list=new ArrayList<>();
for (int i = 1; i < rows; i++) {
Cell cell = sheet.getCell(index, i);
list.add(cell.getContents());
}
return list;
}
传入一个文件 并给出要读取第几列