jxl讀取excel

openkk 13年前發布 | 1K 次閱讀 檢查工具

<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>

 本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!