アットウィキロゴ

p082402

package r2;
 
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[5000][500];
 
    int fastline,lastline;
    int creditx,credity;
    int creditline,arealine,busline;
     String[] area=new String[5000];
    String[] bus=new String[5000];
     int[] year=new int[500];
     int[] code_bus=new int[5000];
     int[] code_area=new int[5000];
     double[][][] v=new double[60][30][50];
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
    pro(){
 
    catchdata sub=new catchdata();
    sub.makedata(10);
    v=sub.v;
 
 
 
 
 
 
    }
 
}
 
 
 
package r2;
 
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
 
 
public class catchdata{
int maxx,maxy;
 
    String[][] mat=new String[5000][500];
 
    int fastline,lastline;
    int creditx,credity;
    int creditline,arealine,busline;
     String[] area=new String[5000];
    String[] bus=new String[5000];
     int[] year=new int[500];
     int[] code_bus=new int[5000];
     int[] code_area=new int[5000];
     double[][][] v=new double[60][30][50];
 
 
 
    void makedata(int page){
 
       readxls sub=new readxls();
    sub.maxx=400;
    sub.maxy=2000;
    sub.makedata("data.xls",page);
    mat=sub.mat;
 
        maxx=60;
        maxy=2000;
 
        writehtml("ren.html");
 
        fastline=4;
        lastline=1155;
        creditx=5;
        credity=43;
 
        creditline=3;
        arealine=2;
        busline=4;
 
        int s;
 
        String str;
 
        for(s=creditx;s<credity+1;s++){
        str=mat[creditline][s];    
        year[s]=(int)num(str);
        }
 
        for(s=fastline;s<lastline+1;s++){
        bus[s]=mat[s][busline];    
        str=mat[s][busline-1]; 
        code_bus[s]=(int)num(str);
        str=mat[s][arealine-1]; 
        code_area[s]=(int)num(str);
        area[s]=mat[s][arealine]; 
        }
 
        int sx,y1,a1,b1;
 
       writexml("ren.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("<year>"); 
pw.print(year[sx]); 
pw.print("</year>"); 
pw.print("<pref>");
pw.print(area[s]);
pw.print("</pref>"); 
pw.print("<code_pref>");
pw.print(code_area[s]);
pw.print("</code_pref>"); 
pw.print("<bus>");
pw.print(bus[s]);
pw.print("</bus>"); 
pw.print("<code_bus>");
pw.print(code_bus[s]);
pw.print("</code_bus>"); 
pw.print("<value>");
pw.print(mat[s][sx]); 
pw.println("</value>");
}
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
 
 
double num(String str){
 
    double nx;
 
    nx=0;
 
 try{
 
    nx=Double.parseDouble(str);
 
 }catch (Exception e) {}
 
 return nx;
 
 
 
}
 
 
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 r2;
 
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][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();
 
  mat[s][sx]=bb;
  }
  }
  }
  }
 
 
 
 
 
  } catch (Exception e) {e.printStackTrace();}
 
 
 
 
 
 
 
 }
}
 
最終更新:2015年08月24日 12:33