"middletree" <mi********@htomail.com> wrote in message
news:#v**************@TK2MSFTNGP14.phx.gbl...
Yes. I am working on it right now. I think I misunderstood hwo it works,
and now I have a better handle on it. Let's see what I can come up with . . .
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:U7********************@comcast.com...
Is that what you really want?
What about this:
1) surround your table with:
<span id="sortabled"> and </span>
2) add this code at the top of the page:
<form action="Sortabler.asp" method="post" name="formXL">
<input type="button" value="Excel" onclick="sortabler()">
<textarea name="Xcel" cols="1" rows="1" style="display:none"></textarea>
</form>
3) Add this code in the Head section
<script type="text/javascript">
function sortabler() {
var what = document.getElementById("sortabled").innerHTML;
var code = [
'<' + '%@ Language="VBScript" %>',
'<' + '% Response.Expires = -1',
' Response.ExpiresAbsolute = Now()-1',
' Response.ContentType = "application/vnd.ms-excel"',
' Response.Buffer = True',
' Response.Clear',
' Response.AddHeader "Content-Disposition",
"filename=Sortable.xls"',
'%>',];
var page = code.join("\n");
var xcel = page + what;
document.formXL.Xcel.value = xcel;
document.formXL.submit();
}
</script>
4) create a new ASP page called "sortabled.asp":
<%@ Language='VBScript' %>
<% Option Explicit
'*
Const cASP = "Sortablex.asp"
'*
Dim strASP
strASP = Server.MapPath(cASP)
Dim strXLS
strXLS = Request.Form("Xcel")
'Response.Write Len(strXLS)
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strASP) Then
objFSO.DeleteFile(strASP)
End If
Dim objOTF
Set objOTF = objFSO.OpenTextFile(strASP,2,True)
objOTF.Write(strXLS)
Set objOTF = Nothing
Set objFSO = Nothing
'*
Response.Redirect(cASP)
%>
Then when you click on the "Excel" button
on the page with your table, it:
1) extracts the HTML between the span tags,
2) puts it in a hidden textarea prefaced with the AddHeader code,
3) submits the textarea in the form to the server,
4) which writes out a new ASP file
5) and then opens it in Excel!
It works for me! Try it and let me know.