hjg
2023-10-16 a92547a2e458ca159b4877fb901f27227b941acf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
/*!
 * HTML5 export buttons for Buttons and DataTables.
 * 2015 SpryMedia Ltd - datatables.net/license
 *
 * FileSaver.js (2015-05-07.2) - MIT license
 * Copyright © 2015 Eli Grey - http://eligrey.com
 */
 
(function( factory ){
    if ( typeof define === 'function' && define.amd ) {
        // AMD
        define( ['jquery', 'datatables.net', 'datatables.net-buttons'], function ( $ ) {
            return factory( $, window, document );
        } );
    }
    else if ( typeof exports === 'object' ) {
        // CommonJS
        module.exports = function (root, $) {
            if ( ! root ) {
                root = window;
            }
 
            if ( ! $ || ! $.fn.dataTable ) {
                $ = require('datatables.net')(root, $).$;
            }
 
            if ( ! $.fn.dataTable.Buttons ) {
                require('datatables.net-buttons')(root, $);
            }
 
            return factory( $, root, root.document );
        };
    }
    else {
        // Browser
        factory( jQuery, window, document );
    }
}(function( $, window, document, undefined ) {
'use strict';
var DataTable = $.fn.dataTable;
 
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * FileSaver.js dependency
 */
 
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
 
var _saveAs = (function(view) {
    // IE <10 is explicitly unsupported
    if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
        return;
    }
    var
          doc = view.document
          // only get URL when necessary in case Blob.js hasn't overridden it yet
        , get_URL = function() {
            return view.URL || view.webkitURL || view;
        }
        , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
        , can_use_save_link = "download" in save_link
        , click = function(node) {
            var event = doc.createEvent("MouseEvents");
            event.initMouseEvent(
                "click", true, false, view, 0, 0, 0, 0, 0
                , false, false, false, false, 0, null
            );
            node.dispatchEvent(event);
        }
        , webkit_req_fs = view.webkitRequestFileSystem
        , req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
        , throw_outside = function(ex) {
            (view.setImmediate || view.setTimeout)(function() {
                throw ex;
            }, 0);
        }
        , force_saveable_type = "application/octet-stream"
        , fs_min_size = 0
        // See https://code.google.com/p/chromium/issues/detail?id=375297#c7 and
        // https://github.com/eligrey/FileSaver.js/commit/485930a#commitcomment-8768047
        // for the reasoning behind the timeout and revocation flow
        , arbitrary_revoke_timeout = 500 // in ms
        , revoke = function(file) {
            var revoker = function() {
                if (typeof file === "string") { // file is an object URL
                    get_URL().revokeObjectURL(file);
                } else { // file is a File
                    file.remove();
                }
            };
            if (view.chrome) {
                revoker();
            } else {
                setTimeout(revoker, arbitrary_revoke_timeout);
            }
        }
        , dispatch = function(filesaver, event_types, event) {
            event_types = [].concat(event_types);
            var i = event_types.length;
            while (i--) {
                var listener = filesaver["on" + event_types[i]];
                if (typeof listener === "function") {
                    try {
                        listener.call(filesaver, event || filesaver);
                    } catch (ex) {
                        throw_outside(ex);
                    }
                }
            }
        }
        , auto_bom = function(blob) {
            // prepend BOM for UTF-8 XML and text/* types (including HTML)
            if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
                return new Blob(["\ufeff", blob], {type: blob.type});
            }
            return blob;
        }
        , FileSaver = function(blob, name) {
            blob = auto_bom(blob);
            // First try a.download, then web filesystem, then object URLs
            var
                  filesaver = this
                , type = blob.type
                , blob_changed = false
                , object_url
                , target_view
                , dispatch_all = function() {
                    dispatch(filesaver, "writestart progress write writeend".split(" "));
                }
                // on any filesys errors revert to saving with object URLs
                , fs_error = function() {
                    // don't create more object URLs than needed
                    if (blob_changed || !object_url) {
                        object_url = get_URL().createObjectURL(blob);
                    }
                    if (target_view) {
                        target_view.location.href = object_url;
                    } else {
                        var new_tab = view.open(object_url, "_blank");
                        if (new_tab === undefined && typeof safari !== "undefined") {
                            //Apple do not allow window.open, see http://bit.ly/1kZffRI
                            view.location.href = object_url;
                        }
                    }
                    filesaver.readyState = filesaver.DONE;
                    dispatch_all();
                    revoke(object_url);
                }
                , abortable = function(func) {
                    return function() {
                        if (filesaver.readyState !== filesaver.DONE) {
                            return func.apply(this, arguments);
                        }
                    };
                }
                , create_if_not_found = {create: true, exclusive: false}
                , slice
            ;
            filesaver.readyState = filesaver.INIT;
            if (!name) {
                name = "download";
            }
            if (can_use_save_link) {
                object_url = get_URL().createObjectURL(blob);
                save_link.href = object_url;
                save_link.download = name;
                click(save_link);
                filesaver.readyState = filesaver.DONE;
                dispatch_all();
                revoke(object_url);
                return;
            }
            // Object and web filesystem URLs have a problem saving in Google Chrome when
            // viewed in a tab, so I force save with application/octet-stream
            // http://code.google.com/p/chromium/issues/detail?id=91158
            // Update: Google errantly closed 91158, I submitted it again:
            // https://code.google.com/p/chromium/issues/detail?id=389642
            if (view.chrome && type && type !== force_saveable_type) {
                slice = blob.slice || blob.webkitSlice;
                blob = slice.call(blob, 0, blob.size, force_saveable_type);
                blob_changed = true;
            }
            // Since I can't be sure that the guessed media type will trigger a download
            // in WebKit, I append .download to the filename.
            // https://bugs.webkit.org/show_bug.cgi?id=65440
            if (webkit_req_fs && name !== "download") {
                name += ".download";
            }
            if (type === force_saveable_type || webkit_req_fs) {
                target_view = view;
            }
            if (!req_fs) {
                fs_error();
                return;
            }
            fs_min_size += blob.size;
            req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
                fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
                    var save = function() {
                        dir.getFile(name, create_if_not_found, abortable(function(file) {
                            file.createWriter(abortable(function(writer) {
                                writer.onwriteend = function(event) {
                                    target_view.location.href = file.toURL();
                                    filesaver.readyState = filesaver.DONE;
                                    dispatch(filesaver, "writeend", event);
                                    revoke(file);
                                };
                                writer.onerror = function() {
                                    var error = writer.error;
                                    if (error.code !== error.ABORT_ERR) {
                                        fs_error();
                                    }
                                };
                                "writestart progress write abort".split(" ").forEach(function(event) {
                                    writer["on" + event] = filesaver["on" + event];
                                });
                                writer.write(blob);
                                filesaver.abort = function() {
                                    writer.abort();
                                    filesaver.readyState = filesaver.DONE;
                                };
                                filesaver.readyState = filesaver.WRITING;
                            }), fs_error);
                        }), fs_error);
                    };
                    dir.getFile(name, {create: false}, abortable(function(file) {
                        // delete file if it already exists
                        file.remove();
                        save();
                    }), abortable(function(ex) {
                        if (ex.code === ex.NOT_FOUND_ERR) {
                            save();
                        } else {
                            fs_error();
                        }
                    }));
                }), fs_error);
            }), fs_error);
        }
        , FS_proto = FileSaver.prototype
        , saveAs = function(blob, name) {
            return new FileSaver(blob, name);
        }
    ;
    // IE 10+ (native saveAs)
    if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
        return function(blob, name) {
            return navigator.msSaveOrOpenBlob(auto_bom(blob), name);
        };
    }
 
    FS_proto.abort = function() {
        var filesaver = this;
        filesaver.readyState = filesaver.DONE;
        dispatch(filesaver, "abort");
    };
    FS_proto.readyState = FS_proto.INIT = 0;
    FS_proto.WRITING = 1;
    FS_proto.DONE = 2;
 
    FS_proto.error =
    FS_proto.onwritestart =
    FS_proto.onprogress =
    FS_proto.onwrite =
    FS_proto.onabort =
    FS_proto.onerror =
    FS_proto.onwriteend =
        null;
 
    return saveAs;
}(window));
 
 
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Local (private) functions
 */
 
