アットウィキロゴ

p082208

package car;
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
 
 
public class pro {
 
String date;
    String[] data=new String[5000];
   int s,datanumber,number; 
     int[] link=new int[5000];
String[][] mat=new String[500][700]; 
     int pa;
 
       String[] year=new String[5000];
       String[] month=new String[5000];
           int maxy=100;
           int maxx=100;
 
int fastline,lastline,creditline,fastlinex;
int creditx,credity,indexline,indexlinex;
 
 
String[] index=new String[5000];
String[] credit=new String[5000];
    public static void main(String[] args) {
        pro test=new pro();
    }
 
    pro(){
 
 
        maxx=100;
        maxy=100;
 
        int page;
 
        for(page=1;page<255;page++){
 
    readxls sub2=new readxls();
    sub2.maxx=maxx;
    sub2.maxy=maxy;
    sub2.makedata("data/"+page+".xls",0);
    mat=sub2.mat;
 
    int sx;
 
    fastline=0;
    for(s=1;s<maxy;s++){
    for(sx=1;sx<20;sx++){
    if(mat[s][sx].indexOf("穀")>-1)fastline=s-1;     
    if(mat[s][sx].indexOf("穀")>-1)indexline=sx;  
    }}
 
    lastline=0;
    for(s=1;s<maxy;s++){
    if(mat[s][indexline].indexOf("分")>-1)lastline=s;       
    }
 
   System.out.println(fastline);
   System.out.println(lastline);
 
   for(s=fastline;s<lastline+1;s++){    
   index[s]=mat[s][indexline]+mat[s][indexline+1];
   }
 
 
 
 
    for(s=1;s<fastline;s++){
    for(sx=indexline+1;sx<20;sx++){
    if(mat[s][sx].indexOf("営")>-1)creditline=s;       
    }}
 
 
    for(sx=indexline+1;sx<20;sx++){
    if(mat[creditline][sx].indexOf("合")>-1)creditx=sx;       
    if(mat[creditline+1][sx].indexOf("合")>-1)creditx=sx; 
    }
 
 
 
 
   System.out.println(creditline);
   System.out.println(creditx);
 
 
   date="";
    for(s=1;s<creditline;s++){
    for(sx=1;sx<10;sx++){
    if(mat[s][sx].indexOf("年")>-1) date=mat[s][sx];       
    }}
 
 
 
 
 
    for(sx=creditx+1;sx<20;sx++){    
    if(mat[creditline+2][sx].indexOf("車")>-1)credity=sx;  
    }
 
 
 
    System.out.println(credity);
 
    for(sx=creditx;sx<credity+1;sx++){    
    credit[sx]=mat[creditline][sx];
    }
 
 
   credit[creditx]="";
    for(sx=creditx+1;sx<credity+1;sx++){    
    if(credit[sx].length()<1)credit[sx]=credit[sx-1];
    }
 
 
 
    for(sx=creditx;sx<credity+1;sx++){    
    credit[sx]=credit[sx]+mat[creditline+1][sx]+mat[creditline+2][sx];
    }
 
 
   for(sx=creditx;sx<credity+1;sx++){    
   System.out.println(credit[sx]);
   }
 
 
 
   writexml("gdata/"+page+".txt");
 
 
    }
 
 
}
 
      void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=fastline;s<lastline+1;s++){  
for(sx=creditx;sx<credity+1;sx++){ 
pw.print("<date>"); 
pw.print(date); 
pw.print("</date>"); 
pw.print("<credit>");
pw.print(credit[sx]);
pw.print("</credit>"); 
pw.print("<index>");
pw.print(index[s]);
pw.print("</index>"); 
pw.print("<value>");
pw.print(mat[s][sx]); 
pw.println("</value>");
}
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
}
 
package car;
 
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
 
public class readxls {
 
int maxx,maxy;
Cell cc;
String[][] mat=new String[50000][500]; 
int[][] color= new int[50000][500];
 
void makedata(String file,int number){   
 
 
 
      try{
 
     FileInputStream is = new FileInputStream(file);
     Workbook wb = new HSSFWorkbook(is);
      Sheet sh = wb.getSheetAt(number);
 
      int s,sx,j,h;
      String bb;
 
 
      CellStyle style = wb.createCellStyle();
 
          for(s=1;s<maxy+1;s++){
           for(sx=1;sx<maxx+1;sx++){
          mat[s][sx]="";
           }}
 
      for(s=1;s<maxy+1;s++){
  Row row = sh.getRow(s-1);
  j=0;
  if(row==null)j=100;
  if(j<50){
  for(sx=1;sx<maxx+1;sx++){  
  cc = row.getCell(sx-1);
  h=0;
  if(cc==null)h=100;
  if(h<50){
  int type =cc.getCellType();
   bb="";
  if(type==1)bb=cc.getStringCellValue();
  if(type==0)bb=""+cc.getNumericCellValue();
 
  short n1=cc.getCellStyle().getFillBackgroundColor();
 
  color[s][sx]=(int)n1;
  mat[s][sx]=bb;
  }
  }
  }
  }
 
 
 
 
 
  } catch (Exception e) {e.printStackTrace();}
 
 
 
 
 
 
 
 }
}
 
最終更新:2015年08月22日 18:04