?? opflowreader.java
字號:
package com.corba.mnq.xls;
import java.io.File;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
public class OpFlowReader {
public static String EOF = OpFlowWriter.EOF;
public static String SHEET = OpFlowWriter.SHEET;
private int currentLine = 1; // 0 was reserved by writeOp
private static common.Logger logger = common.Logger
.getLogger(OpFlowReader.class);
private File file;
private Workbook book;
private Sheet sheet;
class FlowItemStruct {
public String type;
public String value1;
public String value2;
}
public boolean open(String fileName) {
try {
logger.setSuppressWarnings(Boolean.getBoolean("jxl.nowarnings"));
file = new File(fileName);
book = Workbook.getWorkbook(file);
sheet = book.getSheet(SHEET);
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
}
public String getFlowType() {
Cell cell = sheet.getCell(0, 0);
return cell.getContents();
}
public FlowItemStruct getNextItem() {
FlowItemStruct ret = new FlowItemStruct();
Cell cell = sheet.getCell(0, currentLine);
ret.type = cell.getContents();
cell = sheet.getCell(1, currentLine);
ret.value1 = cell.getContents();
cell = sheet.getCell(2, currentLine);
ret.value2 = cell.getContents();
currentLine++;
return ret;
}
public boolean eof() {
Cell cell = sheet.getCell(0, currentLine);
return cell.getContents().equals(EOF);
}
public boolean close() {
book.close();
return true;
}
/**
* @param args
*/
public static void main_(String[] args) {
OpFlowReader op = new OpFlowReader();
op.open("test1.xls");
String type = op.getFlowType();
System.out.println("flowtype=" + type);
while (!op.eof()) {
OpFlowReader.FlowItemStruct ps = op.getNextItem();
System.out.println(ps.type + "," + ps.value1 + "," + ps.value2);
}
op.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -