package xls;
import java.io.*;
public class pro {
String[][] mat=new String[500][200];
int fastline,lastline;
int indexline,creditline,prefline,subline;
int creditx,credity;
int[] month=new int[50000];
String[] dic=new String[50000];
String[] pref=new String[500];
String[] year=new String[500];
String date;
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int dicnumber=0;
int tr;
for(tr=1;tr<26;tr++){
readxls sub=new readxls();
sub.maxx=60;
sub.maxy=70;
sub.makedata("pop.xls",tr);
mat=sub.mat;
int s;
for(s=4;s<51;s++){
pref[s]=mat[s][1];
}
writexml("gdata/"+tr+".txt");
}
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("p,c,y,v");
for(s=4;s<51;s++){
for(sx=2;sx<35;sx++){
pw.print(pref[s]);
pw.print(",p");
pw.print(s-3);
pw.print(",");
pw.print(sx+1978);
pw.print(",");
pw.println(mat[s][sx]);
}
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
package xls;
import java.io.FileInputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
public class readxls{
int pointx,pointy;
int px,py;
int maxx,minx,miny,maxy;
int creditrow;
int checkline,checkx;
String[][] mat=new String[10000][500];
void makedata(String file,int shnumber){
try{
FileInputStream is = new FileInputStream(file);
Workbook wb = new HSSFWorkbook(is);
Sheet sh = wb.getSheetAt(shnumber);
int s,sx;
int h1,h2;
String str;
for(s=miny;s<maxy+1;s++){
for(sx=minx;sx<maxx+1;sx++){
mat[s][sx]="";
}
}
for(s=miny;s<maxy+1;s++){
Row row = sh.getRow(s-1);
h1=0;
if(row==null)h1=100;
if(h1<50){
for(sx=minx;sx<maxx+1;sx++){
Cell cell = row.getCell(sx-1);
str="";
h2=0;
if(cell==null)h2=100;
if(h2<50){
int type =cell.getCellType();
str="";
if(type==0)str=""+cell.getNumericCellValue();
if(type==1)str=cell.getStringCellValue();
mat[s][sx]=str;
}
}
}
}
} catch (Exception e) {e.printStackTrace();}
}
}
最終更新:2016年12月23日 11:20