- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我预计它会有一个提示屏幕,要求用户打开、保存或取消。
从我的代码下面,我尝试使用 FileOutputStream 将文件保存到特定位置,但是我该如何做像下面的屏幕截图这样的事情?
预期截图:
下面是我的代码:
try {
/* Create Workbook and Worksheet XLSX Format */
XSSFWorkbook my_workbook = new XSSFWorkbook();
XSSFSheet my_sheet = my_workbook.createSheet("Cell Font");
/* Get access to XSSFCellStyle */
XSSFCellStyle my_style = my_workbook.createCellStyle();
/* We will now specify a background cell color */
my_style.setFillPattern(XSSFCellStyle.FINE_DOTS);
my_style.setFillForegroundColor(IndexedColors.BLUE.getIndex());
my_style.setFillBackgroundColor(IndexedColors.RED.getIndex());
/* Create a row in the sheet */
Row row = my_sheet.createRow(0);
/* Create a cell */
Cell cell = row.createCell(0);
cell.setCellValue("Cell Fill Color Test");
/* Attach the style to the cell */
cell.setCellStyle(my_style);
/* Write changes to the workbook */
// OutputStream out = new FileOutputStream(
// new File(ExcelConstant.TEST));
// my_workbook.write(out);
// out.close();
OutputStream output = response.getOutputStream();
// response.setContentType("application/x-download");
// response.setHeader("Content-Disposition", "attachment; filename=MyExcel.xls");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=Excel.xlsx");
my_workbook.write(output);
output.close();
}
最佳答案
我找到了自己问题的解决方案,即不允许 Ajax 下载文件。
Refer from buddy: Why threre is no way to download file using ajax request?
原因是我在 extjs 文件中调用了 ajax。海兹...
关于java - 在浏览器中下载 Excel : Not able to prompt out save button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19854573/
我遇到过这个 html: 上面的html和这个有什么区别: 最佳答案 来自MDN page on the tag : 对于 type 的属性标签,可能的值是: 提交:按钮将表单数据提交给服务器
Button button= (Button) findViewbyID(R.id.button); 和 Button button = new Button(this); 有什么区别? 最佳答案 有
我是一名优秀的程序员,十分优秀!