Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7909055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:14:06+00:00 2026-06-03T12:14:06+00:00

Changed Question: 5/5/12 2:34pm (PST) I would like to know if it is possible

  • 0

Changed Question: 5/5/12 2:34pm (PST)

I would like to know if it is possible to render a template from form POST data and in that template, provide a button/link to an Excel spreadsheet of the same POST data that was used in the template.

I have made an Excel download using the POST, and I have rendered a template using the POST, but I would like the following to happen with the form’s Submit button is pushed:
1. Send the information from the view to template, have the template render the information, in the template have a button/link that when clicked, a window pops up asking the user if they want to Open/Save the .XLS file.

The code I am using to do each follows:
1 Render template in new URL

return render_to_response('report/result.html', {long dictionary}, context_instance=RequestContext(request))

2 Export as .XLS file using template:

response2 = render_to_response('report/result.html', {long dictionary}, context_instance=RequestContext(request))

filename = "ToolboxReport%s.xls" % (datetime.now())

response2['Content-Disposition'] = 'attachment; filename='+filename

response2['Content-Type'] = 'application/vnd.ms-excel; charset=utf-8'

return response2

Here is my intended order:
1. At Options page: select options, click Generate Report button
2. At Results page: display information, display button/link to download this info as .XLS
3. (Optional) Clicks download button: Open/Save option appears to download the same information as .XLS

I can’t seem to get the POST data from the Options page to be used in both the Results page and the .XLS download.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:14:11+00:00Added an answer on June 3, 2026 at 12:14 pm

    I use two different buttons on my forms, one for listing the results and one for exporting them to excel.

    In the form template:

    <input type="submit" name="list" value="List Results" />
    <input type="submit" name="excel" value="Export to Excel" />
    

    And in my view function:

    # process your post data here...
    
    # end processing your post data
    if request.REQUEST.get('excel'): 
        # excel button clicked
        result = '<your content result here>'
        response = http.HttpResponse(result.encode("<encoding>", 'ignore'), content_type='application/vnd.ms-excel;charset=<charset>')
        response['Content-Disposition'] = 'attachment; filename="reports.csv"'
        response['Expires'] = "Mon, 26 Jul 2013 05:00:00 GMT"
        return response
    elif request.REQUEST.get('list'):
        # List button clicked
        return render_to_response(<some render param here>, <some context>, <etc>)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After my last question was solved the JSON I'm receiving from the server changed
Edit: Changed question title from Does C# allow method overloading, PHP style (__call)? -
So my question has changed from returning Infinity to returning NaN. If your FFT
My question changed. can I do the same thing using volume button instead? (that
Note that the question has been changed and no longer matches the answers I'm
I asked a previous question about this but it has changed since, I would
So the problem changed from what it was, i'll leave the original question below
I know this question has been asked in the past, but times have changed
I changed the question as its seems to be a problem with target not
EDIT: I have changed the question as it was too localized and gained negative

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.