Forum Moderators: open

Message Too Old, No Replies

Scripting help: Access file with 3 columns

how to export it to simple HTML?

         

Darkelve

1:06 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



I've got a table in Access and have to publish the data on our website. I converted it to PDF, but our website also has to be accessible for visually impaired people. So I need to make Html tables as well.

The access file is very simple and has 3 colums A, B and C.

I would like to find a way to script it so that this structure is reached for each row:

CODE

<tr>
<td class="tdemright">Column A</td>
<td>Column B</td>
<td>Column C</td>
</tr>

There are 5 'worksheets' in the access file. Manually this would take an awful long time. But since there is a method in this, with scripting it should not be too difficult.

Can anyone help me with this?

I have uploaded the file for your reference, here:
<SNIP>

Many thanks!

Darkelve

[edited by: BlobFisk at 1:44 pm (utc) on Jan. 14, 2005]
[edit reason] No URLs please! See TOS [webmasterworld.com] [/edit]

rocknbil

4:35 pm on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know of a way to do it with Javascript, but you could do this directly with .asp. You'd connect to the database and traverse the recordset, outputting HTML. In fact, you could save a lot of trouble but just using the database on your site instead of generating pages. Just update the database as required and your pages would auto-update.

The following is probably outdated but it works, you need to get the adovbs.inc ADO constants include:

<!-- #include file="adovbs.inc" -->
<%

Dim objRec, selStr, fldCurrent, strCon, bgSwitch, counter
bgSwitch = 0
counter = 0

' This is going to vary from environment to environment, connects with database
set strConn = Server.CreateObject("ADODB.Connection")
strConn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("[your_database_filename.mdb]")

'Select the records
set objRec = Server.CreateObject ("ADODB.Recordset")
selStr = "select * from [tablename]"

'Open record object
objRec.Open selStr, strConn, adOpenStatic, adLockOptimistic

'This writes the table header by traversing the fields

response.write "<HTML><HEAD><TITLE>Database Listing</TITLE></HEAD><BODY>"
response.write "<TABLE CELLPADDING='1'><TR>"

For Each fld In objRec.Fields
response.write "<TD BGCOLOR='#000000' ALIGN='center'><FONT COLOR='#FFFFFF'><B>" & fld.Name & " " & fld.Type & "</B></FONT></TD>"
Next
response.write "</TR>"

'This writes out 50 rows of the records. Change the while to write all
' Use this for all: While not objRec.EOF

While counter < 50
Response.Write "<tr>"
For Each fldCurrent In objRec.Fields
Response.Write "<td nowrap">

If fldCurrent.Value <> "" Then
Response.Write Cstr(fldCurrent.Value) & "</td>"
Else
Response.Write "&nbsp;</TD>"
End If

Next
Response.Write "</tr>"
counter = counter + 1

objRec.MoveNext
wend
objRec.Close
Set objRec = Nothing

response.write "</TABLE><BR><BR>"

%>

Darkelve

5:05 pm on Jan 14, 2005 (gmt 0)

10+ Year Member



Thank you, but someone told me an easier way:

Import it in Gnumeric (Linux program, possibly has a Windows version too) and choose "Save as (X)html". Yes, it can even save as Xhtml!

But I do appreciate your suggestion and the work you did to provide this solution.

Problem SOLVED.

Darkelve