public class csvchange {
int maxx,maxy;
int shnumber;
int s,sx;
String[][] ph=new String[500][500];
String[][] colr=new String[500][500];
void makedata(String file,int shnumber){
for(s=1;s<maxy+1;s++){
for(sx=1;sx<maxx+1;sx++){
ph[s][sx]="noinfo";
colr[s][sx]="nocolor";
}
}
try{
FileInputStream is = new FileInputStream(file);
Workbook wb = new HSSFWorkbook(is);
Sheet sh = wb.getSheetAt(shnumber);
int s1,s2,h,z;
double n;
for(s=1;s<maxy+1;s++){
s1=s-1;
Row row = sh.getRow(s1);
z=0;
if(row==null)z=100;
if(z<50){
for(sx=1;sx<maxx+1;sx++){
s2=sx-1;
Cell cc = row.getCell(s2);
h=0;
if(cc==null)h=100;
if(h<50){
int type =cc.getCellType();
n=0;
if(type==0)n=cc.getNumericCellValue();
if(type==0)ph[s][sx]=""+n;
if(type==1)ph[s][sx]=cc.getStringCellValue();
}
}
}
}
for(s=1;s<maxy+1;s++){
s1=s-1;
Row row2 = sh.getRow(s1);
z=0;
if(row2==null)z=100;
if(z<50){
for(sx=1;sx<maxx+1;sx++){
s2=sx-1;
Cell cc2 = row2.getCell(s2);
h=0;
if(cc2==null)h=100;
if(h<50){
CellStyle p=cc2.getCellStyle();
short col=p.getFillBackgroundColor();
colr[s][sx]=String.valueOf(col);
}
}
}
}
} catch (Exception e) {e.printStackTrace();}
}
}
最終更新:2014年01月25日 13:42