Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set up ActiveX Viewer for Web viewing

Status
Not open for further replies.

gquint

Programmer
Oct 31, 2001
9
NL
On the web I see a lot of information about problems with CR ActiveX Viewer but not about installing. I guess I miss something here.
I use Crystal Reports 8.5 and I want to deploy my reports to the end users by Web without using Crystal Enterprise (we use our own web-framework). Exporting to pdf works fine. Can I use the Crystal ActiveX Viewer as well? Where can I find it and how should I install it?
 
In order to deploy your Crystal Reports over the web you are going to have to install and configure Crystal Enterprise on the web server.

Once you have this done, then when users make a request for a report, the default viewer will be DHTML (no client install), but you could change this to be the ActiveX by default if you wish. Here is a Crystal KBase with instruction on this - c2012241

The ActiverX viewer alone will not provide enough for the reports to run.

If not this, and depending on your needs, you could stick with a PDF export and add the link to your existing site. All users will likely already have the Acrobat Reader installed. This will not allow report refreshing though.

Cheers,

SurfingGecko
Home of Crystal Ease
 
Not exactly true. I was using the CR 8.5 RDC to generate reports and the active x viewer to display the reports in an asp application. The sample code for this is still available on the crystal decisions web site. Had to abandon this when I converted to .net. You don't say what web technology you are using. Found the active x control would not work well in .net. I was able to configure com interop to use it but it would not scale and microsoft told us it was a limitation of com interop. I have the asp code if you want to take a look.
 
thanks cjlarie,
We are using apache web server and delphi web snap for the content. Up to now we store pdf-files in a database and present them to the web browser. I want to change that to storing rtp-files with data and viewing them by the ActiveX-viewer in the web browser to enable drill-down, exports and so on. I would like to have a look at your aps code if possble.
 
Here is the code.
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
' ProcessReport8.asp
Option Explicit
Response.Buffer = true
Response.Expires=-1441
Server.ScriptTimeout = 4000

' Querystring should contain:
' Name: is the name of the report
' RP: is the path from which the report was printed
' this is used to find the standard report subdirectory
' P#: parameters to be passed to the report
%>

<HTML>
<HEAD>
<TITLE>Process a Report</TITLE>
</HEAD>


<%
' Declare variables used

dim ErrNumber
dim rsReportLog
dim PathReportName

dim DB
dim SQL
dim DSN
dim DBNAme

dim UserID
dim Password

dim ReportName

dim i
dim j
dim m

dim Path
dim AppPath
dim oRptOptions
dim oOptions

dim CRTable
dim CRTables
dim CRTablesCnt

dim CRSections
dim CRSectionsCnt
dim CRSection

dim CRSubReport

dim CRReports
dim CRReport
dim CRReportsCnt

dim ReportObject
dim ReportDatabase
dim StoredProcParamCollection
dim Item
dim ObjectCnt
Dim SectionCnt
dim Temp


Set DB = Server.CreateObject (&quot;ADODB.Connection&quot;)
DB.CommandTimeout = 240
DB.Open Application(&quot;Aware_ConnectionString&quot;)

' File System Object
Dim FSO

' Set the connection to the alternate if Alternate Server Flag is set
if Request.QueryString(&quot;S&quot;) <> &quot;&quot; and _
ucase(Request.QueryString(&quot;S&quot;)) <> &quot;FALSE&quot; then

' Set the Database name
DBName = Application(&quot;Second_Database&quot;)
DSN = Application(&quot;Second_DSN&quot;)

' Get the user id and password
UserID = Application(&quot;Second_RuntimeUserName&quot;)
Password = Application(&quot;Second_RuntimePassword&quot;)

' Set the connection to the same as the Aware system
else

' Set the Database name
DBName = Application(&quot;Database&quot;)
DSN = Application(&quot;DSN&quot;)

' Get the user id and password
UserID = Application(&quot;Aware_RuntimeUserName&quot;)
Password = Application(&quot;Aware_RuntimePassword&quot;)

end if

' Set the DSN to the same as the Database name
' DSN = DBName

' Get the name of the report to be printed
Reportname = Request.QueryString(&quot;Name&quot;)

' Remove subdirectory information from the reportname
do while instr(ReportName,&quot;\&quot;) > 0
ReportName = mid(ReportName, instr(ReportName,&quot;\&quot;) + 1)
loop

' Read the parameters for use in the report
' Parameters must be contiguos, ex: p1=VR,p2=7002
i = 0
dim Parms()
redim Parms(0)
do while not(isempty(Request.QueryString(&quot;P&quot; & i)))

redim preserve Parms(i+1)
Parms(i+1) = Request.QueryString(&quot;P&quot; & i)

i = i + 1

loop


'==================================================================
' Create the report object for this session if it has not yet been created in this session

if not IsObject (session (&quot;oApp&quot;)) then
set session (&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application.8&quot;)
end if

' Create a File System Object
set FSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)

' Determine path to application server
AppPath = Request.ServerVariables(&quot;APPL_PHYSICAL_PATH&quot;)

