乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > -poi合并excel,java导出excel

-poi合并excel,java导出excel

作者:乔山办公网日期:

返回目录:excel表格制作







package com.baosight.baosteel.eps.analysis.clientmake;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;

public class AA {

static HSSFWorkbook wbTotal = null;

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
AA a = new AA();
a.test();
}

public void test() throws IOException{
String path="d:/test.xls";
HSSFWorkbook one = this.OrgTrade();
HSSFWorkbook two = this.CompanyCount();
FileOutputStream fileOut = new FileOutputStream(path);
one.write(fileOut);
two.write(fileOut);

fileOut.close();
}

public HSSFWorkbook OrgTrade() throws IOException{
HSSFWorkbook one =null;
String filePath = "c://" + "reportResponse" + "/" + "1" + "/"+ "report-day";
File root = new File(filePath);
String time = "2009-12-3"; // 日期e799bee5baa6e997aee7ad94e58685e5aeb9365
String a[] = root.list();
if (a != null && a.length > 0) {
for (int i = 0; i < a.length; i++) {
String fileName = a[i];
String newFileName = fileName.substring(0, fileName.lastIndexOf("."));
if (time.equals(newFileName)) {
String fullFilePathName = filePath + "/" + fileName;
FileInputStream is = new FileInputStream(fullFilePathName);
one = new HSSFWorkbook(is);
//wbTotal.write(new FileOutputStream(one.g));
//one.createSheet("one");
//wbTotal.createSheet(one.getSheetAt(0).);
}
}
}
return one;
}
//
public HSSFWorkbook CompanyCount() throws IOException{
HSSFWorkbook two =null;
String filePath1 = "c://" + "reportResponse" + "/" + "2" + "/"+ "report-day";
File root1 = new File(filePath1);
String time1 = "2009-12-1"; // 日期
String a1[] = root1.list();
if (a1 != null && a1.length > 0) {
for (int i = 0; i < a1.length; i++) {
String fileName = a1[i];
String newFileName = fileName.substring(0, fileName.lastIndexOf("."));
if (time1.equals(newFileName)) {
String fullFilePathName = filePath1 + "/" + fileName;
FileInputStream is = new FileInputStream(fullFilePathName);
two = new HSSFWorkbook(is);
}
}
}
return two;
}

}

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网