package keiki;
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[500][700];
String[][] data=new String[500][10];
int[] year=new int[500];
int[] month=new int[500];
String[] credit=new String[500];
String[] index=new String[500];
int s,sx;
String[] code=new String[500];
int starty;
int indexline;
public static void main(String[] args) {
pro test=new pro();
}
pro(){
count sub=new count();
sub.supx=700;
sub.makedata("data.xls",0);
maxx=sub.maxx;
maxy=sub.maxy;
System.out.println(maxx+","+maxy);
readxls sub2=new readxls();
sub2.maxx=maxx;
sub2.maxy=maxy;
sub2.makedata("data.xls",0);
mat=sub2.mat;
writehtml("ren.html");
starty=5;
indexline=2;
maxy=57;
for(s=starty;s<maxy+1;s++){
index[s]=mat[s][indexline];
}
String str;
int yy;
yy=2007;
for(sx=4;sx<16;sx++){
credit[sx]=mat[4][sx];
}
writexml("ren.txt");
}
void writeindex(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(sx=starty;sx<maxy+1;sx++){
pw.print("<credit>");
pw.print(index[sx]);
pw.print("</credit>");
pw.print("<code_credit>");
pw.print(code[sx]);
pw.println("</code_credit>");
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=4;s<16;s++){
for(sx=starty;sx<maxy+1;sx++){
pw.print("<year>");
pw.print(index[sx]);
pw.print("</year>");
pw.print("<month>");
pw.print(credit[s]);
pw.print("</month>");
pw.print("<value>");
pw.print(mat[sx][s]);
pw.println("</value>");
}
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
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 keiki;
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[50000][500];
int[][] color= new int[50000][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();
short n1=cc.getCellStyle().getFillBackgroundColor();
color[s][sx]=(int)n1;
mat[s][sx]=bb;
}
}
}
}
} catch (Exception e) {e.printStackTrace();}
}
}
最終更新:2015年08月29日 18:55