【java随笔记录】excel读取

2021/6/18 9:59:38

本文主要是介绍【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());
		}
	}
	   

  



这篇关于【java随笔记录】excel读取的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程