dim LeftString
dim RightString

' BARTZ
' change the /s to For i = 1 to len(AppPath)
If Mid(AppPath,i,1) = &quot;/&quot; Then
LeftString = Mid(AppPath,1,i-1)
RightString = Mid(AppPath,i+1,Len(AppPath))
AppPath = LeftString & &quot;\&quot; & RightString
end if
next

' Make sure the path ends in if right(AppPath,1) <> &quot;\&quot; then
AppPath = AppPath & &quot;\&quot;
end if

' Determine path to datapage from which this report is being run
Path = Request.QueryString(&quot;RP&quot;)


if right(Path,1) <> &quot;\&quot; then
Path = Path & &quot;\&quot;
end if

' Hardcoded Report Name
' ---------------------
if Reportname <> Request.QueryString(&quot;Name&quot;) then
Path = &quot;c:\inetpub\ else
Path = Path & &quot;Reports\&quot;
end if

if right(Path,1) <> &quot;\&quot; then
Path = Path & &quot;\&quot;
end if

if Reportname <> Request.QueryString(&quot;Name&quot;) then
' . . . . . . . . . . . . . . . . . . . . . . . . . added by -dh 9/14/2000
dim qsName
dim iSlash


qsName = Request.QueryString(&quot;Name&quot;)
ReportName = Path & Right(qsName,len(qsName) - 3)
Path = &quot;&quot;

' The directory was passed so check to make sure the report exists
if not(FSO.FileExists(Path & Reportname)) then
Response.Write (&quot;Hard coded filename not valid.<BR>&quot;)
Response.Write (&quot;Error: &quot; & Path & Reportname & &quot; not found.<BR>&quot;)

Response.Write (&quot;Path = &quot; & Path & &quot;<BR>&quot;)
Response.Write (&quot;ReportName = &quot; & ReportName & &quot;<BR>&quot;)
set FSO = nothing


' Everything is cool, set up variables for use when opening the report
else
'ReportName = Request.QueryString(&quot;Name&quot;) 'I cut this -dh +++++++++++++++
'Path = &quot;&quot;
end if

' Look for the report in the Xtend directory, this is first place to look if not hard coded
elseif FSO.FileExists(AppPath & &quot;xtend\reports\&quot; & ReportName) then
Path = AppPath & &quot;xtend\reports\&quot;

' Look for report in the common application directory
elseif FSO.FileExists(AppPath & &quot;common\reports\&quot; & ReportName) then
Path = AppPath & &quot;common\reports\&quot;

' Look for report in reports subdirectory under the page where the report was generated
' If not found, the report was not found and there is an error condition
elseif not(FSO.FileExists(Path & ReportName)) then
Response.Write (&quot;Error: &quot; & Path & Reportname & &quot; not found.<BR>&quot;)
set FSO = nothing
Response.end

end if

' Clean up
Set FSO = nothing
'==================================================================
' Clear report session variable
if isobject(session(&quot;oRpt&quot;)) then
set session(&quot;oRpt&quot;) = nothing
end if

PathReportName = Path & ReportName

on error resume next
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & ReportName, 1)
ErrNumber = Err.Number
on error goto 0

' BARTZ
' -----
SQL = &quot;exec dbo.rpInsertReportLog &quot;
SQL = SQL & &quot;'&quot; & PathReportName & &quot;',&quot;
SQL = SQL & &quot;'Creating Session(oRpt)',&quot;
SQL = SQL & Err.Number & &quot;,&quot;
SQL = SQL & &quot;'&quot; & Session(&quot;Staff_Name&quot;) & &quot;'&quot;
set rsReportLog = DB.execute(SQL)
set rsReportLog = nothing

if ErrNumber <> 0 Then
Response.Write &quot;<BR>An Error has occurred on the server in attempting to access the following data source - &quot; & DSN
Response.Write &quot;<BR>Crystal Error: &quot; & ErrNumber
Response.End
end if

' Check for errors when opening the report
if not isobject(Session(&quot;oRpt&quot;)) then
Response.write(&quot;<BR>Unable to open report &quot; & path & ReportName)
Response.End
end if

Session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
Session(&quot;oRpt&quot;).EnableParameterPrompting = False

Set CRTables = Session(&quot;oRpt&quot;).Database.Tables
CRTablesCnt = CRTables.Count
For i = 1 to CRTablesCnt
Set CRTable = CRTables.Item(cint(i))
CRTable.SetLogOnInfo cstr(DSN), cstr(DBName), cstr(userid), cstr(password)
Next
Set CRTables = Nothing

Set CRSections = Session(&quot;oRpt&quot;).Sections
CRSectionsCnt = CRSections.Count
For i = 1 to CRSectionsCnt
Set CRReports = CRSections.Item(CInt(i)).ReportObjects
CRReportsCnt = CRReports.Count
For j = 1 to CRReportsCnt
If CRReports.Item(CInt(j)).Kind = 5 Then
Set CRSubreport = session(&quot;oRpt&quot;).OpenSubreport(CRReports.Item(CInt(j)).SubReportName)
Set CRTables = CRSubreport.Database.Tables
CRTablesCnt = CRTables.Count
For m = 1 to CRTablesCnt
CRTables.Item(m).SetLogOnInfo cstr(DSN), cstr(DBName), cstr(userid), cstr(password)
Next
End if
Next
Next