/**
 * Get the file name for an exported file.
 *
 * @param {object}  config       Button configuration
 * @param {boolean} incExtension Include the file name extension
 */
var _filename = function ( config, incExtension )
{
    // Backwards compatibility
    var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined ?
        config.title :
        config.filename;
 
    if ( filename.indexOf( '*' ) !== -1 ) {
        filename = filename.replace( '*', $('title').text() );
    }
 
    // Strip characters which the OS will object to
    filename = filename.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
 
    return incExtension === undefined || incExtension === true ?
        filename+config.extension :
        filename;
};
 
/**
 * Get the title for an exported file.
 *
 * @param {object}  config  Button configuration
 */
var _title = function ( config )
{
    var title = config.title;
 
    return title.indexOf( '*' ) !== -1 ?
        title.replace( '*', $('title').text() ) :
        title;
};
 
/**
 * Get the newline character(s)
 *
 * @param {object}  config Button configuration
 * @return {string}        Newline character
 */
var _newLine = function ( config )
{
    return config.newline ?
        config.newline :
        navigator.userAgent.match(/Windows/) ?
            '\r\n' :
            '\n';
};
 
/**
 * Combine the data from the `buttons.exportData` method into a string that
 * will be used in the export file.
 *
 * @param  {DataTable.Api} dt     DataTables API instance
 * @param  {object}        config Button configuration
 * @return {object}               The data to export
 */
