导出一张SHEETE表没问题,导出两张或多张,怎么处理
14 回复
我的想法就是在TEMPFIE写一个空文件,然后用不同的LISt数据表,用这个语句写入
boolean isok = J4E.toExcel(downfile,subPon,null);,在送前台下载
不晓得行不行
用appendExcel可以实现,配合J4ECONF设置
list是数据体,fields是需显示的字段名,sheetname是表名称,downfile是送前台的文件名,append_or_create是标识新建EXCEL文件或在原EXCEL文件添加
public String appendexcel(List list,String fields,String sheetname,File downfile,boolean append_or_create)
{
if(list==null)
return "错误:请注意核对上传文件的具体时间点";
J4EConf j4econf=new J4EConf();
j4econf = J4EConf.from(list.get(0).getClass());
j4econf.setUse2007(true);
List<J4EColumn> jcols = j4econf.getColumns();
for (Iterator<J4EColumn> it = jcols.iterator(); it.hasNext();) {
J4EColumn j4eColumn = it.next();
j4eColumn.setIgnore(true);
if(fields.contains(j4eColumn.getFieldName()))
{
j4eColumn.setIgnore(false);
}
}
boolean isok=false;
j4econf.setPassRow(0);
j4econf.setSheetName(sheetname);
if(append_or_create)
isok = J4E.appendExcel(downfile,list,j4econf);
else
isok = J4E.toExcel(downfile,list,j4econf);
if(!isok)
return "错误"+sheetname+"导出失败";
else
return "OK";
}
添加回复
请先登陆