0
List<String> headerRow = Arrays.asList("col1", "col2", "col3","col4","col5");
// Creates a xlsx workbook !!
XSSFWorkbook wb = ExcelHelper.writeToXlsxExcelFile(headerRow,EjbHelper.getAccountEJb().getCustomersByscPartyNumber("9B7W5"));
//Creating a file to dump xlsx
String fileLocation = "d://try.xlsx";
FileOutputStream fout = new FileOutputStream(fileLocation);
workbook.write(fout);
//Want to Create a Webservice to send response without saving file to hard-disk
ResponseBuilder response = Response.ok((Object)fout);
response.header("Content-Disposition","attachment; filename=" + "ResourceInformation.xlsx");
return response.build();
上面的代码片段创建一个xlsx文件,然后通过响应发送它。我想知道有没有任何方法直接发送xlsx文件,而无需在硬盘上创建文件?如何发送新创建的Excel文件作为响应而不将其保存到硬盘上?