2014-01-27 4 views
1

여러 스프레드 시트 개체를 생성하는 cfm 페이지가 있습니다. 다운로드 할 파일을 보내려고하면 마지막으로 생성 된 스프레드 시트 파일 만 다운로드로 보내집니다.여러 파일을 생성하여 압축 파일에 추가 한 다음 zip 파일을 파일 다운로드로 보냅니다.

이러한 파일을 zip에 쓰고 zip 파일을 다운로드하여 보낼 수있는 방법이 있습니까?

이 기존 논리입니다 :

for(VARIABLES.fileNumber = 0; VARIABLES.fileNumber < VARIABLES.maxFiles; VARIABLES.fileNumber = VARIABLES.fileNumber + 1) 
{ 
    /* code to create Spreadsheet here */ 




    VARIABLES.context = getPageContext(); 
    VARIABLES.context.setFlushOutput(true); 

    VARIABLES.response = VARIABLES.context.getResponse().getResponse(); 
    VARIABLES.response.reset(); 
    VARIABLES.response.setContentType("application/msexcel"); 
    VARIABLES.response.setContentLength(len(SpreadsheetReadBinary(VARIABLES.suppItemSpreadSheetObj)));  
    VARIABLES.response.setHeader("Content-Disposition","attachment;filename=MyComplianceStatusFile#VARIABLES.fileNumber#Of#VARIABLES.maxFiles#.xls"); 

    VARIABLES.out = response.getOutputStream();  
    VARIABLES.out.write(SpreadsheetReadBinary(VARIABLES.suppItemSpreadSheetObj));  


    VARIABLES.out.flush();  
    VARIABLES.out.close(); 
    } 

자,이 방법은 내가 생성 된 마지막 스프레드 시트를 얻는다. 생성 된 모든 스프레드 시트를 하나씩 가져 오거나 우편으로 올릴 수있는 방법이 있습니까?

+2

하나의 파일을 다운로드하는 방법이 더 일반적입니다. jsp. CF에서 표준 (더 간단한) 접근법은 ['cfcontent'] (https://learn.adobe.com/wiki/display/coldfusionen/cfcontent)를 사용하는 것입니다. CF에 익숙하지 않은 분이라면 [기능별 태그] (http://help.adobe.com/ko_KR/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec17576-7ffc.html) 및 [범주 별 기능]을 살펴 보시기 바랍니다. ] (http://help.adobe.com/ko_KR/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec1a60c-7ffc.html)보기와 같은 질문을 먼저보십시오. – Leigh

답변

5

예있다 : <cfzip>. 문서에는 사용 예제가 있지만 기본적으로 "RTFM"이라고 말하면서 채찍질을하지 않도록 여기에서 다시 작성하겠습니다.

<!--- This example shows how to zip the directory "c:\temp" into the ZIP file "e:\work\abc.zip". ---> 
<cfzip file="e:\work\abc.zip" source="c:\temp"> 

<!--- This example shows how to zip all the class files in a directory and add a subdirectory named "classes" to the JAR file entry name. ---> 
<cfzip file="e:\work\util.jar" action="zip" source="c:\src\util\" prefix="classes" filter="*.class"> 

<!---This example shows how to zip all of the log files in the ColdFusion directory and create a subdirectory called exception where zipped files are archived. 
<cfzip file="c:\zipTest\log2.zip" action="zip" source="c:\ColdFusion\" prefix="exception" filter="*.log"> 

<!--- This example shows how to overwrite all of the content of a ZIP file with the entries specified in the source. ---> 
<cfzip file="c:\currentApp.zip" source="c:\myApp\work" overwrite="yes"> 
+3

거기서 사람들을 다시 숟가락으로 먹이십시오. –

+0

죄송합니다. 나는 "Oh FFS, JFGI"로가는 것에 질 렸습니다. –

+0

누구나 ColdFusion의 한 줄을 작성하기 전에 문서에 반드시 도입해야한다고 생각합니다. 또는 더 나은 아직, 구글. – fyroc