Sunday, October 4, 2015

Angular - Export to table (XML, PDF, JSON..)

we can export data from a table into various format including 
Json, Xml, Pdf .....

What do you need
  • Angularjs
  • Jquery.js
  • Files referenced below

Note: This example would not run in IE 

<!DOCTYPE html>

<html ng-app="myApp">
    <script src=""></script>
    <script src=""></script>
    <link rel="stylesheet" href="">
    <script src=""></script>
    <link rel="stylesheet" href="">
    <script src="../scripts/tableExport/tableExport.js"></script>
    <script src="../scripts/tableExport/JqueryBase64.js"></script>
    <script src="../scripts/tableExport/html2canvas.js"></script>
    <script src="../scripts/pdf/base64.js"></script>
    <script src="../scripts/pdf/Jspdf.js"></script>
    <script src="../scripts/pdf/sprintf.js"></script>
    <meta charset="utf-8" />
<div ng-controller="myCtrl">
    <div class="container">
        <div class="btn-group">
            <button class="btn btn-warning btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Export Table Data</button>
            <ul class="dropdown-menu " role="menu">
                <li><a href="#" onClick="$('#customers').tableExport({ type: 'json', escape: 'false' });"> <img src='../content/image/icons/json.png' width='24px'> JSON</a></li>
                <li><a href="#" onClick="$('#customers').tableExport({ type: 'json', escape: 'false', ignoreColumn: '[2,3]' });"> <img src='../content/image/icons/json.png' width='24px'> JSON (ignoreColumn)</a></li>
        <table id="customers" class="table table-striped">
                <th>First Name</th>
                <th>Last Name</th>

            <tr ng-repeat="item in items">
    <script type="text/javascript">
        var myAppModule = angular.module('myApp', []);
        myAppModule.controller('myCtrl', function ($scope) {
            $scope.exportData = function () {
                $('#customers').tableExport({ type: 'json', escape: 'false' });
            $scope.items = [
                    "FirstName": "Prathap",
                    "LastName": "Kudupu",
                    "Address": "Near Anjana Beach"
                    "FirstName": "Deepak",
                    "LastName": "Dsouza",
                    "Address": "Near Nariman Point"





  1. Hie Prathap
    My requirement is as such : We need to create a excel sheet from oracle database. it might contain 7-8 lakh record every time .So if i use angularjs - rest - java- jdbc -oracle parsing this much data and writing back to disk in excel format took too much time nearly(10 min by thread).
    is there is any possible way such that i don't need to parse complete data and i cxan optimize the performance. Any technology i can use
    Thanks in Advance

  2. You can use Phython Pandas. you can refer to my post

  3. Hi Prathap, Can we convert json to pdf directly?

  4. We need a third party library. We can use jsPDF. I have a written an article with simple example ( Please let me know if you have any issues

  5. I am not able to see the list when i click on the export table data button. please let me know..

  6. Can you please add your code to codepen or pnkr.

    1. Couple of export options doesn't work now..Please fix the sample

    2. I agree, These are all browser related bugs.

  7. i need to export data table to png in angular 2 , any recommendations ?

  8. The search engines have their conventions; websites that conform by giving the search engines what they want, will find themselves achieving better search engine rankings. The only thing standing between you and the top spots in the search rankings is your competition.Blog Comment

  9. Expected to form you a next to no word to thank you once more with respect to the decent recommendations you've contributed here. We are providing AngularJs training in velachery.
    For more details:AngularJs training in velachery

  10. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition. We are providing AngularJs training in velachery.
    For more details: AngularJs training in Velachery

  11. Hey! I know this is kinda off topic however , I’d figured I’d ask. Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa? My blog covers a lot of the same topics as yours and I believe we could greatly benefit from each other. If you are interested feel free to send me an e-mail. I look forward to hearing from you! Superb blog by the way! web design in new york

  12. I am impressed with this website , very I am a fan . branding agency san francisco

  13. I don’t usually comment but I gotta say thankyou for the post on this amazing one : D. branding sf

  14. I admit, I have not been on this web page in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues. NCML Webmail

  15. Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! dotcomsecrets

  16. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.