Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to export data to excel but...

Status
Not open for further replies.

Ken011

MIS
Oct 13, 2006
66
0
0
US
The submit button is showing up in excel.

Download Report, then
Code:
   <FORM style="display: inline;"> 
        <INPUT Type=Submit Name="Excel" Value="Excel"> 
    </FORM>

I created a search page with certain search params.

If you perform a search and there is a hit, the results of the search is displayed in a page.

What I wanted to do is export the same data that is displayed on a page into an excel spreadsheet.

The code snip above helps me accomplish that.

However, the issue that I have with it is that the exported data contains the word "Excel" which happens
because of this line:
Code:
<INPUT Type=Submit Name="Excel" Value="Excel">

This is only way I know how.

How do I fix this code so only exported data prints on an excel spreadsheet?

Thanks much as usual for your assistance
 
If you're results are contained with a recordset then you'll have no issues to get that export as a spreadsheet. But you need to define a recordset in order for it to work;

<%
If Request.Form("exportexcel")= "true" Then
Dim line, filename

line=profiles.GetString(,,"[_comma_]","[_linebreak_]","")
line=Replace(line,",","¸" )
line=Replace(line,vbCrlf," ")
line=Replace(line,"[_linebreak_]",vbCr)
line=Replace(line,"[_comma_]",",")
filename="report.csv"
Response.ContentType="application/xls"
Response.AddHeader "Content-Disposition", "attachment; filename=" & filename
Response.CacheControl="no-cache"
Response.Write(line)
Response.End()
End if
%>

Add a simple form like;

<form name="exportexcel" action="" method="post">
<input type="hidden" name="exportexcel" value="true" />
<button type="submit" class="export">Export 2 Excel</button>
</form>

This works fine for a number of my clients...
 
What you have here does not provide any ideas as to how you are doing the export, without which it is hard to investigate further.

Have you checked out which covers this topic ?

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Thank you very much.

I was missing this:

Code:
<input type="hidden" name="exportexcel" value="true" />

I appreciate your assistance.
 
You are right, Greg. I realized that I didn't provide enough info.

I was coming back to provide more info but decided to try puremm's solution and it worked.

I can probably improve it by looking at the link you sent me, which is what I am doing now.

Thanks as well for your help.
 
All the links to your examples are broken.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top