将HTMLTable导出为Excel并设置目标文件 [英] Export HTMLTable to excel and set Destination file

查看:87
本文介绍了将HTMLTable导出为Excel并设置目标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..



我想从HTMLTable导出到excel,实际上我的导出工作正常,导出文件会自动在下载文件夹中创建,而我的问题如何在C:\中设置目的地的导出文件

这个我的file.aspx

 <   asp:Literal     ID   =  litTable    runat   =  server < span class =code-attribute>   /  >  



和我的file.aspx.vb

 受保护的  Sub  btnPdfExport_Click( By Val 发​​件人作为 对象 ByVal  e  As  EventArgs)句柄 btnPdfExport.Click 
Dim StrHtmlGenerate As StringBuilder()
Dim StrExport As StringBuilder()
响应。 ContentType = application / x-msexcel
Response.AddHeader( Content-Disposition attachment; filename = ExcelFile.xls
Response.ContentEncoding = Encoding.UTF8
Dim tw As StringWriter()
Dim hw 作为 HtmlTextWriter(tw)
litTable .RenderControl(hw)
Response.Write(tw.ToString())
响应。结束()
结束 Sub





please帮助我如何在C:\中设置目的地导出文件



谢谢你

解决方案

IshaqSalam澄清:

是的,下载到客户端。

你认为是否可以吗?

如果不能在应用程序文件夹中设置目的地下载到服务器端怎么样?



我的目标是我想发送一封电子邮件附上一个excel文件来自html table。

感谢您的澄清。我害怕,这个问题毫无意义。与任何其他Web应用程序一样,ASP.NET应用程序无法控制客户端,并且客户端脚本无法控制下载文件的位置。出于安全原因,这是以这种方式设计的。只有浏览用户才能定义保存所有文件或任何特定文件的位置。



试想一下:在很多平台上,像磁盘C:这样的东西不会存在,甚至作为一个概念。在具有此概念的Microsoft平台上,即使在具有一个或多个硬盘驱动器的Windows系统上,磁盘C:也可能丢失。此外,C:\ *(更确切地说,通常是操作系统所在的卷)不是下载文件的合法位置。



-SA

Hi..

I want to Export from HTMLTable to excel, actualy my export is work fine and export files are automatically created in the download folder, and my problem how to set destination the export files in "C:\"
this my file.aspx

<asp:Literal ID="litTable" runat="server" />


and my file.aspx.vb

Protected Sub btnPdfExport_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPdfExport.Click
        Dim StrHtmlGenerate As New StringBuilder()
        Dim StrExport As New StringBuilder()
        Response.ContentType = "application/x-msexcel"
        Response.AddHeader("Content-Disposition", "attachment;filename=ExcelFile.xls")
        Response.ContentEncoding = Encoding.UTF8
        Dim tw As New StringWriter()
        Dim hw As New HtmlTextWriter(tw)
        litTable.RenderControl(hw)
        Response.Write(tw.ToString())
        Response.End()
    End Sub



please help my how to set destination the export files in "C:\"

Thanksyou

解决方案

IshaqSalam clarified:

yes, downloading to the client side.
do you think if it could?
if it can't how about downloading to server side with set destination in application folder?

My goal is i want to send an email by attaching an excel file from html table.

Thank you for the clarification. Is I was afraid of, the question makes no sense. ASP.NET application, as any other Web application, has not control over the client side, and the client-side script has no control over the location of the downloaded file. This is designed this way for safety reasons. Only the browse user defines where to save all files or any particular file.

Just think about it: on many platforms, such thing as disk "C:" does not exist, even as a concept. And on Microsoft platforms which has this concept, the disk "C:" may be missing, even on Windows system with one or more hard drives. Moreover, "C:\*" (more exactly and generally, the volume the OS is located) is not a legitimate location for downloaded files.

—SA


这篇关于将HTMLTable导出为Excel并设置目标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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