.NET WebService to create a crystal report and export to excel

Posted on 2009-02-11
Last Modified: 2013-11-06
I have seen codes calling crystal reports via a webform, and displayed through the reportviewer.

I have been provided a code that uses the reportdocument to generate a crystal report by calling a webservice.  This WS is supposed to call the crystal report and export it to xls and save to disk.

Im still the process the setting up the WS but Ive hit a roadblock on this ReportDocument initialization.  

In Debug mode, when reach the code  oRpt.Load(reportPath)" , ALL of the properties of the reportdocument object says "<error : an exception of type {System.ArgumentException} occurred".  The reportPath is correct. Query fetched records and was able to populate the dataset. But even after setting the datasource for the Reportdocument object, every property is still have this <error : an exception of type {System.ArgumentException} occurred" value.

Any help is very much appreciated.

Additional info :
The crystal report file data source is an xmlschema.
.NET 1.1

<SoapDocumentMethodAttribute(OneWay:=True), _

    WebMethod()> _

    Public Sub GenerateAndExportFileReport(ByVal reportPath As String,   _

ByVal savePath As String, _

ByVal fileName As String)

        Dim oRpt As New ReportDocument

        Dim crExportOptions As ExportOptions

        Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

        Dim strConnectionString as String = Session("strConnString")

        Dim strSQL  as String  = "Select * from Employees"


        myconnection = New OleDbConnection(strConnectionString)

        mycommand.Connection = myconnection

        mycommand.CommandText = strSQL

        mycommand.CommandType = CommandType.Text

        myDA.SelectCommand = mycommand

        myDA.Fill(myDS, "Employees")

        If (myDS.Tables.Item(1).Rows.Count = 0) Then

            Return Nothing

        End If



       crDiskFileDestinationOptions.DiskFileName = savePath & fileName

     With crExportOptions

                        .DestinationOptions = crDiskFileDestinationOptions

                        .ExportDestinationType = ExportDestinationType.DiskFile

                        .ExportFormatType = ExportFormatType.Excel

                    End With


End Sub

Open in new window

Question by:jermineM
    LVL 100

    Expert Comment

    WHat references or Crystal dlls have you added to the application?


    Author Comment

    I have added  references to the following dlls:

    all these are also imported in the code behind
    LVL 100

    Accepted Solution

    What version of Crystal?

    I don't use .Net so I am not sure but the references look correct.


    Author Closing Comment

    used other approach, but im giving you the point by trying to help out :). Really appreciate it!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now