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

ASP to Excel

Status
Not open for further replies.

030575

MIS
Joined
Feb 20, 2005
Messages
4
Location
US
Hello eveyone,
I know this topic has been discussed quite a bit on this forum. I went through the examples but am still having some problems.

My output asp page has three images and an html table. I added the line at the top of the page to display the Excel page. I see the images overlapping the first row of the table (the column heading) but I don't see the actual records that are queried. It feels like the information is being displayed in the Excel Format before the recordset is entered.

Here's the code:

<%@ Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
%><html>

<head>
<title>View Ts</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim t
Dim size
Dim depat
Dim department

depat = Request.Form("department")
Response.write(depat)

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("t.mdb")

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=guestbook"

'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT TDetails.* FROM TDetails;"

'Open the recordset with the SQL query
rsGuestbook.Open strSQL, adoCon


%>
<br>
<br>
<br>
<br>
<br>
<table>
<tr>
<font face="arial, helvetica" color="#000066" size="2"><b>View Ts</b></font>
</tr>
<tr>
</tr>
<tr>
<td><img src = "office1.jpg">
</td>
<td><img src = "office2.jpg">
</td>
<td><img src = "office3.jpg">
</td>
<td>
<font face="arial, helvetica" color="#000066" size="1"><b>The Table lists all <font color = #FF0000> <%=depat%> </font> Ts.</b></font>
</td>
</tr>
</table>
<table border = "1" width = "1060">
<tr>
<td><font face="arial, helvetica" color="#000066" size="1"><b>T</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Size</b></font></td>
<td><font face="arial, helvetica" color="#000066" size="1"><b>Department</b></font></td>
</tr>

<%

'Loop through the recordset
Do While not rsGuestbook.EOF

if ((rsGuestBook("Department") = depat)) Then


'Write the HTML to display the current record in the recordset
t = rsGuestBook("T")
size = rsGuestBook("Size")
department = rsGuestBook("Department")


%>

<tr>

<td>

<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=t%></font>&nbsp;&nbsp;&nbsp;
</td>

</td>

<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=size%></font>&nbsp;&nbsp;&nbsp;
</td>

<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=department%></font>&nbsp;&nbsp;&nbsp;
</td>


</tr>

<% end if %>
<%
'Move to the next record in the recordset

rsGuestbook.MoveNext

Loop

'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>

</table>
<br>
<br>
<br>
<table>
<a href = "tmenu.asp"><font face="arial, helvetica" color="#000066" size="1">
Return to Main Menu</font></a>
</table>
<script>footer()</script>
<!-- end footer -->
</body>
</html>

Thank you very much.

Pal
 
To:op
[1] You have a typo nested td.
[tt]
<td>

<td>
</font><font face="arial, helvetica" color="#000066" size="1">
<%=t%></font>&nbsp;&nbsp;&nbsp;
</td>

</td>
[/tt]
[2] You have to limit the size of the img or else you have to device more stylistic config. Limit them (office1 ... jpg) to real small about the size of a normal cell like this to start with.
[tt]
<img src = "office1.jpg" height="20" width="50">
<img src = "office2.jpg" height="20" width="50">
<img src = "office3.jpg" height="20" width="50">
[/tt]
Then re-adjust the size to your liking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top