6 Replies Latest reply on Feb 13, 2008 11:10 PM by YogeshM

    download multiple Excel files

    gr8white Level 1
      I was assigned a project to produce multiple Excel files with the press of a single button. I am able to generate the files using CFCONTENT/CFHEADER. I used javascript to submit a form multiple times with different parameters to generate the separate files. I couldn't figure a way to synchronize the "file download" dialog with the browser window but I finally hit on using hidden iframes as the form target - one for each file. This worked fine on my system - each file would open a separate dialog (files are generated as "attachment"), one after the other. But when the client tries it, only one or sometimes two dialogs are opened, then it stops. We are both using IE v. 6.0 with slightly different minor version numbers.

      This would appear to be a browser issue - are there any settings that would affect this?

      Is there any way to check the existence or status of the "file download" dialog using javascript?

      The other possible solution would be to generate the multiple files on the server side and assemble them into a single ZIP for download - any thoughts on that?

      Thanks for any assistance.


        • 1. Re: download multiple Excel files
          insuractive Level 3
          Not sure what a fix to your current issue might be, but could you get away with creating 1 Excel file with multiple worksheets instead of multiple Excel file with 1 Worksheet each? If so, that might fix your multiple download issue. You can create multiple worksheet Excel files using the Jakarta POI Java package (which you probably already have on your server if you are using CFMX 7). I think I've seen some Custom Tag wrappers for POI that make it even easier to use.

          Otherwise, your zip solution might be your best bet. Browsers can be rather finicky about both frames and file downloads and when you mix multiple instances of both together you never know what might happen.
          • 2. Re: download multiple Excel files
            gr8white Level 1

            Thanks for the response. We do have the POI package and I have a little bit of familiarity with it. Multiple worksheets would be an ideal solution as that was the original request - the customer will actually be combining the multiple files into separate worksheets in a single file. But that will involve quite a bit of time for me to get up to speed on the ins and outs of the package and figuring out how things like formatting.

            For now I "solved" the problem by delaying the submission of each form by 10 seconds, obviously not an ideal solution but it may suffice until I come up with something better.

            • 3. Re: download multiple Excel files
              YogeshM Level 1

              I'm actually trying to generate multiple excel files at once, looping though a query and creating the files.

              However, when I launch the code, it is generating only the last file and not one by one.

              I unfortunately cannot use POI in this case because of heavy formatting of the excel files (tables, colspans, rowspans, colors, etc), unless you know of a way to do this with POI?

              Initially the files were generated 1 by 1. This works, no problem.

              But now, the users want the option to tick which files they want to generate and click on a Submit button to generate all the Excel files they have checked.

              Any idea on this issue?

              Pls also advise how you managed to delay the form submission by 10 seconds for each of the files you were creating.

              Thanks and regards,
              Yogesh Mahadnac
              • 4. Re: download multiple Excel files
                larry_schwartz Level 1
                There is <cfzip> in CF8. I would:

                Generate each XLS one at a time.
                Put it in a temp directory on the web server
                Zip them all up
                Serve the zip to the client.

                From a user perspective, this seems much better then dealing with multiple download dialogs.

                If you're not in CF8, there are custom tags available though they may cost something.
                • 5. Re: download multiple Excel files
                  gr8white Level 1

                  Here is the code I used. It sounds like almost exactly what you are trying to do so if you don't have the option of using cfzip you might try this. It presents a list of options and the user can select which ones to generate. Then when submitted another window is opened to allow the reports to be generated. Javascript setTimeout() function delays the submission of each report. We have this in production now and it seems to be working OK. You can tailor it to your own environment.

                  • 6. Re: download multiple Excel files
                    YogeshM Level 1
                    Hi Ken,

                    Many thanks for your prompt reply.

                    I'll give it a try.

                    Have a very nice day!

                    Best regards,