jxl讀取excel
<PRE style="BACKGROUND-COLOR: #c5c5c5; FONT-WEIGHT: bold" class=java name="code">import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException;
/**
- @author 劉毅
- @date 2010-2-25
- @ClassName JxlForReaderExcel.java
- @Email liu_yi126@163.com
- @param 讀取excel
@param */ public class JxlReaderForExcel {
public static void readerExcel() { Workbook wb; try { wb = Workbook.getWorkbook(new File("src/out.xls")); Sheet s = wb.getSheet(0);// 第1個sheet Cell c; int row = s.getRows();// 總行數 int col = s.getColumns();// 總列數 for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { c = s.getCell(j,i); System.out.print(c.getContents() + " "); } //換行 System.out.println(); } } catch (BiffException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public static void main(String[] args) { JxlReaderForExcel.readerExcel(); } }</PRE>