var _exportData = function ( dt, config )
{
    var newLine = _newLine( config );
    var data = dt.buttons.exportData( config.exportOptions );
    var boundary = config.fieldBoundary;
    var separator = config.fieldSeparator;
    var reBoundary = new RegExp( boundary, 'g' );
    var escapeChar = config.escapeChar !== undefined ?
        config.escapeChar :
        '\\';
    var join = function ( a ) {
        var s = '';
 
        // If there is a field boundary, then we might need to escape it in
        // the source data
        for ( var i=0, ien=a.length ; i<ien ; i++ ) {
            if ( i > 0 ) {
                s += separator;
            }
 
            s += boundary ?
                boundary + ('' + a[i]).replace( reBoundary, escapeChar+boundary ) + boundary :
                a[i];
        }
 
        return s;
    };
 
    var header = config.header ? join( data.header )+newLine : '';
    var footer = config.footer ? newLine+join( data.footer ) : '';
    var body = [];
 
    for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
        body.push( join( data.body[i] ) );
    }
 
    return {
        str: header + body.join( newLine ) + footer,
        rows: body.length
    };
};
 
/**
 * Safari's data: support for creating and downloading files is really poor, so
 * various options need to be disabled in it. See
 * https://bugs.webkit.org/show_bug.cgi?id=102914
 * 
 * @return {Boolean} `true` if Safari
 */
var _isSafari = function ()
{
    return navigator.userAgent.indexOf('Safari') !== -1 &&
        navigator.userAgent.indexOf('Chrome') === -1 &&
        navigator.userAgent.indexOf('Opera') === -1;
};
 
 
// Excel - Pre-defined strings to build a minimal XLSX file
var excelStrings = {
    "_rels/.rels": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>\
</Relationships>',
 
    "xl/_rels/workbook.xml.rels": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>\
</Relationships>',
 
    "[Content_Types].xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\
    <Default Extension="xml" ContentType="application/xml"/>\
    <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>\
    <Default Extension="jpeg" ContentType="image/jpeg"/>\
    <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>\
    <Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>\
</Types>',
 
    "xl/workbook.xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">\
    <fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>\
    <workbookPr showInkAnnotation="0" autoCompressPictures="0"/>\
    <bookViews>\
        <workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>\
    </bookViews>\
    <sheets>\
        <sheet name="Sheet1" sheetId="1" r:id="rId1"/>\
    </sheets>\
</workbook>',
 
    "xl/worksheets/sheet1.xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">\
    <sheetData>\
        __DATA__\
    </sheetData>\
</worksheet>'
};
 
 
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Buttons
 */
 
