📄 readfile.java
字号:
package net.aetherial.gis.our.duibi.readXLS;
import jxl.Sheet;
import jxl.Cell;
import java.io.File;
import java.io.IOException;
import jxl.read.biff.BiffException;
import jxl.Workbook;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ReadFile {
/**
* 数据所在的工作表Sheet
*/
protected Sheet mySheet = null;
/**
*
*/
protected Cell[] rowData = null;
/**
* 记录所读取的行
*/
protected int row = 0;
/**
* 行数据(不是表格抬头部分)的第一行,所在的位置(行)
*/
protected int baseRow = 8;
public ReadFile() {
}
public ReadFile(Sheet sheet) {
this.mySheet = sheet;
}
public void setSheet(Sheet sheet){
this.mySheet = sheet;
}
public void moveNext(){
this.row ++;
try {
rowData = this.mySheet.getRow(row);
}
catch (Exception ex) {
}
}
public void movePrevious(){
this.row --;
rowData = this.mySheet.getRow(row);
}
public void setSheet(String fileName,String sheetName){
Workbook workbook = null;
try {
workbook = Workbook.getWorkbook(new File(fileName));
}
catch (BiffException ex) {
System.err.println(ex.getMessage() + " in ReadFile.setSheet(String fileName,String sheetName) BiffException");
}
catch (IOException ex) {
System.err.println(ex.getMessage() + " in ReadFile.setSheet(String fileName,String sheetName) IOException");
}
if (workbook != null) {
this.mySheet = workbook.getSheet(sheetName);
}else{
this.mySheet = null;
}
}
/**
* 判断当前行是否为空数据行
* Judge if present row data is empty contents.
* 如果是空数据行,返回true;
*/
public boolean isEmptyrow(){
boolean empty = true;
if (rowData != null) {
if (rowData.length < 15) {
return true;
}
for (int i = 0; i < rowData.length; i++) {
if (!(rowData[i].getContents().equals(""))) {
empty = false;
break;
}
}
}else{
return true;
}
return empty;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -