jxl Excel에서 데이터 읽기

1091 단어
간단명료하게 jxl 기록을 사용합니다.
pom에jar를 넣다
<dependency>
	<groupId>net.sourceforge.jexcelapi</groupId>
	<artifactId>jxl</artifactId>
	<version>2.6.12</version>
</dependency>

호출하면 돼요.
package jxl;

//  excel
//  Excel 
import java.io.File;

import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class Jxl {

	public static void main(String args[]) {
		readExcel();
	}

	/**
	 *  excel
	 */
	public static void readExcel() {
		try {
			Workbook book = Workbook.getWorkbook(new File("C:/Users/admin/Desktop/media_yuan.xls"));
			//  
			Sheet sheet = book.getSheet(0);
			//  
			Cell[] column = sheet.getColumn(4);

			for (int i = 0; i < column.length; i++) {
				System.out.println(column[i].getContents());
			}
			// Cell cell1 = sheet.getCell(0, 0);
			// String result = cell1.getContents();
			// System.out.println(result);
			book.close();
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}

좋은 웹페이지 즐겨찾기