Set StoredProcParamCollection = Session(&quot;oRpt&quot;).ParameterFields
i = 0
For each Item in StoredProcParamCollection
i = i + 1
if ubound(Parms) >= i then
Temp = Parms(i)
select case Item.ValueType

case 7
' Number field
' Need to check to see if ANY of the parameters is blank
' If it's blank, set the value to 0 so it won't cause problems
if trim(Temp) = &quot;&quot; Then
Temp = 0
end if
Item.SetCurrentValue cdbl(Temp)

case 16,10
' Date & DateTime fields
Temp = trim(Temp)
if instr(temp,&quot;/&quot;) < 4 then
dim TempDate
dim strTemp

TempDate = left(Temp, instr(Temp, &quot; &quot;))
if len(month(TempDate)) < 2 then
Temp = year(TempDate) & &quot;/0&quot; & month(TempDate)
else
Temp = year(TempDate) & &quot;/&quot; & month(TempDate)
end if

if len(day(TempDate)) < 2 then
Temp = Temp & &quot;/0&quot; & day(TempDate)
else
Temp = Temp & &quot;/&quot; & day(TempDate)
end if

'add time if type DateTime, otherwise leave as just date
if Item.ValueType = 16 then
Temp = Temp & &quot; 00:00:00.000&quot;
end if
end if

Temp= mid(Temp,6,2) & &quot;/&quot; & _
mid(Temp,9,2) & &quot;/&quot; & _
left(Temp,4)

Item.SetCurrentValue cdate(Temp)

case else
Item.SetCurrentValue cstr(Temp)

end select

else
Item.SetCurrentValue Item.DefaultValue,Item.ValueType
end if
next

Set CRTables = Nothing
Set CRTable = Nothing
Set CRSubreport = Nothing
Set CRReports = Nothing
Set CRSections = Nothing

'==================================================================
' Retrieve the Records
On Error Resume Next

session(&quot;oRpt&quot;).ReadRecords
ErrNumber = Err.Number
On Error GoTo 0

' BARTZ
' -----
SQL = &quot;exec dbo.rpInsertReportLog &quot;
SQL = SQL & &quot;'&quot; & PathReportName & &quot;',&quot;
SQL = SQL & &quot;'Reading Records',&quot;
SQL = SQL & Err.Number & &quot;,&quot;
SQL = SQL & &quot;'&quot; & Session(&quot;Staff_Name&quot;) & &quot;'&quot;
set rsReportLog = DB.execute(SQL)
set rsReportLog = nothing

if ErrNumber <> 0 Then
Response.Write &quot;<BR>An Error has occurred on the server in attempting to access the following data source - &quot; & DSN
Response.Write &quot;<BR>Crystal Error: &quot; & ErrNumber
if ErrNumber = 20534 then
Response.Write &quot;<BR>The stored procedure may have returned an error.&quot;
elseif ErrNumber = 20599 then
Response.Write &quot;<BR>There may be a security issue on the server.&quot;
end if
else
if isobject(session(&quot;oPageEngine&quot;)) then
set session(&quot;oPageEngine&quot;) = nothing
end if
Set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
end If

DB.Close
Set DB = nothing

'==================================================================
' Display the report using a smart viewer

%>
<BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript ONLOAD=&quot;Page_Initialize&quot;>
<p align=&quot;left&quot;>
<BUTTON NAME=cmdClose ACCESSKEY=C><U>C</U>lose</BUTTON>
</p>
<p align=&quot;left&quot;>


<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=95%
codebase=&quot;../../../../../../../../../../../../../../viewer/activeXViewer/activexviewer.cab#Version=8,0,0,224&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>

</p>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Page_Initialize
dim Temp
Temp = location.href
Temp = left(Temp,instr(Temp,&quot;?&quot;) - 1)
Temp = left(Temp,instrRev(Temp,&quot;/&quot;)) & &quot;rptserver.asp&quot;
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
CRViewer.ReportName = Temp
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = Temp
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub

Sub cmdClose_OnClick
window.close
End Sub

-->

</SCRIPT>

<%
' Set Server Script Timout back to default
Server.ScriptTimeout = 90
%>

</BODY>
</HTML>
 
hi cjlarue,

Thanks for the code, it took me a while to get some time to figure it out. I am specially interested in the part with the smart viewer where it says:

&quot; ...
Dim webSource
Set webSource = CreateObject
&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = Temp
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub&quot;

I manage to get the viewer showing in the browser but how do I load a report file? From my back end I have an *.rpt-file with data stored in a temp-file somewhere on disc. I tried the following to load the report:
webSource.URL = &quot;file:///c:/base/http/drilldown9.rpt&quot;
but it does not work.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top