Excel 文件“打开” “另存为”对话框未在 asp.net 中显示
我已经搜索了 S/O,但找不到可以帮助我解决问题的解决方案。我正在将数据从我的 asp.net 应用程序导出到 xls 文件。当用户单击“导出数据”按钮时,我需要显示“打开/另存为/取消”对话框。
我该如何做到这一点?
oSheet = Nothing
oRange = Nothing
oWB.SaveAs(sFileName.ToString())
oWB.Close()
oWB = Nothing
oXL.Quit()
I have searched S/O, but unable to find a solution that helps my problem. I am exporting data to an xls file from my asp.net application. I need to display the Open / Save As / Cancel dialog box when the user clicks "Export Data" button.
How do I accomplish that?
oSheet = Nothing
oRange = Nothing
oWB.SaveAs(sFileName.ToString())
oWB.Close()
oWB = Nothing
oXL.Quit()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试这个代码块。您可能需要对其进行微调。代码的 Response 块与对话框有关:
Try this code block. You may have to fine tune it. The
Response
block of the code has to do with the dialog box:您可以通过多种方式做到这一点。您提供的代码示例与此无关,但显然您创建了文件并将其保存到磁盘。鉴于您有文件路径,您可以使用 Response.WriteFile。您需要添加内容处置以打开“另存为”对话框。
You can do it several ways. Your code sample you gave has nothing to do with that, but apparently your creating the file and saving it to disk. Seeing as you have the file path, you could use Response.WriteFile. You need to add the Content-Disposition to bring up the Save As dialog.
嗯。你没有。您的 Excel 对象正在 WEB 服务器上的 ASP.NET 进程中运行。无法使该对话框显示在客户端(浏览器)端。
Uhm. You do not. Your excel objects are running in the ASP.NET process ON THE WEB SERVER. There's no way to make the dialog show up on the CLIENT (BROWSER) side.