package parser;
import java.io.File;
import java.util.Vector;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
public class Autoparser {
Vector<Autolist> autolist=new Vector<Autolist>();
Sheet sheet;
public void load(String pfad,int i){
//Einlesen der XLS Datei mit Blatt nr
try {
Workbook workbook = Workbook.getWorkbook(new File(pfad));
this.sheet=workbook.getSheet(i);
} catch (Exception e) {}
int nr=3;
Cell zelle=null;
boolean run=true;
Vector<Auto> autos=new Vector<Auto>();
while(run){
try {zelle=sheet.getCell(0,nr);}
catch (Exception e) {
autolist.add(new Autolist(autos));
System.out.println(autos.get(0).fuid);
break;
}
autos.add(getauto(nr));
//sSystem.out.println(autos.size());
if(!zelle.getContents().equals(sheet.getCell(0,nr-1).getContents())){
System.out.println(autos.get(0).fuid);
autolist.add(new Autolist(autos));
System.out.println(autolist.get(0).autos.get(0).fuid);
System.out.println("neu");
//autos=new Vector<Auto>();
autos.removeAllElements();
}
nr++;
}
}
public Auto getauto(int nr){
//Ein Auto wird erschaffen, so schnell geht das
return new Auto(sheet.getCell(0,nr).getContents(),sheet.getCell(1,nr).getContents(),sheet.getCell(2,nr).getContents(),
sheet.getCell(3,nr).getContents(),sheet.getCell(4,nr).getContents(),sheet.getCell(5,nr).getContents(),sheet.getCell(6,nr).getContents(),
sheet.getCell(7,nr).getContents(),sheet.getCell(8,nr).getContents(),sheet.getCell(9,nr).getContents(),sheet.getCell(10,nr).getContents(),
sheet.getCell(11,nr).getContents(),sheet.getCell(12,nr).getContents(),sheet.getCell(13,nr).getContents(),sheet.getCell(14,nr).getContents(),
sheet.getCell(15,nr).getContents(),sheet.getCell(16,nr).getContents(),sheet.getCell(17,nr).getContents());
}
public static void main(String[] args) {
Autoparser ap=new Autoparser();
ap.load("test_datei3.xls",0);
//System.out.println(ap.autolist.get(0).autos.get(2).sid);
System.out.println(ap.autolist.get(0).autos.get(0).fuid);
System.out.println(ap.autolist.get(1).autos.get(0).fuid);
System.out.println(ap.autolist.get(2).autos.get(0).fuid);
}
}
package parser;
import java.util.Vector;
class Auto {
public String ffid,sid,fuid,swf,fubzws,typ,fgbzwbg,fbzwb,d,l,tun,wg,verh,zeit,rb,wfuerk,klartext,dcode;
public Auto(String ffid, String sid, String fuid, String swf,
String fubzws, String typ, String fgbzwbg, String fbzwb, String d,
String l, String tun, String wg, String verh, String zeit,
String rb, String wfuerk, String klartext, String dcode) {
this.ffid = ffid;
this.sid = sid;
this.fuid = fuid;
this.swf = swf;
this.fubzws = fubzws;
this.typ = typ;
this.fgbzwbg = fgbzwbg;
this.fbzwb = fbzwb;
this.d = d;
this.l = l;
this.tun = tun;
this.wg = wg;
this.verh = verh;
this.zeit = zeit;
this.rb = rb;
this.wfuerk = wfuerk;
this.klartext = klartext;
this.dcode = dcode;
}
}
class Autolist{
Vector<Auto> autos=new Vector<Auto>();
public Autolist(Vector<Auto> autos) {
this.autos = autos;
}
}