//
// Copy to clipboard
//
DataTable.ext.buttons.copyHtml5 = {
    className: 'buttons-copy buttons-html5',
 
    text: function ( dt ) {
        return dt.i18n( 'buttons.copy', 'Copy' );
    },
 
    action: function ( e, dt, button, config ) {
        var exportData = _exportData( dt, config );
        var output = exportData.str;
        var hiddenDiv = $('<div/>')
            .css( {
                height: 1,
                width: 1,
                overflow: 'hidden',
                position: 'fixed',
                top: 0,
                left: 0
            } );
        var textarea = $('<textarea readonly/>')
            .val( output )
            .appendTo( hiddenDiv );
 
        // For browsers that support the copy execCommand, try to use it
        if ( document.queryCommandSupported('copy') ) {
            hiddenDiv.appendTo( 'body' );
            textarea[0].focus();
            textarea[0].select();
 
            try {
                document.execCommand( 'copy' );
                hiddenDiv.remove();
 
                dt.buttons.info(
                    dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
                    dt.i18n( 'buttons.copySuccess', {
                            1: "Copied one row to clipboard",
                            _: "Copied %d rows to clipboard"
                        }, exportData.rows ),
                    2000
                );
 
                return;
            }
            catch (t) {}
        }
 
        // Otherwise we show the text box and instruct the user to use it
        var message = $('<span>'+dt.i18n( 'buttons.copyKeys',
                'Press <i>ctrl</i> or <i>\u2318</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>'+
                'To cancel, click this message or press escape.' )+'</span>'
            )
            .append( hiddenDiv );
 
        dt.buttons.info( dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ), message, 0 );
 
        // Select the text so when the user activates their system clipboard
        // it will copy that text
        textarea[0].focus();
        textarea[0].select();
 
        // Event to hide the message when the user is done
        var container = $(message).closest('.dt-button-info');
        var close = function () {
            container.off( 'click.buttons-copy' );
            $(document).off( '.buttons-copy' );
            dt.buttons.info( false );
        };
 
        container.on( 'click.buttons-copy', close );
        $(document)
            .on( 'keydown.buttons-copy', function (e) {
                if ( e.keyCode === 27 ) { // esc
                    close();
                }
            } )
            .on( 'copy.buttons-copy cut.buttons-copy', function () {
                close();
            } );
    },
 
    exportOptions: {},
 
    fieldSeparator: '\t',
 
    fieldBoundary: '',
 
    header: true,
 
    footer: false
};
 
//
// CSV export
//
DataTable.ext.buttons.csvHtml5 = {
    className: 'buttons-csv buttons-html5',
 
    available: function () {
        return window.FileReader !== undefined && window.Blob;
    },
 
    text: function ( dt ) {
        return dt.i18n( 'buttons.csv', 'CSV' );
    },
 
    action: function ( e, dt, button, config ) {
        // Set the text
        var newLine = _newLine( config );
        var output = _exportData( dt, config ).str;
        var charset = config.charset;
 
        if ( charset !== false ) {
            if ( ! charset ) {
                charset = document.characterSet || document.charset;
            }
 
            if ( charset ) {
                charset = ';charset='+charset;
            }
        }
        else {
            charset = '';
        }
 
        _saveAs(
            new Blob( [output], {type: 'text/csv'+charset} ),
            _filename( config )
        );
    },
 
    filename: '*',
 
    extension: '.csv',
 
    exportOptions: {},
 
    fieldSeparator: ',',
 
    fieldBoundary: '"',
 
    escapeChar: '"',
 
    charset: null,
 
    header: true,
 
    footer: false
};
 
//
// Excel (xlsx) export
//
DataTable.ext.buttons.excelHtml5 = {
    className: 'buttons-excel buttons-html5',
 
    available: function () {
        return window.FileReader !== undefined && window.JSZip !== undefined && ! _isSafari();
    },
 
    text: function ( dt ) {
        return dt.i18n( 'buttons.excel', 'Excel' );
    },
 
    action: function ( e, dt, button, config ) {
        // Set the text
        var xml = '';
        var data = dt.buttons.exportData( config.exportOptions );
        var addRow = function ( row ) {
            var cells = [];
 
            for ( var i=0, ien=row.length ; i<ien ; i++ ) {
                if ( row[i] === null || row[i] === undefined ) {
                    row[i] = '';
                }
 
                // Don't match numbers with leading zeros or a negative anywhere
                // but the start
                cells.push( typeof row[i] === 'number' || (row[i].match && row[i].match(/^-?[0-9\.]+$/) && row[i].charAt(0) !== '0') ?
                    '<c t="n"><v>'+row[i]+'</v></c>' :
                    '<c t="inlineStr"><is><t>'+(
                        ! row[i].replace ?
                            row[i] :
                            row[i]
                                .replace(/&(?!amp;)/g, '&amp;')
                                .replace(/[\x00-\x1F\x7F-\x9F]/g, ''))+ // remove control characters
                    '</t></is></c>'                                    // they are not valid in XML
                );
            }
 
            return '<row>'+cells.join('')+'</row>';
        };
 
        if ( config.header ) {
            xml += addRow( data.header );
        }
 
        for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
            xml += addRow( data.body[i] );
        }
 
        if ( config.footer ) {
            xml += addRow( data.footer );
        }
 
        var zip           = new window.JSZip();
        var _rels         = zip.folder("_rels");
        var xl            = zip.folder("xl");
        var xl_rels       = zip.folder("xl/_rels");
        var xl_worksheets = zip.folder("xl/worksheets");
 
        zip.file(           '[Content_Types].xml', excelStrings['[Content_Types].xml'] );
        _rels.file(         '.rels',               excelStrings['_rels/.rels'] );
        xl.file(            'workbook.xml',        excelStrings['xl/workbook.xml'] );
        xl_rels.file(       'workbook.xml.rels',   excelStrings['xl/_rels/workbook.xml.rels'] );
        xl_worksheets.file( 'sheet1.xml',          excelStrings['xl/worksheets/sheet1.xml'].replace( '__DATA__', xml ) );
 
        _saveAs(
            zip.generate( {type:"blob"} ),
            _filename( config )
        );
    },
 
    filename: '*',
 
    extension: '.xlsx',
 
    exportOptions: {},
 
    header: true,
 
    footer: false
};
 
