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".
Printable View
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.
There is a tutorial on Crystal in this link about half way down.
http://vb.net-informations.com/
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.
In the link I posted there is a section "Crystal Reports without database". Maybe there is something there that can help.
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...
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.
Can you recommend a good reporting engine that does? ;)
I think you could write it to a CSV file and feed that to Crystal.
You might want to look into ActiveReports. I think you might be able to do what you want with that reporting utility.
Justin
SSRS report templates are XML and can be generated/manipulated at run time.
Yeah, I've ended up doing that already! That's far more programatically interactive.Quote:
Originally Posted by MonkOFox