?1
import?java.io.FileInputStream;
?2
import?java.io.InputStream;
?3
?4
import?jxl.Cell;
?5
import?jxl.Sheet;
?6
import?jxl.Workbook;
?7
?8
/**
?9
?*?@author?wufalong
10
?*?2007-9-3
11
?*/
12
public?class?Excel
13
{
14
????public?static?void?main(String[]?args)
15
????{
16
????????try
17
????????{
18
????????????String?sourcefile?=?"c://test.xls";
19
????????????InputStream?is?=?new?FileInputStream(sourcefile);
20
????????????jxl.Workbook?rwb?=?Workbook.getWorkbook(is);
21
????????????//獲得總的Sheets,得到sheet的層數
22
????????????Sheet[]?sheets?=?rwb.getSheets();
23
????????????int?sheetLen?=?sheets.length;
24
????????????//獲得第一個Sheets?的結果
25
????????????jxl.Sheet?rs?=?rwb.getSheet(0);?
26
????????????int?num?=?rs.getRows();//得到行數
27
????????????for(int?j=0;j
<
num
;j++)
28
????????????{
29
????????????????Cell[]?cell?
=?rs.getRow(j);//得到第一行的所有值
30
????????????????
String?value?
=?cell[0].getContents();//得到第一行,第一列的值
31
????????????????
System.out.println("Values:"+rs.getRow(j)[0].getContents());
32
????????????}
33
????????}
34
????????catch(Exception?ex)
35
????????{
36
????????????????ex.printStackTrace();
37
????????}
38
????}
39
}

?2

?3

?4

?5

?6

?7

?8

?9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39
