Results 1 to 13 of 13

Thread: Creating Crystal Reports Programatically

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Creating Crystal Reports Programatically

    Is it possible to create crystal reports in vb.net programatically at run time? There will be no typed dataset because I don't know what fields will need to be in it until the user clicks "Print".
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Creating Crystal Reports Programatically

    Quote Originally Posted by simonm View Post
    Is it possible to create crystal reports in vb.net programatically at run time? There will be no typed dataset because I don't know what fields will need to be in it until the user clicks "Print".
    Hi,

    You can find some example, here.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Creating Crystal Reports Programatically

    There is a tutorial on Crystal in this link about half way down.

    http://vb.net-informations.com/

  4. #4

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Creating Crystal Reports Programatically

    I see an example of how to create a crystal report dynamically from an SQL string. But the problem I have is that the data does not exist in the database, only in an ADO.NET data table. I suppose I could save the data to a temp table and then generate an SQL string based on that but I imagined I might be able to merely bind the report I created to my data table directly.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Creating Crystal Reports Programatically

    In the link I posted there is a section "Crystal Reports without database". Maybe there is something there that can help.

  6. #6
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Creating Crystal Reports Programatically

    Yes, it's very possible. First, save your ADO.NET DataSet/DataTable's schema using:

    myDataSet.WriteXml("C:\schema.xml", XmlWriteMode.WriteSchema)

    Then, make a new Crystal Report, tell it your datasource is ADO.NET, and pick your schema file. You'll see the report builder populated with all the tables and fields from your DataSet. If you ever need to make a change to your DataSet, just re-export the schema, and re-import it into the Crystal Report.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Creating Crystal Reports Programatically

    Quote Originally Posted by Jenner View Post
    Yes, it's very possible. First, save your ADO.NET DataSet/DataTable's schema using:

    myDataSet.WriteXml("C:\schema.xml", XmlWriteMode.WriteSchema)

    Then, make a new Crystal Report, tell it your datasource is ADO.NET, and pick your schema file. You'll see the report builder populated with all the tables and fields from your DataSet. If you ever need to make a change to your DataSet, just re-export the schema, and re-import it into the Crystal Report.
    I think you misunderstand my requirement. The schema will change everytime (potentially) the user prints the report.

    What I'm trying to do is generate a report from the contents of a list view who's columns can be configured by the user.

    Thinking about it now, I'm inclined not to bother with Crystal and look at printing directly, perhaps using the PrintDocument control...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  8. #8
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Creating Crystal Reports Programatically

    Yea, best to just build it on the fly with PrintDocument. Crystal is very precise with what it wants. It doesn't have the equivalent of a FlowLayoutTable to dynamically stack and arrange columns.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  9. #9

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Creating Crystal Reports Programatically

    Can you recommend a good reporting engine that does?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  10. #10
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Creating Crystal Reports Programatically

    I think you could write it to a CSV file and feed that to Crystal.

  11. #11
    Frenzied Member
    Join Date
    Feb 2008
    Location
    Texas
    Posts
    1,288

    Re: Creating Crystal Reports Programatically

    You might want to look into ActiveReports. I think you might be able to do what you want with that reporting utility.

    Justin
    You down with OOP? Yeah you know me!
    MCAD and MCMICKEYMOUSE (vb.net)

    ----

    If it even kinda helps... rate it : )

    Edit a Multi-page .tif file and save.

  12. #12
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Creating Crystal Reports Programatically

    SSRS report templates are XML and can be generated/manipulated at run time.

  13. #13

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Creating Crystal Reports Programatically

    Quote Originally Posted by MonkOFox
    You might want to look into ActiveReports. I think you might be able to do what you want with that reporting utility.

    Justin.
    Yeah, I've ended up doing that already! That's far more programatically interactive.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width