CSV not loading

S

Silver_Soul

Afternoon

This CSV file doesn't work and i don't know why? This page is refered
to by another page by a href link. This page should show the link to
the CSV file.


---------------------------------------------

<%

var tlist = new TradeList()

var fso = Server.CreateObject("Scripting.FileSystemObject");
var fo = Server.MapPath("/admin/user_csv") + "\\" ;
var d = new Date();
var fname = "user_csv_" + d.getDate() + "-" +
Utils.MONTH[d.getMonth()] + "-" + d.getYear() + ".csv";
%>
<html>
<head>
<title>Admin Section</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body>
<!-- #include file="top.asp" -->
<tr>
<td align="center" bgcolor="#FFFFFF" style="padding:15px;"><p
class="title">Click below to create a User.CSV </p>
<%
if (!tlist.EOF) {

var totalPayout = 0;
var i = 1;
var tfile = fso.createTextFile(fo + fname,true);
tfile.writeLine("ID,USERNAME,PASSWORD,FIRSTNAME,LASTNAME,GENDER,EMAIL,ADDRESS1,ADDRESS2,TOWN,COUNTY,POSTCODE,PHONE,USERTYPE,STATUS,ENVIROPOINTS,HEARDABOUTFROM,OPTOUT,BUSINESS,DOB,CONFIRMED_ENVIROPOINTS,EARNER_TOTAL,DATE_JOINED,EARNER_ID,PROMO_CODE,CHARITY_DETAILS,NEW_PHONE_DUE");

// Load User
var user = new User()
user.loadFromId(tradeItem.userId,conn);

// Write Line in from user class to CSV
tfile.writeLine(
user.id + "," +
user.username + "," +
user.password + "," +
user.firstname + "," +
user.lastname + "," +
user.gender + "," +
user.email + "," +
user.username + "," +
user.address1 + "," +
user.address2 + "," +
user.town + "," +
user.county + "," +
user.postcode + "," +
user.phone + "," +
user.usertype + "," +
user.status + "," +
user.enviropoints + "," +
user.heardabout + "," +
user.optout + "," +
user.business + "," +
user.dob + "," +
user.confirmedpints + "," +
user.earnerTotal + "," +
user.dateJoined + "," +
user.earnerId + "," +
user.promoCode + "," +
user.charityDetails + "," +
user.newPhoneDue);

;

if (counter >= lowerRec && counter <= higherRec) {

recsDisplayed++;
}
tlist.moveNext();
counter++;


tfile.close();
}
%>
<p class="title">
<%
if (fso.fileExists(fo + fname)) {
Response.Write("inside the loop");
Response.Write("<a href=\"/admin/user_csv/" + fname +"\"
target=\"blank\">" + fname + "</a>");
Response.Write("going out of the loop");
}
%>
</p>
<p><a href="index.asp">Return to Admin Home</a></p>
</td>
</tr>

-----------------
I don't know why this doesn;t work? has anyone got any ideas?

Cheers

Nick
 
W

Walton

what doesn't work about it?

instead of creating a csv "file", why not just have the javascript
write the text out to the page and set the page's mime type as
text/csv? when you click on the href, the browser should recognize it
as a csv file and allow you to save it as one.
 
W

Walton

i have to append something to my last statement... i've never output a
csv using javascript so i can't say for sure if that will work, but
it's worth a try.

they way i have gotten csv to work in the past was with a servlet. i
just had the servlet write the csv and then set the mime type.

i'm curious to see if it can be done like that in javascript. please
let me know how it goes. thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top