package pi;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class pro {
int maxx,maxy;
String[][] mat=new String[200][100];
int creditx,credity;
int fastline,lastline;
String[] index=new String[200];
String[] term=new String[200];
String[] size=new String[200];
public static void main(String[] args) {
pro ts=new pro();
}
pro(){
maxx=50;
maxy=200;
int px,y1,q1;
for(y1=17;y1<28;y1++){
for(q1=1;q1<5;q1++){
for(px=1;px<16;px++){
readxls sub=new readxls();
sub.maxx=maxx;
sub.maxy=maxy;
sub.makedata("data/"+y1+"0"+q1+".xls",changex(px)+"-"+changex(2));
mat=sub.mat;
int s,sx,p1;
p1=500;
creditx=500;
for(s=1;s<10;s++){
for(sx=1;sx<10;sx++){
if(mat[s][sx].indexOf("月")>-1)p1=sx;
if(p1<creditx)creditx=p1;
}
}
p1=0;
credity=0;
for(s=1;s<10;s++){
for(sx=creditx;sx<maxx+1;sx++){
if(mat[s][sx].indexOf("月")>-1)p1=sx;
if(p1>credity)credity=p1;
}
}
System.out.println(creditx);
System.out.println(credity);
fastline=0;
for(s=1;s<10;s++){
for(sx=1;sx<creditx;sx++){
if(mat[s][sx].indexOf("全")>-1)fastline=s;
}}
int h;
lastline=0;
for(s=fastline+1;s<maxy;s++){
for(sx=1;sx<creditx;sx++){
h=0;
if(mat[s][sx].indexOf("保険")>-1)h=h+1;
if(lastline==0)h=h+1;
if(h==2)lastline=s;
}}
String str;
for(s=fastline;s<lastline+1;s++){
str="";
for(sx=1;sx<creditx;sx++){
str=str+mat[s][sx];
}
str=str.replace(" ","");
str=str.replace(" ","");
index[s]=str;
}
System.out.println(fastline);
System.out.println(lastline);
size[1]="大企業";
size[2]="中堅企業";
size[3]="中小企業";
term[1]="前期";
term[2]="今期";
term[3]="翌期";
term[4]="翌々期";
String file;
file="gdata/"+y1+"0"+q1+px+".txt";
if(px<10)file="gdata/"+y1+"0"+q1+"0"+px+".txt";
writefile(file);
}}}
}
void writefile(String file){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
int ch,s,sx;
int s1,s2;
for(s=fastline;s<lastline+1;s++){
for(s1=1;s1<4;s1++){
for(s2=1;s2<5;s2++){
sx=creditx+4*(s1-1)+s2-1;
pw.print("<bus>");
pw.print(index[s]);
pw.print("</bus>");
pw.print("<size>");
pw.print(size[s1]);
pw.print("</size>");
pw.print("<term>");
pw.print(term[s2]);
pw.print("</term>");
pw.print("<value>");
pw.print(mat[s][sx]);
pw.println("</value>");
}}}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
String changex(int nx) {
String ss;
ss="";
if(nx==0)ss="0";
if(nx==1)ss="1";
if(nx==2)ss="2";
if(nx==3)ss="3";
if(nx==4)ss="4";
if(nx==5)ss="5";
if(nx==6)ss="6";
if(nx==7)ss="7";
if(nx==8)ss="8";
if(nx==9)ss="9";
if(nx==10)ss="10";
if(nx==11)ss="11";
if(nx==12)ss="12";
if(nx==13)ss="13";
if(nx==14)ss="14";
if(nx==15)ss="15";
return ss;
}
}
package pi;
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[7000][700];
int[][] color= new int[50000][500];
void makedata(String file,String px){
try{
FileInputStream is = new FileInputStream(file);
Workbook wb = new HSSFWorkbook(is);
Sheet sh = wb.getSheet(px);
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();}
}
}
最終更新:2016年05月15日 18:16