• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

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

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"
 
       oRpt.Load(reportPath)
        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
        oRpt.SetDataSource(myDS)
        
       crDiskFileDestinationOptions.DiskFileName = savePath & fileName
 
     With crExportOptions
                        .DestinationOptions = crDiskFileDestinationOptions
                        .ExportDestinationType = ExportDestinationType.DiskFile
                        .ExportFormatType = ExportFormatType.Excel
                    End With
 
       oRpt.Export()
 
End Sub

Open in new window

0
jermineM
Asked:
jermineM
  • 2
  • 2
1 Solution
 
mlmccCommented:
WHat references or Crystal dlls have you added to the application?

mlmcc
0
 
jermineMAuthor Commented:
I have added  references to the following dlls:
CrystalDecisions.CrystalReports.Engine  
CrystalDecisions.Shared
CrystalDecisions.ReportSource
CrystalDecisions.Web

all these are also imported in the code behind
0
 
mlmccCommented:
What version of Crystal?

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

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now