Data from excel to ASP - range issue
new_learner | Posted 1:09am 5. February 2010 Server Time |
Hi All,
I am able to get the data from excel to an asp page, however i am facing an issue here...any help would be appreciated truly.
Here is what i do...
I am extracting the data from excel to asp in the table format with the table border =1. When i view the data on the asp page i see blank rows (thats because there are is no data) Issue here is that i do not want the border to be visible where there is no data...that is: I have a data of about 100 rows but have given range upto 200 rows for future use. what i want is that as and when i enter the new data(in the excel file) in the next row, the table should show it with the border and border should not be visible for the next row where is no data...i hope i am clear..
Here is my code:
<!-- Begin ASP Source Code -->
<%@ LANGUAGE="VBSCRIPT" %>
<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Schedules1"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = objConn
objRS.CursorType = 3 'Static cursor.
objRS.LockType = 2 'Pessimistic Lock.
objRS.Source = "Select * from new1"
'objRS.Open
If objRS.Open=0 then
response.write "connected"
else
response.write "connected"
end if
%>
<%
Response.write"<br>"
'Printing out original spreadsheet headings and values.
'Note that the first recordset does not have a "value" property
'just a "name" property. This will spit out the column headings.
Response.Write("<TABLE border=1><TR>")
For X = 0 To 8
Response.Write("<TD>" & objRS.Fields.Item(X).Name & "</TD>")
Next
Response.Write("</TR>")
objRS.MoveFirst
While Not objRS.EOF
Response.Write("<TR>")
For X = 0 To objRS.Fields.Count - 1
Response.write("<TD>" & objRS.Fields.Item(X).value)
Next
objRS.MoveNext
Response.Write("</TR>")
Wend
Response.Write("</TABLE>")
%> |
katy8439 | Posted 6:08am 5. February 2010 Server Time |
Have a look at the following example, you can do what you're after apply CSS to the table - empty cells are hidden:
<html>
<head>
<style type="text/css">
table {
border-collapse:collapse;
empty-cells:hide;
}
td {
border-style:solid;
border-width:1px;
border-color:#999999;
padding:0px;
}
</style>
</head>
<body>
<table>
<tr>
<th>Title one</th>
<th>Title two</th>
</tr>
<tr>
<td>value</td>
<td>value</td>
</tr>
<tr>
<td>value</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>value</td>
<td>value</td>
</tr>
</table>
</body>
</html>
new_learner | Posted 7:32pm 9. February 2010 Server Time |
Thank You Katy, it worked perfectly fine. Will come back with some more queries...till then have a great day. Thank You once again.
Reply to Post Data from excel to ASP - range issue
|
|
|