资源简介
用Java程序读取Excel表格里的内容并显示在Swing界面里。
代码片段和文件信息
package com.bpsoft.terence;
import java.io.FileInputStream;
import java.io.InputStream;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
public class Read {
private jxl.Workbook rwb = null;
private int colCnt = 0;
public int getColCount(int sheetIndex) {
try {
jxl.Sheet rs = rwb.getSheet(sheetIndex);
colCnt = rs.getColumns();
} catch (Exception e) {
colCnt = 0;
} finally {
try {
} catch (Exception e) {
colCnt = 0;
}
}
return colCnt;
}
public int getRowCount(int sheetIndex) {
try {
jxl.Sheet rs = rwb.getSheet(sheetIndex);
colCnt = rs.getRows();
} catch (Exception e) {
colCnt = 0;
} finally {
try {
} catch (Exception e) {
colCnt = 0;
}
}
return colCnt;
}
public boolean openExcel(String fileName) {
boolean Rtn = false;
try {
InputStream is = new FileInputStream(fileName);
rwb = Workbook.getWorkbook(is);
Rtn = true;
} catch (Exception e) {
Rtn = false;
} finally {
try {
} catch (Exception e) {
}
}
return Rtn;
}
public String getCellContent(int col int row) {
String cellContent = ““;
try {
Sheet rs = rwb.getSheet(0);
Cell c00 = rs.getCell(col row);
cellContent = c00.getContents();
} catch (Exception e) {
cellContent = ““;
} finally {
try {
} catch (Exception e) {
cellContent = ““;
}
}
return cellContent;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 296 2010-12-27 16:56 ReadExcel\.classpath
文件 385 2010-12-27 17:41 ReadExcel\.project
文件 126 2010-12-29 11:11 ReadExcel\.settings\org.eclipse.core.resources.prefs
文件 1759 2010-12-29 16:40 ReadExcel\bin\com\bpsoft\terence\Read.class
文件 664 2010-12-29 14:49 ReadExcel\bin\com\bpsoft\terence\ReadExcel.class
文件 2224 2010-12-29 17:23 ReadExcel\bin\com\bpsoft\terence\TableTest.class
文件 2539 2010-12-29 14:26 ReadExcel\bin\com\bpsoft\terence\Table_Model.class
文件 685 2010-12-29 14:26 ReadExcel\bin\com\bpsoft\terence\Test$1.class
文件 685 2010-12-29 14:26 ReadExcel\bin\com\bpsoft\terence\Test$2.class
文件 685 2010-12-29 14:26 ReadExcel\bin\com\bpsoft\terence\Test$3.class
文件 4498 2010-12-29 14:26 ReadExcel\bin\com\bpsoft\terence\Test.class
文件 899 2010-12-30 10:29 ReadExcel\bin\com\bpsoft\terence\TestFomart.class
文件 1476 2010-12-29 16:40 ReadExcel\src\com\bpsoft\terence\Read.java
文件 411 2010-12-29 14:49 ReadExcel\src\com\bpsoft\terence\ReadExcel.java
文件 1333 2010-12-29 17:23 ReadExcel\src\com\bpsoft\terence\TableTest.java
文件 5215 2010-12-29 13:44 ReadExcel\src\com\bpsoft\terence\Test.java
文件 328 2010-12-30 10:29 ReadExcel\src\com\bpsoft\terence\TestFomart.java
目录 0 2011-01-04 16:04 ReadExcel\bin\com\bpsoft\terence
目录 0 2011-01-04 16:04 ReadExcel\src\com\bpsoft\terence
目录 0 2011-01-04 16:04 ReadExcel\bin\com\bpsoft
目录 0 2011-01-04 16:04 ReadExcel\src\com\bpsoft
目录 0 2011-01-04 16:04 ReadExcel\bin\com
目录 0 2011-01-04 16:04 ReadExcel\src\com
目录 0 2011-01-04 16:04 ReadExcel\.settings
目录 0 2011-01-04 16:04 ReadExcel\bin
目录 0 2011-01-04 16:04 ReadExcel\src
目录 0 2011-01-04 16:04 ReadExcel
----------- --------- ---------- ----- ----
24208 27
............此处省略0个文件信息
- 上一篇:天气预报,xm
l解析 - 下一篇:java socket实现的点对点文件传输
评论
共有 条评论