📄 readrecord.java
字号:
package net.aetherial.gis.jiaotongbu.input.jxl;
import jxl.Workbook;
import jxl.Cell;
import jxl.*;
import java.io.File;
import jxl.read.biff.*;
import java.io.*;
import net.aetherial.gis.jiaotongbu.input.publicuse.Item;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ReadRecord {
protected Sheet mySheet = null;
protected int row = 0;
protected String[] head = null;
protected boolean error = false;
protected String errorString = "";
public ReadRecord(Sheet sheet) {
this.mySheet = sheet;
this.setHead();
}
public void setRow(int row){
this.row = row;
}
public String getID(){
return mySheet.getCell(0,row).getContents();
}
public String getXiangzhenName(){
return mySheet.getCell(1,row).getContents();
}
public String getName(){
return mySheet.getCell(2,row).getContents();
}
public String getRoadName(){
return mySheet.getCell(3,row).getContents();
}
public String getLongitude(){
return mySheet.getCell(4,row).getContents();
}
public String getLatitude(){
return mySheet.getCell(5,row).getContents();
}
public String getAltitude(){
return mySheet.getCell(6,row).getContents();
}
protected void setHead(){
Cell[] title = mySheet.getRow(0);
if (title == null) {
this.error = true;
this.errorString = this.errorString + "表格的标题取不出来.\r\n";
}else{
this.head = new String[title.length];
for (int i = 0; i < title.length; i++) {
this.head[i] = title[i].getContents();
}
}
}
private void test(){
// Cell cell = mySheet.getCell(1,1);
}
public String[] getAll(){
String[] all = new String[7];
all[0] = this.getID();
all[1] = this.getXiangzhenName();
all[2] = this.getName();
all[3] = this.getRoadName();
all[4] = this.getLongitude();
all[5] = this.getLatitude();
all[6] = this.getAltitude();
this.row ++;
return all;
}
public static void main(String args[]){
Item.setJianzhicun("E:\\test\\建制村.xls");
ReadRecord rr = new ReadRecord(Item.getJianzhicunSheet());
String[] temp = null;
rr.test();
// System.out.println("rows:" + rr.mySheet.getRows());
for (int i = 0; i < 100; i++) {
temp = rr.getAll();
for (int j = 0; j < temp.length; j++) {
System.out.print(temp[j]);
if (j<temp.length -1) {
System.out.print(",");
}else{
System.out.print(";");
}
}
System.out.println("");
File f = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -