Hi,
Something that I came across from Active Reports helpfiles is that
you can use ARViewer (arviewer.ocx) to view reports in IE (using VB 6).
Below is the way to go about it (in the help files):
________________________________________________________________________
________________
This is an example of inserting the viewer control into your page. You
will need to set up a licensing package file (LPK) as described in
Microsoft’s Internet Client SDK.
<Object ID="ARViewer1" WIDTH="869" HEIGHT="1143"
CLASSID="clsid:00C7C2A0-8B82-11D1-8B57-00A0C98CD92B"
codebase="arviewer.cab">
</Object>
<Script LANGUAGE="VBScript">
<!—
' Set the data path to the relative path
' of your pages output
Sub Window_onLoad()
ARViewer1.DataPath="salesbycountry.rdf"
End Sub
-->
</Script>
You can use ActiveReports to serve reports from your web server. You
will need to create an ActiveX DLL that combines all your reports with a
class that manages running and saving the reports to either an RDF
format or a PDF format.
The class will create an instance of the requested report and save it to
a directory where the ASP script can push it to the client.
Public Property Let Report(iRpt As eReport)
Dim hr As Long
Debug.Print "Report: ", iRpt
m_iReport = iRpt
End Property
Public Property Let OutputFormat(iFormat As eOutputFormat)
Debug.Print "OutputFormat: ", iFormat
m_iFormat = iFormat
End Property
Public Property Get FileName() As String
Debug.Print "FileName"
m_sFName = StripFileName(m_sFName)
FileName = m_sFName
End Property
Public Function RunReport() As Boolean
Dim rpt As Object
Dim pdf As New ActiveReportsPDFExport.ARExportPDF
Debug.Print "RunReport"
Select Case m_iReport
Case erptAnnualReports: Set rpt = New rptAnnualReport
Case erptCatalog: Set rpt = New rptCatalog
Case erptCustomerLabels: Set rpt = New rptCustomerLabels
Case Else
RunReport = False
Exit Function
End Select
rpt.Run False
m_sFName = String(255, Chr$(0))
' GetTempFileName is a Win32 API function, you need
' to add the declaration in one of your modules
If Not GetTempFileName(sServerPath, "AR", -1, m_sFName) Then
RunReport = False
Exit Function
End If
m_sFName = Left$(m_sFName, InStr(m_sFName, Chr$(0)) - 1)
Debug.Print m_sFName
If m_iFormat = eRDF Then
rpt.Pages.Save m_sFName
ElseIf m_iFormat = ePDF Then
pdf.FileName = m_sFName
pdf.Export rpt.Pages
End If
Unload rpt
Set rpt = Nothing
Set pdf = Nothing
RunReport = True
End Function
The ASP script will set the two properties Report and Output Format then
run the report.
<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim rptServer
Dim fname
Set rptServer = CreateObject("ARASPSample.ReportServer")
rptServer.Report = Request.Form("cboReport")
rptServer.OutputFormat = 1
If rptServer.RunReport() Then
fname = rptServer.FileName
%>
<CENTER>
<OBJECT ID="arv" WIDTH=95% HEIGHT=95%
CLASSID="CLSID:00C7C2A0-8B82-11D1-8B57-00A0C98CD92B"
CODEBASE="../bin/arviewer.cab">
<PARAM NAME="_ExtentX" VALUE="17674">
<PARAM NAME="_ExtentY" VALUE="10478">
</OBJECT>
</CENTER>
<BODY FONT="Arial">
<script LANGUAGE="VBScript">
<!--
Sub window_onload()
' set the initial reportsource data path
arv.DataPath="Reports/<%Response.Write fname%>"
end sub
-->
</script>
<%else%>
<BODY>
<P>
Error: Unable to create report.<BR>
Please send email to <A
HREF="mailto:
[email protected]">ActiveReports.Suppo
(e-mail address removed)</A><BR>
</P>
<%end if%>
</BODY>
________________________________________________________________________
________________
By idea is to convert the above sample to Asp.NET.
So we get:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm2.aspx.vb"
Inherits="AccessReportAutomation.WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm2</title>
<meta content="Microsoft Visual Studio.NET 7.0"
name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<OBJECT id="ARViewer1" style="WIDTH: 448px; HEIGHT:
422px" codeBase="arviewer.cab" height="422" width="448"
classid="clsid:00C7C2A0-8B82-11D1-8B57-00A0C98CD92B" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="9483">
<PARAM NAME="_ExtentY" VALUE="8932">
</OBJECT>
</form>
</body>
</HTML>
Its the next part of creating a class that gives problems (have called
the class
- Mehul_class). Here's the code:
Imports System.Diagnostics
Public Class Mehul_Class
Public Property Report(ByVal iRpt As eReport)
Get
Dim hr As Long
Debug.Write("Report: ", iRpt)
m_iReport = iRpt
End Get
Set(ByVal Value)
End Set
End Property
Public Property Let OutputFormat(iFormat As eOutputFormat)
Debug.Print "OutputFormat: ", iFormat
m_iFormat = iFormat
End Property
Public Property FileName() As String
Get
Debug.Write("FileName")
m_sFName = StripFileName(m_sFName)
FileName = m_sFName
End Get
End Property
Public Function RunReport() As Boolean
Dim rpt As Object
Dim pdf As New ActiveReportsPDFExport.ARExportPDF()
Debug.Write("RunReport")
Select Case m_iReport
Case erptAnnualReports : rpt = New rptNewReport()
Case erptCatalog : rpt = New rptCatalog()
Case erptCustomerLabels : rpt = New rptCustomerLabels()
Case Else
RunReport = False
Exit Function
End Select
rpt.Run(False)
m_sFName = String(255, Chr$(0))
' GetTempFileName is a Win32 API function, you need
' to add the declaration in one of your modules
If Not GetTempFileName(sServerPath, "AR", -1, m_sFName) Then
RunReport = False
Exit Function
End If
m_sFName = Left$(m_sFName, InStr(m_sFName, Chr$(0)) - 1)
Debug.Write(m_sFName)
If m_iFormat = eRDF Then
rpt.Pages.Save(m_sFName)
ElseIf m_iFormat = ePDF Then
pdf.FileName = m_sFName
pdf.Export(rpt.Pages)
End If
Unload(rpt)
rpt = Nothing
pdf = Nothing
RunReport = True
End Function
End Class
Question is what do i convert
Public Property Let OutputFormat(iFormat As eOutputFormat)
Debug.Print "OutputFormat: ", iFormat
m_iFormat = iFormat
End Property
into as vb.net doesnt support it? Also statements like
m_iReport = iRpt
in the 1st Report property - give an error that "Name m_iReport is not
declared".
However if in the help files is not declared anywhere (or am i missing
something?).
[See above for code that was provided in the help files].
Pls help,
Rgs,
Mehul