hi Chris,

Take heart! We do this and do it successfuly.

heres how.

we gather whatever paramaters from the user, then preform the SQL to get the
results just like normal for displaying on the page.

we then do a file write action.

in the file name we use the user referance # as a unique identifier for the
file name:
<@WEBROOT>\<@userreference>.csv


then, in the data to write section we put:

Header1,Header2,Header3,<@char code=13><@var local$Resultset aprefix=""
asuffix="" rprefix="" rsuffix="<@char code=13>" cprefix="" csuffix=",">

What this essentialy does is write out the file with commas at the ends of
the columns and new lines at the ends of rows so it can be read by Excel.
Header1,2 and 3 are the headers that will apear at the top of the columns.
They are optional of course, but make it look nicer and make the data make
more sense.

After the file action, we have a results html which looks like this:

<html>

<head>

<script language="JavaScript">

<!--

var Excel =
window.open('<@cgi><@appfilepath><@userreference>.csv','Excel',config='toolb
ar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');

Excel.focus();

//-->

</script>

</head>

<form name=excelform method=post action="JavaScript:history.go(-1)">

<center>

<input type=submit name=test value="Return">

</center>

</form>

</font>

</body>

</html>


What this does is pop open a new window, and the part that says 'Excel'
tells the browser that if possible, we want to open the file in an Excel
window, which it so happily obliges us.  This works great for us, and in
fact, I learned how to do this from a post by Scott Cadilac i believe so if
you have any problems with this or need it do behave differently then the
code above, im sure someone will be able to help you further (:


----- Original Message -----

From: Chris Smith
To: [EMAIL PROTECTED]
Sent: Sunday, February 16, 2003 5:22 PM
Subject: Witango-Talk: Opening a result set in excel from a taf action.


Hi All,

 I have an interface were I'm executing a dynamic query based on which form
fields were included in the post. Due to some space limitations I'm only
able to bring back 7 columns to screen for these reports. Which is okay, but
for more detail I wanted to be able to have the user click an export button
on the interface that would open the result set in the excel plugin for the
web browser. What I would like to do is re-execute the query but in the
excel post have more columns returned (the equal of Select *) This way the
user could "push" the results to excel and manipulate the data there...use
what columns the want...discard the columns they don't... Any suggestion?

csmith
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to