java中Excel2007和2003的導入

必須的jar包下載鏈接:

http://archive.apache.org/dist/poi/release/bin/poi-bin-3.8-20120326.zip

/**
	 * 
	 * 讀取Excel的內容,第一維數組存儲的是一行中格列的值,二維數組存儲的是多少個行
	 * @param file讀取數據的源Excel
	 * @param ignoreRows讀取數據忽略的行數,比喻行頭不需要讀入 忽略的行數爲1
	 * @return 讀出的Excel中數據的內容
	 * @throws FileNotFoundException
	 * @throws IOException
         * @throws XmlException
	 */
	public static String[][] getData(File file, int ignoreRows)
			throws FileNotFoundException, IOException, XmlException,InvalidFormatException {
		List<String[]> result = new ArrayList<String[]>();
		int rowSize = 0;
		BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
		// 打開HSSFWorkbook,Excel2003用的方法
		// POIFSFileSystem fs = new POIFSFileSystem(in);
		// HSSFWorkbook wb = new HSSFWorkbook(fs);
		// HSSFCell cell = null;
		
		Cell cell = null;
		Row row = 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章