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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.ContentType = "application/vnd.ms-excel" HELP

Status
Not open for further replies.

zishan619

Programmer
May 28, 2003
284
MX
Hi:
I am using this Response.ContentType "application/vnd.ms-excel" in my code to bring place an excel looking like document on the browser. But it seems not to be filling in the data. What can I do to make it fill in the data?
<%@ Language=VBScript %>
<%
Response.Expires = -1000
Response.ContentType = &quot;application/vnd.ms-excel&quot;
Response.Write &quot;<HTML>&quot;
Response.Write &quot;<HEAD>&quot;
Response.Write &quot;</HEAD>&quot;
Response.Write &quot;<BODY>&quot;

Dim rs
Dim strFile_Lookup
Dim strFile_Function
Dim fso
Dim ts
Dim strSQL
Dim strLine
strFile_Lookup = &quot;&quot;
strFile_Function = &quot;&quot;

strFile_Function = strFile_Function & &quot;Function Productivity()&quot; & vbcrlf

strSQL= &quot;SELECT [A].[LastName] + ' , ' + [A].[FirstName] AS Analyst, [M].[LastName] + ' , ' + [M].[FirstName] AS Manager, A.CCNum, TAS_TimeProdData.dblHours AS Total_Hours, TAS_validTimeProdCodes.TPCode AS Category, TAS_TimeProdData.dtsDate &quot;
strSQL = strSQL & &quot;FROM (TAS_PeopleDynamic AS A INNER JOIN (TAS_TimeProdData INNER JOIN TAS_validTimeProdCodes ON TAS_TimeProdData.TPCodeID = TAS_validTimeProdCodes.TPCodeID) ON A.UID = TAS_TimeProdData.UID) INNER JOIN TAS_PeopleDynamic AS M ON A.MgrUID = M.UID &quot;
'strSQL = strSQL & &quot;WHERE A.CCNum='&quot; & CCNum & &quot;' AND TAS_TimeProdData.dtsDate Between '&quot; & StartDate & &quot;' AND '&quot; & EndDate & &quot;'ORDER BY dtsDate&quot;
strSQL = strSQL & &quot;WHERE A.CCNum='1867' AND TAS_TimeProdData.dtsDate Between '01/01/04' AND '01/01/04'ORDER BY dtsDate&quot;
OpenADOConn
set rs = server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open strSQL, ADOConn, 1, 3 'adOpenKeyset , optimistic
strLine=&quot;&quot;
For each x in rs.Fields
strLine = strLine & x.name & chr(9)
Next
strLine = strLine & vbcrlf

do while not rs.EOF
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
Next
rs.MoveNext

strLine = left(strLine, len(strLine)-1) & vbcrlf
Loop
rs.close
set rs = nothing
CloseADOConn

strFile_Function = strFile_Function & &quot;End function&quot; & vbcrlf
Dim strFileNameRelative
set fso = server.CreateObject(&quot;scripting.FileSystemObject&quot;)
strFileNameRelative = &quot;..\images\tmpxls\TAS_Prod_&quot; & GetNTLogin & &quot;.xls&quot;
strFileName = server.MapPath(strFileNameRelative)
Set ts = fso.CreateTextFile(strFileName, True)
ts.writeline strLine
ts.Close
Set ts=Nothing
Set fso=Nothing



Response.Write &quot;</BODY>&quot;
Response.Write &quot;</HTML>&quot;
%>







 
It appears that your writing the data to a local xls file, but never actually display tatfile to the user (only a few begin and end HTML tags).
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Huh??....I am new at this. It is going to a file on the server. How do I open the data in that file on the screen right away. It does create the file. I need to open it when the person selects the criterias. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top