My favorites
▼
|
Sign in
lineadecodigo
Web Code Samples in spanish
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
lineadecodigo_asp
/
ado
/
leer-excel.asp
r478
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<%@ Language=VBScript %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Leer de una hoja de datos Excel</title>
</head>
<body>
<h1>Leer de una hoja de datos Excel</h1>
<%
'Las variables del archivo adovbs.inc
Const adOpenStatic = 3
Const adLockPessimistic = 2
'Nos conectamos a la hoja de datos del Excel
Set db = Server.CreateObject("ADODB.Connection")
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "Driver={Microsoft Excel Driver (*.xls)};Dbq="
& Server.MapPath("Libro1.xls") & ";"
db.open DB_CONNECTIONSTRING
'Recordset correspondiente a un rango de datos
set rs = Server.CreateObject("ADODB.Recordset")
SQLStr = "SELECT * FROM alumnos"
rs.open SQLStr,DB_CONNECTIONSTRING, adOpenStatic
,adLockPessimistic, adCmdText
'NĂºmero de columnas de la tabla
columnas = rs.Fields.Count
Response.Write("<table width='20%' border='1'><tr>")
'Mostramos el tiulo de la tabla.
For I = 0 To columnas - 1
Response.Write "<td align='center'><b>"
& rs.Fields.Item(I).Name & "</b></td>"
Next
Response.Write("</tr>")
'Nos ponemos en el primer registro
rs.MoveFirst
'Mostramos los datos
Do While Not rs.EOF
Response.Write("<tr>")
For I = 0 To columnas - 1
Response.Write ("<td>" & rs.Fields.Item(I).Value & "</td>")
Next
Response.Write "</tr>"
rs.MoveNext
Loop
Response.Write("</table>")
'Eliminamos el recordset
rs.Close
Set rs = Nothing
'Eliminamos la bd
db.Close
Set db = Nothing
%>
<br><br>
<hr>
Artículo disponible en: <a href="http://lineadecodigo.com/asp/leer-de-un-excel-con-asp/">http://lineadecodigo.com/asp/leer-de-un-excel-con-asp/</a><br/>
<a href="http://lineadecodigo.com" title="Linea de Codigo">lineadecodigo.com</a>
</body>
</html>
Show details
Hide details
Change log
r158
by vcuervo on Aug 24, 2009
Diff
Leer un Excel con ASP
Go to:
...adecodigo_asp/ado/leer-excel.asp
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 2022 bytes, 79 lines
View raw file
Powered by
Google Project Hosting