//
// PDF export - using pdfMake - http://pdfmake.org
//
DataTable.ext.buttons.pdfHtml5 = {
    className: 'buttons-pdf buttons-html5',
 
    available: function () {
        return window.FileReader !== undefined && window.pdfMake;
    },
 
    text: function ( dt ) {
        return dt.i18n( 'buttons.pdf', 'PDF' );
    },
 
    action: function ( e, dt, button, config ) {
        var newLine = _newLine( config );
        var data = dt.buttons.exportData( config.exportOptions );
        var rows = [];
 
        if ( config.header ) {
            rows.push( $.map( data.header, function ( d ) {
                return {
                    text: typeof d === 'string' ? d : d+'',
                    style: 'tableHeader'
                };
            } ) );
        }
 
        for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
            rows.push( $.map( data.body[i], function ( d ) {
                return {
                    text: typeof d === 'string' ? d : d+'',
                    style: i % 2 ? 'tableBodyEven' : 'tableBodyOdd'
                };
            } ) );
        }
 
        if ( config.footer ) {
            rows.push( $.map( data.footer, function ( d ) {
                return {
                    text: typeof d === 'string' ? d : d+'',
                    style: 'tableFooter'
                };
            } ) );
        }
 
        var doc = {
            pageSize: config.pageSize,
            pageOrientation: config.orientation,
            content: [
                {
                    table: {
                        headerRows: 1,
                        body: rows
                    },
                    layout: 'noBorders'
                }
            ],
            styles: {
                tableHeader: {
                    bold: true,
                    fontSize: 11,
                    color: 'white',
                    fillColor: '#2d4154',
                    alignment: 'center'
                },
                tableBodyEven: {},
                tableBodyOdd: {
                    fillColor: '#f3f3f3'
                },
                tableFooter: {
                    bold: true,
                    fontSize: 11,
                    color: 'white',
                    fillColor: '#2d4154'
                },
                title: {
                    alignment: 'center',
                    fontSize: 15
                },
                message: {}
            },
            defaultStyle: {
                fontSize: 10
            }
        };
 
        if ( config.message ) {
            doc.content.unshift( {
                text: config.message,
                style: 'message',
                margin: [ 0, 0, 0, 12 ]
            } );
        }
 
        if ( config.title ) {
            doc.content.unshift( {
                text: _title( config, false ),
                style: 'title',
                margin: [ 0, 0, 0, 12 ]
            } );
        }
 
        if ( config.customize ) {
            config.customize( doc );
        }
 
        var pdf = window.pdfMake.createPdf( doc );
 
        if ( config.download === 'open' && ! _isSafari() ) {
            pdf.open();
        }
        else {
            pdf.getBuffer( function (buffer) {
                var blob = new Blob( [buffer], {type:'application/pdf'} );
 
                _saveAs( blob, _filename( config ) );
            } );
        }
    },
 
    title: '*',
 
    filename: '*',
 
    extension: '.pdf',
 
    exportOptions: {},
 
    orientation: 'portrait',
 
    pageSize: 'A4',
 
    header: true,
 
    footer: false,
 
    message: null,
 
    customize: null,
 
    download: 'download'
};
 
 
return DataTable.Buttons;
}));