【java随笔记录】excel读取


     /**
	 * 
	 * @param file 
	 * @param index 列(0开始)
	 * @throws Exception
	 */
	public static void 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();//获取行
		String[] phone = new String[rows];
		for(int i = 1; i<rows; i++) {
			Cell cell = sheet.getCell(index, i);
			System.out.println(cell.getContents());
		}
	}
	   

  

posted @ 2021-06-18 09:26  闻名遐迩  阅读(21)  评论(0)    收藏  举报