首页 > 代码库 > JXL读取Excel——(二)

JXL读取Excel——(二)

Jar包

同一一样

Java代码

 1 package JXL;
 2 import java.io.File;
 3 import java.io.IOException;
 4 
 5 import jxl.Cell;
 6 import jxl.Sheet;
 7 import jxl.Workbook;
 8 import jxl.read.biff.BiffException;
 9 
10 public class ReadExcel {
11     public static void main(String[] args) {
12         try {
13             Workbook workbook = Workbook.getWorkbook(new File("e:/JXL_TEST.xls"));
14             Sheet sheet = workbook.getSheet(0);
15             for (int i=0;i<sheet.getRows();i++){
16                 for(int j=0;j<sheet.getColumns();j++){
17                     Cell cell = sheet.getCell(j, i);
18                     System.out.print(cell.getContents()+"  ");
19                 }
20                 System.out.println();
21             }
22             workbook.close();
23         } catch (Exception e) {
24             // TODO Auto-generated catch block
25             e.printStackTrace();
26         }
27     }
28 }

 结果:

技术分享

JXL读取Excel——(二)