使用模态弹出窗口我想在C#中打开并保存excel文件 [英] Using modal popup I want to open and save excel file in C#

查看:113
本文介绍了使用模态弹出窗口我想在C#中打开并保存excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有gridview数据。我有一个名为exporttoexcel的按钮,当我点击该按钮我要将数据导出到Excel时。



我的代码如下

i have gridview data. i have one button called exporttoexcel when i click that button i want to export data into excel.

my code as follows

string attachment = "attachment; filename=GridviewDetails.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

Response.Write("");
Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
Response.Write("<body>");
Response.Write("<table border=1 bordercolor=black>");

Response.Write("<tr>");
Response.Write("<td colspan=5><b><center>");
Response.Write("GirdviewDetails");
Response.Write("</b></center></td>");
Response.Write("</tr>");

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());

Response.Flush();
Response.Write("<table>");
Response.Write("</body>");
Response.Write("</html>");
Response.End();





当我点击导出按钮时,excel数据直接下载,



i想要显示弹出窗口。在弹出窗口打开保存就在那里。



当我点击打开按钮excel文件打开时。



当我点击要保存的保存按钮excel文件时。



我怎样才能在asp.net中使用C#。



我尝试过:



当我点击导出按钮时,excel数据正在下载直接,



我想要的东西

i想要显示弹出窗口。在弹出窗口打开保存就在那里。



当我点击打开按钮excel文件打开时。



当我点击要保存的保存按钮excel文件时。



我怎样才能在asp.net中使用C#。



When i click the export button the excel data is downloading directly,

i want to show popup. in that popup open save is to be there.

When i click the open button excel file to be opened.

When i click the save button excel file to be saved.

for that how can i do in asp.net using C#.

What I have tried:

When i click the export button the excel data is downloading directly,

What I Want
i want to show popup. in that popup open save is to be there.

When i click the open button excel file to be opened.

When i click the save button excel file to be saved.

for that how can i do in asp.net using C#.

推荐答案

搜索短语modal popup asp.net会给你很多点击量,如果你只是尝试一下。



以下是一些如何使用AJAX进行操作的示例

使用ASP.Net AJAX ModalPopupExtender控件构建模态弹出窗口 [ ^ ]



启动模态服务器代码(C#)的弹出窗口| ASP.NET站点 [ ^ ]



从ModalPopup(C#)处理回传| ASP.NET站点 [ ^ ]



这些示例仅向您展示如何创建模态弹出窗口和按钮。

用于打开和保存自己需要的Excel文件的代码。
The search phrase "modal popup asp.net" will give you a lot of hits, if you just try it.

Here are some samples for how to do it with AJAX
Building Modal Popup using ASP.Net AJAX ModalPopupExtender Control[^]

Launching a Modal Popup Window from Server Code (C#) | The ASP.NET Site[^]

Handling Postbacks from a ModalPopup (C#) | The ASP.NET Site[^]

These examples will only show you how to create the modal popup and the buttons.
The code behind for opening and saving Excel files you need to do yourself.


这篇关于使用模态弹出窗口我想在C#中打开并保存excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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