You can achieve your objective using ASP/ASPX. Using ASP/ASPX would
require the Microsoft IIS web server. Here is a sample using aspx which
displays an Excel Spreadsheet in a webpage. Note: This can also be
accomplished using ASP.
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(Src as Object, E as EventArgs)
Try
GetFile()
Catch ex As Exception
End Try
End Sub
Private Sub GetFile()
Dim FilePath As String = Cache("strFile").ToString
If Not Dir(FilePath).Equals("") Then
Dim fs As New FileStream(FilePath, FileMode.Open, FileAccess.Read)
Dim bw As New System.IO.BinaryReader(fs)
Dim byt() As Byte, i As Integer
byt = bw.ReadBytes(CInt(fs.Length))
i = byt.Length()
Response.ContentType = "application/vnd.ms-excel"
Response.OutputStream.Write(byt, 0, i)
Response.OutputStream.Close()
End If
End Sub
</script>
<HTML>
<HEAD>
<title><%=Cache("strFileName")%></title>
</HEAD>
<body >
<form>
</form>
</body>
</HTML>
To use this as straight ASP, just comment out the words
'Try
...
'Catch
and leave out the import line
<%@ Import Namespace="System.IO" %>
Note: If you load the .Net Framework on the server with IIS (IIS 5),
then the above ASPX code should run fine. You can write it straight in
Notepad. This routine uses a byte array and the line
Response.ContentType = "application/vnd.ms-excel"
is where the magic happens. Where Access comes into the picture here is
that you generate the Excel Report from Access. All of my Access
reports operate this way: I generate the report and then copy it to the
web server for viewing. The Response.ContentType line displays the
Excel Sheet in its native format with tabs and all. The only caveat
with this is that if someone tries to edit the sheet from the Web
Browser, the Excel file becomes unusable/uneditable for anyone else -
becomes read-only if edited from the web. Have your users download the
file first and then make edits to it.
Rich
*** Sent via Developersdex
http://www.developersdex.com ***