9 Replies - 2349 Views - Last Post: 14 October 2009 - 01:24 PM Rate Topic: -----

#1 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Request.Form isn't working

Posted 14 October 2009 - 07:15 AM

What is the easiest way to go about exporting a webpage table to a PDF and/or excel file? How do I tell the computer to get the data from the html results page? [b]The script below pulls up an empty spreadsheet.

<%
''// Set the name of the file that you are going to output
FileName = "JTDI Report.xls"

''// Build up a regular HTML table (this translates into the rows and cells in excel)
sData = "<table><tr><th></th><th></th></tr>"

sData = sData & "<tr><td></td><td></td></tr>"

sData = sData & "</table>"

''// Write out the table
response.write sData

''// Set the Header info
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment; filename=" & FileName
%>

This post has been edited by knockkneed81: 15 October 2009 - 05:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Request.Form isn't working

#2 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Re: Request.Form isn't working

Posted 14 October 2009 - 11:29 AM

View Postknockkneed81, on 14 Oct, 2009 - 06:15 AM, said:

What is the easiest way to go about exporting a webpage table to a PDF and/or excel file? How do I tell the computer to get the data from the html results page? The script below pulls up an empty spreadsheet.

<%
''// Set the name of the file that you are going to output
FileName = "JTDI Report.xls"

''// Build up a regular HTML table (this translates into the rows and cells in excel)
sData = "<table><tr><th></th><th></th></tr>"

sData = sData & "<tr><td></td><td></td></tr>"

sData = sData & "</table>"

''// Write out the table
response.write sData

''// Set the Header info
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment; filename=" & FileName
%>


[b]I found the code which converts my html table to excel, but it is automatically putting the results in an excel file. By default, I would like it to continue to display on the webpage, but would like to give the customer the option to export it to excel with a "Export to Excel" button on the page.

Was This Post Helpful? 0
  • +
  • -

#3 W3bDev  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: Request.Form isn't working

Posted 14 October 2009 - 11:38 AM

Set an onclick handler that will trigger the response you are looking for, instead of having it in the main method.
Was This Post Helpful? 0
  • +
  • -

#4 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Re: Request.Form isn't working

Posted 14 October 2009 - 12:29 PM

View PostW3bDev, on 14 Oct, 2009 - 10:38 AM, said:

Set an onclick handler that will trigger the response you are looking for, instead of having it in the main method.



Would it be easier to create a HTML form which points to a ASP file, which contains the code to export it.
Was This Post Helpful? 0
  • +
  • -

#5 W3bDev  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: Request.Form isn't working

Posted 14 October 2009 - 12:37 PM

Well, I guess if it's easier for you? I find the onclick handler easier myself.
Was This Post Helpful? 0
  • +
  • -

#6 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Re: Request.Form isn't working

Posted 14 October 2009 - 12:44 PM

View PostW3bDev, on 14 Oct, 2009 - 11:37 AM, said:

Well, I guess if it's easier for you? I find the onclick handler easier myself.



Can you let me know where I am going wrong with this script? The asp script works when I put it directly in the main code, but only pull up a blank excel file if I put it in a seperate file. I want the excel file to contain the results on the webpage.

Form:

<FORM METHOD="POST" ACTION="exporttoexcel.asp">
<INPUT TYPE="submit" VALUE="Export to Excel">
</FORM>


Asp Script:

<%Response.ContentType = "application/x-download"
Response.AddHeader "content-disposition","attachment;filename=Test.xls"%>

Was This Post Helpful? 0
  • +
  • -

#7 W3bDev  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: Request.Form isn't working

Posted 14 October 2009 - 12:52 PM

Well, it really depends on your content on the post page. Because you are moving away from the current page, none of the information is going with you, other than post values. If the information you are passing is within form fields, then you can use Request.Form to push the information to the second form.

By the way, is there a particular reason you are still using classic asp? Could run into some issues there because this is an asp.net forum.
Was This Post Helpful? 0
  • +
  • -

#8 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Re: Request.Form isn't working

Posted 14 October 2009 - 01:05 PM

View PostW3bDev, on 14 Oct, 2009 - 11:52 AM, said:

Well, it really depends on your content on the post page. Because you are moving away from the current page, none of the information is going with you, other than post values. If the information you are passing is within form fields, then you can use Request.Form to push the information to the second form.

By the way, is there a particular reason you are still using classic asp? Could run into some issues there because this is an asp.net forum.


Honestly...I am not a developer (My programming skills are below minimal). I have been tasked with building a webpage (still don't know how this has happened). I am slowly getting the site together, but everytime I get one thing working ....they ask me for something additional. I took java and vb classes in college and I swore to myself that I would not get into this particular field of technology, because I struggled in those classes. I have nothing but respect for programmers.
Was This Post Helpful? 0
  • +
  • -

#9 W3bDev  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 42
  • View blog
  • Posts: 379
  • Joined: 15-March 09

Re: Request.Form isn't working

Posted 14 October 2009 - 01:11 PM

Well, at least with the vs express edition (free) you get some tools to work with, with cases like this, verses relying on old technology...
Was This Post Helpful? 0
  • +
  • -

#10 knockkneed81  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 52
  • Joined: 05-November 08

Re: Request.Form isn't working

Posted 14 October 2009 - 01:24 PM

View PostW3bDev, on 14 Oct, 2009 - 12:11 PM, said:

Well, at least with the vs express edition (free) you get some tools to work with, with cases like this, verses relying on old technology...



Request.Form isn't working for me.

Form:

<FORM METHOD="GET" ACTION="exporttoexcel.asp">
<INPUT TYPE="submit" NAME="Export" VALUE="Export to Excel">
</FORM>



ASP:

<%
response.write(request.form("Export"))
Response.ContentType = "application/x-download"
Response.AddHeader = "content-disposition","attachment;filename=Test.xls"
%>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1