package gdpx;
import java.io.*;
import java.io.File;
public class pro {
String[][] mat=new String[300][300];
int fastline,lastline;
String[] pref=new String[300];
String[] credit=new String[300];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
File f=new File("data");
String[] ff=f.list();
int maxx=100;
int maxy=100;
int tr=0;
for(tr=0;tr<ff.length;tr++){
readxls sub2=new readxls();
sub2.maxx=maxx;
sub2.maxy=maxy;
sub2.makedata("data/"+ff[tr],0);
mat=sub2.mat;
fastline=7;
lastline=53;
int s,sx;
for(s=fastline;s<lastline+1;s++){
pref[s]=mat[s][2];
System.out.println(s+","+mat[s][2]);
}
for(s=1;s<101;s++){
credit[s]=mat[5][s];
System.out.println(s+","+credit[s]);
}
writexml("gdata/"+ff[tr]+".txt");
}
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.print("");
for(s=fastline;s<lastline+1;s++){
pw.print(",");
pw.print(pref[s]);
}
pw.println("");
for(sx=2;sx<101;sx++){
if(credit[sx].length()>0){
pw.print(credit[sx]);
for(s=fastline;s<lastline+1;s++){
pw.print(",");
pw.print(mat[s][sx]);
}
pw.println("");
}
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
package gdpx;
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();}
}
}
最終更新:2017年03月12日 17:20