我的代码在下载excel时显示弹出窗口时出错 [英] Error in my code to show the popup when downloading the excel

查看:92
本文介绍了我的代码在下载excel时显示弹出窗口时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将gridview数据导出为ex​​cel。



i想要在下载之前显示弹出窗口,我编写的代码如下



我的代码如下



I am exporting the gridview data to excel.

i want to show the popup before downloading for that i written code as follows

My code as follows

Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
string FileName = "Employeess.xls";
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
gvEmpdetails.GridLines = GridLines.Both;
gvEmpdetails.HeaderStyle.Font.Bold = true;
gvEmpdetails.RenderControl(htmltextwrtter);
Response.Write(strwritter.ToString());
Response.End();

   String FileName = "csharp_Excel.xls";
                String FilePath = "C:\\Users\\551386\\Downloads";
          
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "text/plain";
                response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
                response.TransmitFile(FilePath);
              
                response.End();



我想在下载excel之前显示弹出窗口。





当我运行上面的代码时显示错误如下



访问路径'C:\ Users \ 551386 \Downloads'被拒绝。



请帮我解决我的代码中的问题


i want to show popup before downloading the excel.


when i run the above code shows error as follows

Access to the path 'C:\Users\551386\Downloads' is denied.

please help me what is the problem in my code

推荐答案

Quote:

访问路径'C:\ Users \ 551386 \下载'被拒绝。

Access to the path 'C:\Users\551386\Downloads' is denied.

问题不在于您的代码。

问题是您没有凭据在该路径中读取。

The problem is not your code.
The problem is that you don't have credential to read in that path.


这篇关于我的代码在下载excel时显示弹出窗口时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