Well, I'll admit that this is a pretty outlandish work-around, but you could use something like this to automatically export your crystal report:
1 Option Strict On
2 Imports CrystalDecisions.CrystalReports.Engine
3 Imports CrystalDecisions.Shared
4 Imports System.Net.Mail
5
6 Partial Class _Default
7 Inherits System.Web.UI.Page
8
9 Private stage7Detail As ReportDocument
10 Private reportDB As Database
11 Private reportTables As Tables
12 Private reportTable As Table
13 Private reportLogOnInfo As TableLogOnInfo
14 Private dateToday As Date = Date.Today
15 Private exportPath As String = "d:\IIS Web Roots\intranet\cf_sched1\crystal\" 'path to export the report to for auto-export
16 ' these declarations are for a more complicated export scenario. Leaving them in for future reference.
17 'Private myDiskFileDestinationOptions As DiskFileDestinationOptions
18 'Private myExportOptions As ExportOptions
19 'Private selectedNoFormat As Boolean = False
20
21 'our configuration method. Controls the session setup, loading of report, setting of
22 'connection information, etc.
23 Private Sub ConfigureCrystalReport()
24 If (Session("stage7Detail") Is Nothing) Then 'if the report isn't in the session (first load)
25 stage7Detail = New ReportDocument()
26 'load the report document
27 stage7Detail.Load("D:\IIS Web Roots\intranet\cf_sched1\crystal\AutomaticDailyStage7-Detail.rpt") 'web server
28 'stage7Detail.Load("C:/Documents and Settings/cfry/Desktop/Web_Reports/Stage7Detail-Q1-new/Stage7-Detail-Y2D.rpt") 'local
29
30 'authenticate to the database
31 reportDB = stage7Detail.Database 'get the database
32 reportTables = reportDB.Tables 'get the tables
33 'iterate through all of the tables, setting the correct login information for all of them
34 For Each reportTable In reportTables
35 reportLogOnInfo = reportTable.LogOnInfo 'get the LogOnInfo object
36 'reportLogOnInfo.ConnectionInfo.ServerName = "server" 'specify the server.
37 'reportLogOnInfo.ConnectionInfo.DatabaseName = "database" 'specify the database
38 'reportLogOnInfo.ConnectionInfo.UserID = "username" 'specify the user name
39 reportLogOnInfo.ConnectionInfo.Password = "password" 'specify the password
40 reportTable.ApplyLogOnInfo(reportLogOnInfo) 'save the changes
41 Next reportTable
42
43 Session("stage7Detail") = stage7Detail 'save the report to the session
44 Else
45 stage7Detail = CType(Session("stage7Detail"), ReportDocument) 'otherwise load the report
46 End If
47
48 Stage7DetailViewer.DisplayGroupTree = False 'hide the group tree
49 Stage7DetailViewer.ReportSource = stage7Detail 'set the viewer source to the report object
50 End Sub
51
52 'the on-load function merely launches the ConfigureCrystalReport() method
53 'that method will do any actual setup that's required.
54 Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
55 ConfigureCrystalReport()
56 ExportSetup()
57 ExportReport()
58 End Sub
59 'Setup the file export. Basically concerned with setting the correct values for:
60 'Private exportPath As String
61
62 Public Sub ExportSetup()
63 'Note: If you want to place the Exported folder within the Web directory of your Web server,
64 'prefix the folder name with the Request.PhysicalApplicationPath property. (from VS help)
65 If Not System.IO.Directory.Exists(exportPath) Then 'check if the directory exists
66 System.IO.Directory.CreateDirectory(exportPath) 'and create it if it doesn't
67 End If
68 End Sub
69 Public Sub ExportReport()
70 Dim myFileName As String = ""
71 myFileName = exportPath & "OrderManagementReport_" & Format(dateToday, "MMddyyyy") & ".pdf"
72 stage7Detail.ExportToDisk(ExportFormatType.PortableDocFormat, myFileName)
73 End Sub
This will get your report automatically exported to (in this case) a PDF in the specified directory. You can then put another
function call after line 57 to load the exported PDF up into the browser. It is also possible to export the PDF directly into
the browser (or a new browser window) which I have samples of as well, but haven't tested and so can't be sure that my
sample code works as is. Hopefully this example might lead you in a helpful direction,
Pont
PS: Mind you, the exported PDF will be the same size as your report. It's possible that your extra whitespace isn't caused by being loaded
into ASP, but rather is in the report itself... *shrug*