アットウィキロゴ

景気動向指数

package k;
 
import java.io.*;
 
public class pro {
 
    int maxx,maxy;
     String[][] mat=new String[5000][5000]; 
 int s,sx;
    int[] month=new int[500];
     int[] year=new int[500];
     double[] v1=new double[500];
      double[] v2=new double[500];
       double[] v3=new double[500];
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
   pro(){ 
 
 
       maxx=50;
       maxy=416;
 
       readxls sub=new readxls();
       sub.maxx=maxx;
       sub.maxy=maxy;
    sub.makedata("data.xls",0);
    mat=sub.mat;
 
    double n;
 
    for(s=67;s<417;s++){
    n=Double.parseDouble(mat[s][3]);
    month[s]=(int)n;
    n=Double.parseDouble(mat[s][2]);
    year[s]=(int)n;
    }
 
 
    for(s=67;s<417;s++){
    n=Double.parseDouble(mat[s][4]);
    v1[s]=n;
    n=Double.parseDouble(mat[s][5]);
    v2[s]=n;
    n=Double.parseDouble(mat[s][6]);
    v3[s]=n;
    }
 
 
 
    writefile("ren.txt");
 
 
 
   }
 
   void writefile(String file){ 
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=67;s<417;s++){ 
 
pw.print("<year>"); 
pw.print(year[s]); 
pw.print("</year>"); 
pw.print("<month>"); 
pw.print(month[s]); 
pw.print("</month>");
pw.print("<credit>"); 
pw.print("先行指数"); 
pw.print("</credit>"); 
pw.print("<value>"); 
pw.print(v1[s]); 
pw.println("</value>"); 
 
pw.print("<year>"); 
pw.print(year[s]); 
pw.print("</year>"); 
pw.print("<month>"); 
pw.print(month[s]); 
pw.print("</month>");
pw.print("<credit>"); 
pw.print("一致指数"); 
pw.print("</credit>"); 
pw.print("<value>"); 
pw.print(v2[s]); 
pw.println("</value>"); 
 
pw.print("<year>"); 
pw.print(year[s]); 
pw.print("</year>"); 
pw.print("<month>"); 
pw.print(month[s]); 
pw.print("</month>");
pw.print("<credit>"); 
pw.print("遅行指数"); 
pw.print("</credit>"); 
pw.print("<value>"); 
pw.print(v3[s]); 
pw.println("</value>"); 
} 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
 
 
}
 
 
 
package k;
 
 
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[5000][5000]; 
 
 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;
 
 
          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();
 
   mat[s][sx]=bb;
  }
  }
  }
      }
 
 
 
 
 
  } catch (Exception e) {e.printStackTrace();}
 
 
 
 
 
 
 
 }
}
 
最終更新:2014年04月11日 01:48