日期:2014-05-20  浏览次数:20818 次

java在后台生成excel时如何将生成的文件放到自己指定的目录下面?
java在后台生成excel时如何将生成的文件放到自己指定的目录下面?

------解决方案--------------------
看你用的是什么了
jxl:
FileOutputStream os = new FileOutputStream( "d:/temp/test1.xls ");
WritableWorkbook wwb=Workbook.createWorkbook(os);
.....................................
wwb.write();
wwb.close();
os.close();
---------------------------------
poi:
HSSFWorkbook wb = new HSSFWorkbook();
.............................
FileOutputStream os = new FileOutputStream( "d:/temp/test1.xls ");
wb.write(os);
os.close();
------解决方案--------------------
用流我方式。
用JXL
OutputFormat out=null;
jxl.write.WritableWorkbook excel=null;
jxl.write.WritableSheet sheet=null;

public void setOutputStream(java.io.OutputStream out)throws java.io.IOException{
excel=jxl.Workbook.createWorkbook(out);
sheet=excel.createSheet( "aaaa ", 0);
}