Bom dia,
gostaria de saber se tem alguma forma de criar um arquivo na memoria e na mesma hora fazer o download dele.
public HashMap relExcel() {
String sql = req.getParameter("pSql");
try{
DAOExcelSql dao = new DAOExcelSql();
List<String> NomeClunas = dao.consultaNmeColunas(sql);
List<Object> DadosColunas = dao.consultaDadosColunas(sql);
int linha = 1;
int count = 0;
StringBuilder sb = new StringBuilder();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Relatório SQL");
HSSFRow Colunarow = sheet.createRow(0);
HSSFRow Linharow = sheet.createRow(linha);
for (int i = 0; i < NomeClunas.size(); i++) {
Colunarow.createCell(i).setCellValue(NomeClunas.get(i));
}
for (int i = 0; i < DadosColunas.size(); i++) {
if(count == NomeClunas.size()){
linha++;
Linharow.setRowNum(linha);
count = 0;
}
Linharow.createCell(count).setCellValue(String.valueOf(DadosColunas.get(i)));
count ++;
}
FileOutputStream stram = new FileOutputStream("relSQL.xls");
wb.write(stram);
}catch (Exception ex){
ex.printStackTrace();
}
return dados;
}
esse relSQL que eu quero fazer download