アットウィキロゴ

しゅp999

package monmo;
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
 
 
public class pro {
 
      String[][] mat=new String[500][700]; 
    int maxx,maxy;
  String[] credit=new String[700]; 
    String[] pref=new String[700]; 
  int fastline,lastline;
  int creditx,credity;
  int tr;
     String[] bus=new String[700]; 
    int yy;
 
    public static void main(String[] args) {
        pro t=new pro();
 
 
 
    }
 
pro(){
 
    int delta=0;
 
    maxx=100;
    maxy=100;
 
    int tr;
    for(yy=13;yy<26;yy++){
 
    count sub=new count();
    sub.makedata("data/fuhyo"+yy+".xls");
    int n1=sub.c;
 
    System.out.println(n1);
 
    for(tr=0;tr<n1;tr++){
 
   readxls sub2=new readxls();
    sub2.maxx=maxx;
    sub2.maxy=maxy;
    sub2.makedata("data/fuhyo24.xls",tr);
    mat=sub2.mat;
 
writehtml("ren.html");    
 
       int s,sx;
    fastline=0;
    int s1=0;
    for(s=1;s<11;s++){
    for(sx=1;sx<5;sx++){  
    if(mat[s][sx].indexOf("北海道")>-1)s1=sx;    
    if(mat[s][sx].indexOf("北海道")>-1)fastline=s; 
    }}
 
    System.out.println(fastline+","+s1);
    lastline=0;
 
    for(s=fastline;s<89;s++){
      if(mat[s][s1].indexOf("沖縄")>-1)lastline=s;    
    } 
 
    for(s=fastline;s<lastline+1;s++){
    pref[s]=mat[s][s1];    
    } 
 
 
    System.out.println(lastline+","+s1);
 
 int upper=0;
   creditx=0;
 
    for(sx=s1+1;sx<10;sx++){
    for(s=1;s<fastline;s++){
   int h=0;
   if(mat[s][sx].equals("①"))h=h+1;
   if(upper==0)h=h+1;
   if(h==2)upper=s;
   if(h==2)creditx=sx;
    }}
 
    credity=0;
 
    System.out.println(upper);
 
    for(sx=creditx;sx<100;sx++){    
    String str=mat[upper][sx];    
    if(str.length()>0)credity=sx;
    credit[sx]=str;
    }
 
 for(sx=creditx;sx<credity+1;sx++){   
 bus[sx]="";    
 }
 
 
     for(sx=creditx;sx<credity+1;sx++){   
    bus[sx]="";
    String str=""; 
    for(s=3;s<fastline;s++){
     int h=0;
     if(mat[s][sx].length()>0)h=h+1;
     if(str.length()==0)h=h+1;
    if(h==2)str=mat[s][sx]; 
    }
    if(credit[sx].equals("②"))bus[sx]=str;
     }
 
 for(sx=creditx;sx<credity+1;sx++){
 if(credit[sx].equals("①"))bus[sx]=bus[sx+1];
 if(bus[sx].length()<1)bus[sx]=bus[sx-1];
 }
 
 delta=delta+1;
 
writexml("gdata/"+delta+".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++){ 
if(credit[sx].length()>0){
pw.print("<year>"); 
pw.print(yy); 
pw.print("</year>"); 
pw.print("<bus>"); 
pw.print(bus[sx]); 
pw.print("</bus>"); 
pw.print("<pref>"); 
pw.print(pref[s]); 
pw.print("</pref>"); 
pw.print("<credit>");
pw.print(credit[sx]);
pw.print("</credit>"); 
pw.print("<value>");
pw.print(mat[s][sx]); 
pw.println("</value>");
}
}
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
void writehtml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
 
pw.println("<html>");
 
pw.println("<head>");
pw.println("<meta charset=\"UTF-8\">");
pw.println("</head>");
pw.println("<body>");
pw.print("<table rules=\"all\">"); 
pw.print("<tr>"); 
pw.print("<td>"); 
pw.print(""); 
pw.print("</td>"); 
for(sx=1;sx<maxx+1;sx++){ 
pw.print("<th>"); 
pw.print(sx); 
pw.print("</th>"); 
} 
pw.println("</tr>"); 
for(s=1;s<maxy+1;s++){ 
pw.print("<tr>"); 
pw.print("<th>"); 
pw.print(s); 
pw.print("</th>"); 
for(sx=1;sx<maxx+1;sx++){ 
pw.print("<td>"); 
pw.print(mat[s][sx]); 
pw.print("</td>"); 
} 
pw.println("</tr>"); 
}   
pw.println("</table>"); 
pw.println("</body>");
pw.println("</html>");
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
 
}
 
 
package monmo;
 
 
 
 
 
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[500][500]; 
int[][] color= new int[500][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();}
 
 
 
 
 
 
 
 }
}
 
 
package monmo;
 
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
 
public class count {
 
    int c;
 
    void makedata(String file){
 
      try{
 
 
 
     FileInputStream is = new FileInputStream(file);
     Workbook wb = new HSSFWorkbook(is);
 
 
 
    c=wb.getNumberOfSheets();
 
 
 
 
  } catch (Exception e) {e.printStackTrace();}
 
 
}
 
}
 
最終更新:2016年06月03日 09:17