Stringpath=request.getSession().getServletContext().getRealPath("/");//服务器路径Stringname=de011+de007;//+".xls"finalStringfilename=path+name+".xls";fName=name;finalFile...
String path = request.getSession().getServletContext().getRealPath("/"); //服务器路径
String name = de011+de007;//+".xls"
final String filename = path+name+".xls";
fName = name;
final File fileOutput = new File(filename); //生成文件-----------------!!!!!!!!--------------------
sql="select bblxexcel from jk014 where bbpl="+iBbpl+" and de011="+iDe011 +" and rownum=1";
this.getJdbcTemplate().execute(sql,new CallableStatementCallback(){
public Object doInCallableStatement(CallableStatement stmt)
throws SQLException, DataAccessException {
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
InputStream inputStream = rs.getBinaryStream("bblxexcel");//数据库中blob字段存储excel FileOutputStream fos;
try {
fos = new FileOutputStream(fileOutput); //
int c;
while ((c = inputStream.read()) != -1) {
fos.write(c);
}
fos.close();
}catch(Exception e){
e.printStackTrace();
}
}
return null;
}
});
WritableWorkbook wwb = null;
Workbook wb = Workbook.getWorkbook(fileOutput);
wwb = Workbook.createWorkbook(fileOutput,wb);
我现在是需要 先从库中取到模板,然后把值插入模板中,再下载
现在是能不能跳过中间步,不在服务器上生成file
展开