DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Rediscovering Angular: Modern Advantages and Technical Stack
  • Angular Input/Output Signals: The New Component Communication
  • Azure Deployment Using FileZilla
  • Angular RxJS Unleashed: Supercharge Your App With Reactive Operators

Trending

  • Agile and Quality Engineering: A Holistic Perspective
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 1
  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  1. DZone
  2. Coding
  3. Frameworks
  4. Learn MVC Using AngularJS and Crystal Report

Learn MVC Using AngularJS and Crystal Report

Looking for a better way to export data from your web application? Read on to learn how to leverage Angular for just such a task.

By 
Thiruppathi Rengasamy user avatar
Thiruppathi Rengasamy
·
Jun. 14, 17 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
13.3K Views

Join the DZone community and get the full member experience.

Join For Free

introduction

in this article, we will learn mvc, using angularjs and crystal report to help us handle server side data, using visual studio 2015.

mvc


what is crystal report?

crystal report is a business intelligence application. crystal report is powered by sap . it is used to design and generate reports from a wide range of data sources.

why we are using sap crystal report

  • provides a powerful reporting tool.
  • creates a real-time operational report.
  • works with the web, windows, and mobile devices.
  • makes flexible and customizable reports.

tools installation

we will download the crystal report ide from this link . after registration, “exe” will be downloaded automatically.

mvc


after completing the installation, restart visual studio.

create an mvc project

open visual studio 2015.


mvc


go to menu >new > click project > it will open the new project popup.


mvc


select asp.net project and give to the solution name, and then click the ok button. again one popup should appear that's called 'new asp.net web application.'


mvc


select mvc template and click ok to start the project. configure angularjs in this mvc project.

create a new folder called report and right click on the folder. add crystal report into the solution explorer.

mvc

in this report folder, add one dataset for server-side data binding. this will be used to design the customizable reports.

mvc


use this dataset to export your data for the designing and developing of the report.


mvc


easy-to-use] drag-and-drop controls are used in the design, as shown.


mvc


write a method to access the data and bind to the data from the server to crystal report in the controller. i have written the code given below in my home controller file.

c# code

public actionresult exportexcel()  
        {  
            list<bookmodel> booklist = new list<bookmodel>();  
            datasetreport dsreport = new datasetreport();  
            using (var con = new sqlconnection(configurationmanager.connectionstrings["dbsqlcon"].connectionstring))  
            {  
                var cmd = new sqlcommand("bookmaster_sp", con);  
                cmd.commandtype = commandtype.storedprocedure;  
                cmd.parameters.add(new sqlparameter("@mode", sqldbtype.varchar)).value = "get";  
                con.open();  

                (new sqldataadapter(cmd)).fill(dsreport.tables["booklist"]);  
            }  

            reportdocument rd = new reportdocument();  
            rd.load(path.combine(server.mappath("~/report"), "reportbooklist.rpt"));  
            rd.setdatasource(dsreport.tables["booklist"]);  

            response.buffer = false;  
            response.clearcontent();  
            response.clearheaders();  


            stream stream = rd.exporttostream(crystaldecisions.shared.exportformattype.excelworkbook);  
            stream.seek(0, seekorigin.begin);  
            return file(stream, "application/pdf", "reportbooklist.xlsx");  
        }   

proceed, as shown below.

rd.load(path.combine(server.mappath("~/report"), "reportbooklist.rpt")); 

in this article, i have demonstrated only excel and pdf reports.

stream stream = rd.exporttostream(crystaldecisions.shared.exportformattype.excelworkbook);  

you can export 16 different types of report formats using crystal reports.

mvc


we have finished the server part of the work. now we can start writing the code to the html and angular js controller file.

javascript code

$scope.excelreport=function()  
    {  
        $window.open("home/exportexcel", "_blank");  
    }  
    $scope.pdfreport = function () {  
        $window.open("home/exportpdf", "_blank");  
    }   

before writing this code, you must inject the $window keyword into the angular controller.

uiroute.controller('bookcontroller', function ($scope, bookservice, $window)  

call the above javascript function in your html buttons.

<button class="btn btn-success " ng-click="excelreport()">excel report</button>  
<button class="btn btn-danger " ng-click="pdfreport()">pdf report</button>  

that's it! that's all the client side part of the work. now, you can run the application.

output 1

mvc

output 2

mvc

finally, we succeeded in exporting our data using crystal report in mvc angularjs.

source code download

  • link

conclusion

in this article, we learned mvc, using angularjs and crystal report. if you have any queries, please tell me through the comments section .

happy coding!

Crystal (programming language) AngularJS

Published at DZone with permission of Thiruppathi Rengasamy, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Rediscovering Angular: Modern Advantages and Technical Stack
  • Angular Input/Output Signals: The New Component Communication
  • Azure Deployment Using FileZilla
  • Angular RxJS Unleashed: Supercharge Your App With Reactive Operators

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!