Crystal Reports, Dynamic Graphs, Charts and PDF

Last post 01-14-2008 3:29 PM by eseidel. 3 replies.

Sort Posts:

  • Crystal Reports, Dynamic Graphs, Charts and PDF

    01-14-2008, 1:19 PM
    • Member
      45 point Member
    • andyaiyer
    • Member since 02-10-2006, 5:07 PM
    • Posts 12

    Gentlemen,

    I hope one of you will graciously spend a minute to answer this. I have been going in circles around different products for what it seems like ever.

    Problem: 

    I have a ASP.Net Internet based web application. My Application will need to be able to generate Dynamic Database driven reports. These reports are complex reports and will contain Charts & Graphics which will need to be drawn from Database values. Now, I cannot render them to the end-user's browser in anything except PDF document/format. I also need the ability to generate this Chart/Graph on a pre-printed Page (Read as= End user will use graph sheets instead plain white paper if he desires).

    I have checked RDLC, Amyuni, HTML to PDF and scores of other tools which are great in converting HTML, but they do not work well with graphs/charts OR they do not provide us the ability to create a Graph or Chart in a PDF document.

    Question: Can Crystal Report handle this requirement? If you have worked on a previous tool or a similar requirement and can point me in the right direction, I would very much appreciate it.

    Thanks

    -Andy

    Please Mark Reply as Accepted and complete. It helps in tracking open posts.
  • Re: Crystal Reports, Dynamic Graphs, Charts and PDF

    01-14-2008, 2:04 PM
    • Participant
      1,607 point Participant
    • eseidel
    • Member since 10-17-2006, 10:03 AM
    • Indianapolis, Indiana
    • Posts 504

    Crystal report can do this.  I am doing EXACTLY what you are needing and it works great.   All of my graphs are loaded dynamically from very complex queries in order to have the graphs display like the user wants.  You can then export these to PDF using the crystal report viewer control(which also allows the report to be displayed in the web browser).  The pdf's are actually better looking then the CRV version because some dynamic stuff such as lines and images that are drawn based on certain conditions will not show in the browser, but when you export them to PDF or just print them then everything looks like it should. 

     

    Eric

     

  • Re: Crystal Reports, Dynamic Graphs, Charts and PDF

    01-14-2008, 2:12 PM
    • Member
      45 point Member
    • andyaiyer
    • Member since 02-10-2006, 5:07 PM
    • Posts 12

    Eric,

     Thank you for replying back to me. I now do see some light far down. Would you be so kind enough to just point me to some 'push' method samples for generating Charts/Graphics using Crystal Reports please? Any tutorials orreference sites would also work great! Sorry, if this is too a basic request; but since this is my first exposure to crystal reports I am even having a hard time googling for resources. (I am sure this is more than a 'Monday' thing). By the way what is your opinion about using SQL Server Reporting Services for this requirement?

    Many Thanks!

    -Andy

     

    Please Mark Reply as Accepted and complete. It helps in tracking open posts.
  • Re: Crystal Reports, Dynamic Graphs, Charts and PDF

    01-14-2008, 3:29 PM
    Answer
    • Participant
      1,607 point Participant
    • eseidel
    • Member since 10-17-2006, 10:03 AM
    • Indianapolis, Indiana
    • Posts 504

     

     

    Ok, so I almost finished writing a huge post for you but right before I finished I closed the window by accident instead of minimizing it.  So I'm sorry but I'm not spending another half hour to write that today(as you said its monday).  Here is my abbreviated post:  Here is the configure crystal reports routine that I call from page_load.  Check out my post http://forums.asp.net/t/1127676.aspx to understand this a little better if you don't already.

    Private Sub ConfigureCrystalReports()

    If (Session("supplierRpt") Is Nothing) Then

    supplierRpt = New ReportDocument()

    supplierRpt.Load(Server.MapPath("SupplierReport_Final.rpt"))

    ' supplierRpt.Load(Server.MapPath("SupplierReport_Final_bak.rpt"))

    LoadDataSources()

    supplierRpt.SetDataSource(dsOcc)

    supplierRpt.Subreports("FailOcc").SetDataSource(dsOcc.Tables("FailOcc"))

    supplierRpt.Subreports("IndexByFailure").SetDataSource(dsOcc.Tables("IndexFail"))

    supplierRpt.Subreports("FailByRank").SetDataSource(dsOcc.Tables("IndexFail"))

    supplierRpt.Subreports("FailureType").SetDataSource(dsOcc.Tables("FailureType"))

    supplierRpt.Subreports("ResponseTime").SetDataSource(dsOcc.Tables("ResponseSummary"))

    supplierRpt.Subreports("ResponseSummary").SetDataSource(dsOcc.Tables("ResponseSum"))

    supplierRpt.Subreports("JPN_ResponseSummary").SetDataSource(dsOcc.Tables("ResponseSum"))

    SetParameters()  ‘ Sets the parameters in a ‘System.Collections.Specialized.StringDictionary object

     ‘Pushes parameters down through report to subreports

    ‘note: keep parameter names the same for subreports

    ApplyParams()

    Session("supplierRpt") = supplierRpt

    Else

    supplierRpt = CType(Session("supplierRpt"), ReportDocument)

    End If

    Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

    'setup db connection for report

    myConnectionInfo.DatabaseName = ""

    myConnectionInfo.UserID = ...

    myConnectionInfo.Password = ...

    myConnectionInfo.ServerName = ...

    SetDBLogonForReport(myConnectionInfo)

    crv.ReportSource = supplierRpt

    End Sub

    Then inside of LoadDataSources() I first load the main report data(parameters used in main report and subreports) then I call each individual subreport load to load each query into a table in my dataset dsOCC. Here is the code for one of the simpler queries(method is exact same for more complex ones):  This table, Failure Type loads a pie chart that shows percentages of different failure types.  But very similar idea for other types of graphs.  So the graph itself would have as data On Change Of: FailureType.basicfailurecode, Show Values: Percentage of Sum of FailureType.Cnt

    Private Sub LoadFailureType()

            Dim conn As String = connstring

            Dim sqlFailureType As String = _

                "SELECT  supplier,supplierloc,COUNT (occdate) cnt, basicfailurecode " & _

                "FROM VW_QAOCC_REPORTCARD " & _

                "WHERE supplier IN (" & rptSupplier & ") and supplierloc in (" & rptSupplierLoc & ") " & _

                "AND occdate BETWEEN TO_DATE('" & rptBegDate.ToString("d") & "','MM/dd/yyyy') and TO_DATE('" & rptEndDate.ToString("d") & "','MM/dd/yyyy') " & _

                "and (upper(trim(foundby)) not like  '%MARKET%' or foundby is null) " & _

                "and (upper(trim(foundby)) not like '%TRIAL%' or foundby is null) " & _

                "and (upper(trim(rank)) not like '%MARKET%' or rank is null) " & _

                "and (upper(trim(rank)) not like '%TRIAL%' or rank is null) " & _

                "and  nvl(void,'N') = 'N' " & _

                "GROUP BY supplier,supplierloc,basicfailurecode"

     

            Dim rptFailureTypeAdapter As OleDb.OleDbDataAdapter = _

                New OleDbDataAdapter(sqlFailureType, conn)

     

            ‘ First time the query is run it should create XML schema to use as Ado datasource in Crystal Reports so that data doesn't have to be there at CR design time, just column names

    ‘Create XML schema to use in setting dataset in report designer,

    Comment out after xml is created

            'dsFailureType.WriteXmlSchema("c:\temp\failuretype.xml")

     

    ‘once xml is created then just fill the datatable as normal

            rptFailureTypeAdapter.Fill(dsOcc, "FailureType")

        End Sub

    Then in the graphs just make sure you set the subreport db-links to point to the correct parameters.

    Its not a super easy process but once you get the hang of it its not too hard.  If you have questions I will try to answer to my best ability.  Good luck.

    Eric

     

     

     

Page 1 of 1 (4 items)