Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2012, 06:31 AM
Registered User
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Export to Excel multiple worksheets

Hi There,

This might be a very old school query. But I am not able to crack it yet after hours of googling also.

"How do I export data into multiple worksheets from classic ASP page"

Any help on this regard is highly appreciable. Following is the piece of code how I am exporting data into a single worksheet -

<%
response.charset = "UTF-8"
Response.Buffer=true
'Response.ContentType = "application/download"
Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader "Content-Disposition", "attachment; filename=" & "File01.xls"
%>
<HTML xmlns:x="urn:schemas-microsoft-com:office:excel">
<HEAD>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>File01</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>File01-Actions</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>File01-Detailed</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo>
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</HEAD>
<BODY>
<TABLE>
<%

' Connection String
dim SQL, oConn

Set oConn = Server.CreateObject("ADODB.Connection")

oConn.Open vMdbConnStr

Dim rs, ds

Set rs = Server.CreateObject("ADODB.Recordset")
SQL = request.querystring("DBQuery")
rs.Open SQL, oConn
ds = rs.GetRows
Dim i, j
dim c

Response.Write "<tr>"
For c = 0 to UBound(ds,1)
Response.Write "<td style='border-left:none;border:.5pt solid windowtext;' bgcolor='#CCCCCC' bordercolor='#000000'><b>"
Response.Write rs.Fields(c).Name
Response.Write "</b></td>"
Next
Response.Write "</tr>" & vbcrlf

rs.Close
Set rs = Nothing
oConn.Close
Set oConn = Nothing

' Showing Each Row
For i = 0 To UBound(ds, 2)
Response.Write "<tr>"
' Showing Each Column
For j = 0 To UBound(ds, 1)
Response.Write "<td>"
Response.Write ds(j, i)
Response.Write "</td>"
Next
Response.Write "</tr>" & vbcrlf
Next

Erase ds

%>
</TABLE>
</BODY>
</HTML>


Thanks!
 
Old January 31st, 2012, 06:29 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Please make sure you post your solution if you find one. I have tried to achieve this with pure ASP before without success. Im not so sure its possible to be honest. Search this forum for more info, there have been a number of posts over the years. Good luck!
__________________
Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an Excel Spread with multiple worksheets hewstone999 Access VBA 1 March 7th, 2008 08:21 AM
Export to multiple Excel files using template ecapox Access VBA 0 February 5th, 2008 10:38 AM
Excel Worksheets brawny4 Excel VBA 2 December 29th, 2007 04:57 AM
updating multiple worksheets at once bcastello Excel VBA 3 October 17th, 2006 11:46 PM
Splitting Excel file into Multiple Worksheets tvschalapathirao Dreamweaver (all versions) 3 May 16th, 2005 02:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.