开发者

Download file in coldfusion and read its content

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开发者_JS百科.mimeType is application/vnd.ms-excel in this case. Thanks!!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