0

试图修复一个旧的 .asp 站点以在 ipad 上工作。其中一项功能是用户能够将搜索结果下载到 Excel 工作表中。该代码使用:

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=results.xls" 
Response.CharSet = "iso-8859-1"

在 ipad 上查看该站点时,当单击带有上面代码的页面的链接时,它什么也不做,只是旋转。是不是我试图将数据导出为ex​​cel,我在一些帖子中读过它是如何编码的!我是否应该转换代码以将结果页面导出为 csv 文件,然后允许用户以他们想要/可用的任何内容打开它?什么是击中最多设备的最佳方法...

谢谢

4

1 回答 1

1

在过去,我会遇到同样的情况,所以我做了什么:

文件:下载.ASP

<%  
' get the file to download
myFile = request.querystring("File")
myFullPath = "c:\name_folder\" & myFile ' example of full path and filename

' set headers
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "attachment; filename=" & myFile

' send the file using the stream as

Set adoStream = CreateObject("ADODB.Stream") 
adoStream.Open() 
adoStream.Type = 1 
adoStream.LoadFromFile(myFullPath) 
Response.BinaryWrite adoStream.Read() 
adoStream.Close 
Set adoStream = Nothing
%>

文件:HTML

<a href="DOWNLOAD.ASP?File=result.xls">Download Excel file</a>

此示例完全使用本机浏览器 Safari 与 Ipad 一起工作。该文件Result.xls被下载并加载到查看器中,但无法进行编辑。

我的 iPad 用户使用 App QuickOffice 让文件保存在虚拟文件夹中,重命名文件,删除,......但他们无法编辑文件,该应用程序仅用于管理文件,不需要下载文件

如果您的用户还需要在 iPad 上编辑 XLS 文件,我建议使用(例如)Google App Document,它允许用户直接在浏览器中编辑和管理文件。

希望有帮助

于 2012-05-28T19:08:48.533 回答