开发者

Create custom reports with crystal reports and entity framework 4

I want to allow users of a asp.net mvc 2 application, creating dynamicly reports. In a SQLServer Database is a table with all tasks for a user. Every task depends on a project and a user. What I want to do is to create some reports like "show me all tasks for the project X" or "Show me all my tasks" but also something like "Show me all my tasks with the status X for project Y". This lists should be exportable as PDF or CSV. And it would be also nice if it is possible to show this lists in a asp.net mvc view.

I read a lot about crystal reports and 开发者_JS百科it seems that what I want is possible with it. I found some tutorials which explain how to show all columns of a table in the report. But what I don't understand is how I can set some conditions "on the fly".

It would be very nice if something like the following pseudocode will do what I want:

// Load the tasks with Entity Framework by reference to some Condition
List<Task> tasks = GetTasks(userId); 

// Load the reportfile
var report = GetChristalReport("Name of the .rpt report file");

// Set the loaded entities to the report
report.setData(tasks);

// Export it to pdf or do what you want with the rendered report
var pdf = report.ExportToPdf();

I hope you can help me and say if this is possible with chrystal reports and how I can implement this.


Everything you mention is not only possible but relatively easy to do in CR. Most of what you need to do is to create a ReportDocument object, call repDoc.Load("myReport.rpt"); and then repDoc.ExportToDisk(fileFormat, fileName); and you're done. If you want to view it in the asp as an rpt file you need to create a ReportViewer object which is a little difficult but ASP natively supports viewing pdf in browser. I hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