アットウィキロゴ

p000いhh

package xls;
 
import java.io.*;
 
public class pro {
 
String[][] mat=new String[500][500]; 
int s1,s2;
String[] pref=new String[500];
 
    public static void main(String[] args) {
       pro t=new pro();
    }
 
    pro(){
 
        int tr;
 
     for(tr=15;tr<27;tr++){
        readxls sub=new readxls();
        sub.maxx=100;
        sub.maxy=100;
        sub.makedata("a/"+tr+".xls",0);
        mat=sub.mat;
 
        int s;
        s1=0;
        for(s=1;s<100;s++){
        int h=0;
        if(mat[s][1].indexOf("北海道")>-1)s1=s;
 
 
        }
 
 
s2=0;
        for(s=s1;s<100;s++){
        int h=0;
        if(mat[s][1].indexOf("沖縄")>-1)s2=s;  
        }
 
        for(s=s1;s<s2+1;s++){
        pref[s]=mat[s][1];    
        }
 
 
 
        writexml("data/"+tr+".txt");
 
    }
 
    }
 
 
 
       void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=s1;s<s2+1;s++){  
for(sx=1;sx<13;sx++){ 
if(pref[s].length()>0){
pw.print("<year>"); 
pw.print(2000); 
pw.print("</year>"); 
pw.print("<pref>"); 
pw.print(pref[s]); 
pw.print("</pref>"); 
pw.print("<month>");
pw.print(sx);
pw.print("</month>"); 
pw.print("<value>");
pw.print(mat[s][sx+3]); 
pw.println("</value>");
}
}
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
}
 
 
 
 
package xls;
 
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();}
 
 
 
 
 
 
 
 }
}
 
最終更新:2016年04月29日 10:35