Skip to main content
WolfShade
Legend
October 14, 2015
Question

Page loads - generates Excel object - create link to download Excel spreadsheet

  • October 14, 2015
  • 1 reply
  • 562 views

Hello, all,

I'm helping one of my developers with a project, and I've got one requirement that I'm not entirely sure how to proceed with it.

The page in question runs a SELECT query from the database and displays the tabular information in a table.  As the table is being generated, I'm using spreadsheetnew() and associated commands to create an Excel object from said data.

Now, it would be real easy to introduce code that would automatically offer the Excel object as a spreadsheet upon page load.  What is being requested is for there to be a link to start that stream/download upon click; in case the user doesn't want to save or open the spreadsheet.

I don't want to run the query a second time to generate the Excel object.  Is there a way for me to pass the Excel object to another page to start the stream/download?

V/r,

^_^

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    October 14, 2015

    The client might want to restart the download later, should something go wrong. Another client might also wish to download the file. So you would need a persistent solution.

    One way to achieve this is to create a directory beforehand. Write the Excel object as a file to that directory. Then give the URL of the Excel file to the clients.

    WolfShade
    WolfShadeAuthor
    Legend
    October 14, 2015

    Thanks for the reply, BKBK‌, but this isn't for a public-facing page; this is an internal-only web application, and there's no telling how often the database is updated, so a direct-to-download (or -open) after the data is aggregated is the call.

    V/r,

    ^_^

    BKBK
    Community Expert
    Community Expert
    October 14, 2015

    What about the usual combination,

    <cfheader>

    <cfcontent>

    on the current page.