使用数据透视表IE将[1]附加到文件名下载Excel

时间:2022-11-07 02:21:46

Currently I am face this issue.

目前我正面临这个问题。

when I am directly opening from IE with out saving , IE adding [1]/Version to file name

当我直接从IE中打开并保存时,IE将[1] / Version添加到文件名中

Example: Test.xlsx file in backend but when i am opening the file its renamed to Test[1].xlsx.And this is creating the issue.

示例:后端的Test.xlsx文件,但是当我打开文件时,它重命名为Test [1] .xlsx。这就是创建问题。

Can any one suggest what I am doing wrong here.

任何人都可以在这里暗示我做错了什么。

//res.setContentType("application/vnd.ms-excel");
               //res.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
               //res.reset();
               //res.setHeader("Expires", "0");

      myDownloadTask{
              //res.setHeader("Cache-Control","must-revalidate,post-check=0, pre-check=0");
               //res.setHeader("Pragma", "public");
               //res.setContentType("application/force-download");
               //res.setHeader("Content-Transfer-Encoding", "binary");
               res.setContentType("application/ms-excel; charset=UTF-8");
               res.setCharacterEncoding("UTF-8");

               fileName=EncodeFileName(fileName);

               res.setHeader("Content-Disposition","attachment; filename="+fileName);
       }

1 个解决方案

#1


You have a file with Test.xlsx already on your hard disk, this is why IE rename it to Test[1].xlsx.

你的硬盘上已有一个Test.xlsx文件,这就是IE将其重命名为Test [1] .xlsx的原因。

I think you can not handle it, you can create a unique file name on the server every time, or gently prompt to user to make sure he does not have a file with same name on his hard disk !

我认为你无法处理它,你可以每次在服务器上创建一个唯一的文件名,或者轻轻提示用户确保他的硬盘上没有同名的文件!

#1


You have a file with Test.xlsx already on your hard disk, this is why IE rename it to Test[1].xlsx.

你的硬盘上已有一个Test.xlsx文件,这就是IE将其重命名为Test [1] .xlsx的原因。

I think you can not handle it, you can create a unique file name on the server every time, or gently prompt to user to make sure he does not have a file with same name on his hard disk !

我认为你无法处理它,你可以每次在服务器上创建一个唯一的文件名,或者轻轻提示用户确保他的硬盘上没有同名的文件!