java,poi导出excle 代码如下,怎么修改才能 出现‘’保存路径的选择框‘’?

已经能导出了,只是路径是写死的,怎么修改才能 出现可以选择保存路径的框? 望指导!

以下是部分代码::

String fileName = "硬件查询信息.xls";  
            fileName = new String(fileName.getBytes("GBK"), "iso8859-1");  
            response.reset();  
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);// 指定下载的文件名  
            response.setContentType("application/vnd.ms-excel");  
            response.setHeader("Pragma", "no-cache");  
            response.setHeader("Cache-Control", "no-cache");  
            response.setDateHeader("Expires", 0);  
          //  OutputStream output = response.getOutputStream();  
            FileOutputStream  bufferedOutPut = new FileOutputStream ("C:/硬件查询信息.xls");  
            

最后关闭的代码::

try{
            bufferedOutPut.flush();  
            wb.write(response.getOutputStream());
            bufferedOutPut.close(); 
        }catch (IOException e) {  
            e.printStackTrace();  
        } finally {  
            Exportlist.clear();  
        }      

    
           
阅读 4k
2 个回答

这个保存路径是在浏览器设置里面选择的吧,把响应发送给浏览器然后下载的过程都是浏览器控制的。

clipboard.png

下载路径是浏览器来决定的。

这种情况要找其它方法解决。。。下载

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题