在coldfusion中下载文件并读取其内容
cfhttp 带有 get 来下载文件。有谁有一个例子 cfhttp 工作吗?是否需要在服务器端进行特殊设置才能使此标签正常工作。当我尝试以下代码时:
<CFHTTP
METHOD = "get"
URL="http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&years_option=specific_years&to_year=2010&from_year=2009&delimiter=comma&output_view&output_format=excelTable"
path="/Users/Deepak"
file="testfile.xls">
我的计算机没有返回任何内容?怎么让它弹出“你想把文件保存到哪里”对话框呢?
我通过点击此链接在 Coldfusion 中提交表单 http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&years_option=special_years&to_year=2010&from_year=2009&delimiter=comma& output_view&output_format=excelTable
结果我得到了一个 excel 文件。我怎样才能将此文件保存到我的本地盒子上。或者,是否可以使用cfftp或cfhttp通过coldfusion直接读取文件内容而不将其保存在本地盒子中?
在本例中,cfhttp.mimeType 是 application/vnd.ms-excel。 谢谢!!
cfhttp with a get to download the files. Does anyone have an example of
cfhttp working? Are there special settings that need to be set up on the server side to get this tag to work. When I try the following code:
<CFHTTP
METHOD = "get"
URL="http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&years_option=specific_years&to_year=2010&from_year=2009&delimiter=comma&output_view&output_format=excelTable"
path="/Users/Deepak"
file="testfile.xls">
Nothing comes back to my computer? How do you get it to pop up the "where do you want to save the file box" dialogue box?
I am submitting a form in coldfusion by hitting this link http://data.bls.gov/PDQ/servlet/SurveyOutputServlet?series_id=LNU04032231&years_option=specific_years&to_year=2010&from_year=2009&delimiter=comma&output_view&output_format=excelTable
I am getting a excel file as a result. How can I save this file on my local box. Or, is it possible to directly read the content of file without saving it in my local box through coldfusion using cfftp or cfhttp?
cfhttp.mimeType is application/vnd.ms-excel in this case.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定我是否理解这个问题,但无论如何让我尝试一下:
使用 cfhttp,您可以将表单变量提交到 URL,并取回数据。从那里,您可以保存它,在内存中操作它,或者其他什么。
如果需要从 CF 推送内容到客户端,可以使用 cfheader 和 cfcontent 来实现。
如果这不能回答您的问题,请澄清问题。
I'm not certain I understand the question, but let me try anyway:
Using cfhttp, you can submit the form variables to the URL, and get back the data. From there, you could save it, manipulate it in memory, or whatever.
If you need to push the content to the client from CF, you can use cfheader and cfcontent to do so.
If this does not answer what you are asking, please clarify the question.
手动运行一次,看看它是否真的是一个excel文件,或者是一个扩展名为“xls”的HMTL文件,这是一个常见的技巧。如果是 HTML,那么阅读起来会很痛苦。
如果是二进制,则使用 CFHTTP 以及“文件”和“ path”属性将文件下载到您的服务器。然后您可以使用 cfspreadsheet (CF9) 读取 Excel 二进制文件。
如果您没有 CF9,请查看 POI CF9 使用它来实现 cfspreadsheet 标签
Run it by hand once to see if it is really an excel file or an HMTL file with an "xls" extension, which is a common trick. If it is HTML, then it is gonna be a pain to read.
If it is Binary, then use CFHTTP with the "file" and "path" attributes to download the file to your server. Then you can use cfspreadsheet (CF9) to read the excel binary.
If you don't have CF9 then check out POI which is what CF9 is using to implement the cfspreadsheet tag