10
if ( typeof define === 'function' && define.amd ) {
12
define( ['jquery', 'datatables.net', 'datatables.net-buttons'], function ( $ ) {
13
return factory( $, window, document );
16
else if ( typeof exports === 'object' ) {
18
module.exports = function (root, $) {
23
if ( ! $ || ! $.fn.dataTable ) {
24
$ = require('datatables.net')(root, $).$;
27
if ( ! $.fn.dataTable.Buttons ) {
28
require('datatables.net-buttons')(root, $);
31
return factory( $, root, root.document );
36
factory( jQuery, window, document );
38
}(function( $, window, document, undefined ) {
40
var DataTable = $.fn.dataTable;
54
var ZeroClipboard_TableTools = {
55
version: "1.0.4-TableTools2",
62
if (typeof(thingy) == 'string') {
63
thingy = document.getElementById(thingy);
65
if (!thingy.addClass) {
67
thingy.hide = function() { this.style.display = 'none'; };
68
thingy.show = function() { this.style.display = ''; };
69
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
70
thingy.removeClass = function(name) {
71
this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
73
thingy.hasClass = function(name) {
74
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
80
setMoviePath: function(path) {
82
this.moviePath = path;
85
dispatch: function(id, eventName, args) {
87
var client = this.clients[id];
89
client.receiveEvent(eventName, args);
93
log: function ( str ) {
94
console.log( 'Flash: '+str );
97
register: function(id, client) {
99
this.clients[id] = client;
102
getDOMObjectPosition: function(obj) {
107
width: obj.width ? obj.width : obj.offsetWidth,
108
height: obj.height ? obj.height : obj.offsetHeight
111
if ( obj.style.width !== "" ) {
112
info.width = obj.style.width.replace("px","");
115
if ( obj.style.height !== "" ) {
116
info.height = obj.style.height.replace("px","");
120
info.left += obj.offsetLeft;
121
info.top += obj.offsetTop;
122
obj = obj.offsetParent;
128
Client: function(elem) {
133
this.id = ZeroClipboard_TableTools.nextId++;
134
this.movieId = 'ZeroClipboard_TableToolsMovie_' + this.id;
137
ZeroClipboard_TableTools.register(this.id, this);
146
ZeroClipboard_TableTools.Client.prototype = {
154
handCursorEnabled: true,
160
glue: function(elem, title) {
163
this.domElement = ZeroClipboard_TableTools.$(elem);
167
if (this.domElement.style.zIndex) {
168
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
172
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
175
this.div = document.createElement('div');
176
var style = this.div.style;
177
style.position = 'absolute';
180
style.width = (box.width) + 'px';
181
style.height = box.height + 'px';
182
style.zIndex = zIndex;
184
if ( typeof title != "undefined" && title !== "" ) {
185
this.div.title = title;
187
if ( box.width !== 0 && box.height !== 0 ) {
192
if ( this.domElement ) {
193
this.domElement.appendChild(this.div);
194
this.div.innerHTML = this.getHTML( box.width, box.height ).replace(/&/g, '&');
198
positionElement: function() {
199
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
200
var style = this.div.style;
202
style.position = 'absolute';
205
style.width = box.width + 'px';
206
style.height = box.height + 'px';
208
if ( box.width !== 0 && box.height !== 0 ) {
214
var flash = this.div.childNodes[0];
215
flash.width = box.width;
216
flash.height = box.height;
219
getHTML: function(width, height) {
222
var flashvars = 'id=' + this.id +
226
if (navigator.userAgent.match(/MSIE/)) {
228
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
229
html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard_TableTools.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
233
html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard_TableTools.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
241
this.div.style.left = '-2000px';
250
destroy: function() {
254
if (this.domElement && this.div) {
255
$(this.div).remove();
257
this.domElement = null;
260
$.each( ZeroClipboard_TableTools.clients, function ( id, client ) {
261
if ( client === that ) {
262
delete ZeroClipboard_TableTools.clients[ id ];
268
reposition: function(elem) {
272
this.domElement = ZeroClipboard_TableTools.$(elem);
273
if (!this.domElement) {
278
if (this.domElement && this.div) {
279
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
280
var style = this.div.style;
281
style.left = '' + box.left + 'px';
282
style.top = '' + box.top + 'px';
286
clearText: function() {
290
this.movie.clearText();
294
appendText: function(newText) {
296
this.clipText += newText;
297
if (this.ready) { this.movie.appendText(newText) ;}
300
setText: function(newText) {
302
this.clipText = newText;
303
if (this.ready) { this.movie.setText(newText) ;}
306
setFileName: function(newText) {
308
this.fileName = newText;
310
this.movie.setFileName(newText);
314
setSheetData: function(data) {
317
this.movie.setSheetData( JSON.stringify( data ) );
321
setAction: function(newText) {
323
this.action = newText;
325
this.movie.setAction(newText);
329
addEventListener: function(eventName, func) {
332
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
333
if (!this.handlers[eventName]) {
334
this.handlers[eventName] = [];
336
this.handlers[eventName].push(func);
339
setHandCursor: function(enabled) {
341
this.handCursorEnabled = enabled;
343
this.movie.setHandCursor(enabled);
347
setCSSEffects: function(enabled) {
349
this.cssEffects = !!enabled;
352
receiveEvent: function(eventName, args) {
356
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
363
this.movie = document.getElementById(this.movieId);
366
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
371
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
373
setTimeout( function() { self.receiveEvent('load', null); }, 100 );
379
this.movie.clearText();
380
this.movie.appendText( this.clipText );
381
this.movie.setFileName( this.fileName );
382
this.movie.setAction( this.action );
383
this.movie.setHandCursor( this.handCursorEnabled );
387
if (this.domElement && this.cssEffects) {
389
if (this.recoverActive) {
390
this.domElement.addClass('active');
396
if (this.domElement && this.cssEffects) {
397
this.recoverActive = false;
398
if (this.domElement.hasClass('active')) {
399
this.domElement.removeClass('active');
400
this.recoverActive = true;
407
if (this.domElement && this.cssEffects) {
408
this.domElement.addClass('active');
413
if (this.domElement && this.cssEffects) {
414
this.domElement.removeClass('active');
415
this.recoverActive = false;
420
if (this.handlers[eventName]) {
421
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
422
var func = this.handlers[eventName][idx];
424
if (typeof(func) == 'function') {
428
else if ((typeof(func) == 'object') && (func.length == 2)) {
430
func[0][ func[1] ](this, args);
432
else if (typeof(func) == 'string') {
434
window[func](this, args);
441
ZeroClipboard_TableTools.hasFlash = function ()
444
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
451
navigator.mimeTypes &&
452
navigator.mimeTypes['application/x-shockwave-flash'] !== undefined &&
453
navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin
464
window.ZeroClipboard_TableTools = ZeroClipboard_TableTools;
480
var _glue = function ( flash, node )
482
var id = node.attr('id');
484
if ( node.parents('html').length ) {
485
flash.glue( node[0], '' );
488
setTimeout( function () {
489
_glue( flash, node );
500
var _filename = function ( config, incExtension )
503
var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined ?
507
if ( typeof filename === 'function' ) {
508
filename = filename();
511
if ( filename.indexOf( '*' ) !== -1 ) {
512
filename = $.trim( filename.replace( '*', $('title').text() ) );
516
filename = filename.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
518
return incExtension === undefined || incExtension === true ?
519
filename+config.extension :
528
var _sheetname = function ( config )
530
var sheetName = 'Sheet1';
532
if ( config.sheetName ) {
533
sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, '');
544
var _title = function ( config )
546
var title = config.title;
548
if ( typeof title === 'function' ) {
552
return title.indexOf( '*' ) !== -1 ?
553
title.replace( '*', $('title').text() || 'Exported data' ) :
567
var _setText = function ( flash, data )
569
var parts = data.match(/[\s\S]{1,8192}/g) || [];
572
for ( var i=0, len=parts.length ; i<len ; i++ )
574
flash.appendText( parts[i] );
584
var _newLine = function ( config )
586
return config.newline ?
588
navigator.userAgent.match(/Windows/) ?
601
var _exportData = function ( dt, config )
603
var newLine = _newLine( config );
604
var data = dt.buttons.exportData( config.exportOptions );
605
var boundary = config.fieldBoundary;
606
var separator = config.fieldSeparator;
607
var reBoundary = new RegExp( boundary, 'g' );
608
var escapeChar = config.escapeChar !== undefined ?
611
var join = function ( a ) {
616
for ( var i=0, ien=a.length ; i<ien ; i++ ) {
622
boundary + ('' + a[i]).replace( reBoundary, escapeChar+boundary ) + boundary :
629
var header = config.header ? join( data.header )+newLine : '';
630
var footer = config.footer && data.footer ? newLine+join( data.footer ) : '';
633
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
634
body.push( join( data.body[i] ) );
638
str: header + body.join( newLine ) + footer,
646
available: function () {
647
return ZeroClipboard_TableTools.hasFlash();
650
init: function ( dt, button, config ) {
652
ZeroClipboard_TableTools.moviePath = DataTable.Buttons.swfPath;
653
var flash = new ZeroClipboard_TableTools.Client();
655
flash.setHandCursor( true );
656
flash.addEventListener('mouseDown', function(client) {
657
config._fromFlash = true;
658
dt.button( button[0] ).trigger();
659
config._fromFlash = false;
662
_glue( flash, button );
664
config._flash = flash;
667
destroy: function ( dt, button, config ) {
668
config._flash.destroy();
694
function createCellPos( n ){
695
var ordA = 'A'.charCodeAt(0);
696
var ordZ = 'Z'.charCodeAt(0);
697
var len = ordZ - ordA + 1;
701
s = String.fromCharCode(n % len + ordA) + s;
702
n = Math.floor(n / len) - 1;
718
function _createNode( doc, nodeName, opts ){
719
var tempNode = doc.createElement( nodeName );
723
$(tempNode).attr( opts.attr );
726
if( opts.children ) {
727
$.each( opts.children, function ( key, value ) {
728
tempNode.appendChild( value );
733
tempNode.appendChild( doc.createTextNode( opts.text ) );
746
function _excelColWidth( data, col ) {
747
var max = data.header[col].length;
748
var len, lineSplit, str;
750
if ( data.footer && data.footer[col].length > max ) {
751
max = data.footer[col].length;
754
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
755
var point = data.body[i][col];
756
str = point !== null && point !== undefined ?
762
if ( str.indexOf('\n') !== -1 ) {
763
lineSplit = str.split('\n');
764
lineSplit.sort( function (a, b) {
765
return b.length - a.length;
768
len = lineSplit[0].length;
787
return max > 6 ? max : 6;
790
var _serialiser = "";
791
if (typeof window.XMLSerializer === 'undefined') {
792
_serialiser = new function () {
793
this.serializeToString = function (input) {
798
_serialiser = new XMLSerializer();
808
function _xlsxToStrings( obj ) {
809
if ( _ieExcel === undefined ) {
812
_ieExcel = _serialiser
814
$.parseXML( excelStrings['xl/worksheets/sheet1.xml'] )
816
.indexOf( 'xmlns:r' ) === -1;
819
$.each( obj, function ( name, val ) {
820
if ( $.isPlainObject( val ) ) {
821
_xlsxToStrings( val );
830
var worksheet = val.childNodes[0];
834
for ( i=worksheet.attributes.length-1 ; i>=0 ; i-- ) {
835
var attrName = worksheet.attributes[i].nodeName;
836
var attrValue = worksheet.attributes[i].nodeValue;
838
if ( attrName.indexOf( ':' ) !== -1 ) {
839
attrs.push( { name: attrName, value: attrValue } );
841
worksheet.removeAttribute( attrName );
845
for ( i=0, ien=attrs.length ; i<ien ; i++ ) {
846
var attr = val.createAttribute( attrs[i].name.replace( ':', '_dt_b_namespace_token_' ) );
847
attr.value = attrs[i].value;
848
worksheet.setAttributeNode( attr );
852
var str = _serialiser.serializeToString(val);
857
if ( str.indexOf( '<?xml' ) === -1 ) {
858
str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+str;
862
str = str.replace( /_dt_b_namespace_token_/g, ':' );
867
str = str.replace( /<([^<>]*?) xmlns=""([^<>]*?)>/g, '<$1 $2>' );
877
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
878
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
879
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'+
882
"xl/_rels/workbook.xml.rels":
883
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
884
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
885
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'+
886
'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+
889
"[Content_Types].xml":
890
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
891
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'+
892
'<Default Extension="xml" ContentType="application/xml" />'+
893
'<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />'+
894
'<Default Extension="jpeg" ContentType="image/jpeg" />'+
895
'<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />'+
896
'<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />'+
897
'<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />'+
901
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
902
'<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'+
903
'<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>'+
904
'<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>'+
906
'<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>'+
909
'<sheet name="" sheetId="1" r:id="rId1"/>'+
913
"xl/worksheets/sheet1.xml":
914
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
915
'<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">'+
920
'<?xml version="1.0" encoding="UTF-8"?>'+
921
'<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">'+
922
'<numFmts count="6">'+
923
'<numFmt numFmtId="164" formatCode="#,##0.00_-\ [$$-45C]"/>'+
924
'<numFmt numFmtId="165" formatCode=""£"#,##0.00"/>'+
925
'<numFmt numFmtId="166" formatCode="[$€-2]\ #,##0.00"/>'+
926
'<numFmt numFmtId="167" formatCode="0.0%"/>'+
927
'<numFmt numFmtId="168" formatCode="#,##0;(#,##0)"/>'+
928
'<numFmt numFmtId="169" formatCode="#,##0.00;(#,##0.00)"/>'+
930
'<fonts count="5" x14ac:knownFonts="1">'+
933
'<name val="Calibri" />'+
937
'<name val="Calibri" />'+
938
'<color rgb="FFFFFFFF" />'+
942
'<name val="Calibri" />'+
947
'<name val="Calibri" />'+
952
'<name val="Calibri" />'+
958
'<patternFill patternType="none" />'+
962
'<patternFill patternType="solid">'+
963
'<fgColor rgb="FFD9D9D9" />'+
964
'<bgColor indexed="64" />'+
968
'<patternFill patternType="solid">'+
969
'<fgColor rgb="FFD99795" />'+
970
'<bgColor indexed="64" />'+
974
'<patternFill patternType="solid">'+
975
'<fgColor rgb="ffc6efce" />'+
976
'<bgColor indexed="64" />'+
980
'<patternFill patternType="solid">'+
981
'<fgColor rgb="ffc6cfef" />'+
982
'<bgColor indexed="64" />'+
986
'<borders count="2">'+
994
'<border diagonalUp="false" diagonalDown="false">'+
995
'<left style="thin">'+
996
'<color auto="1" />'+
998
'<right style="thin">'+
999
'<color auto="1" />'+
1001
'<top style="thin">'+
1002
'<color auto="1" />'+
1004
'<bottom style="thin">'+
1005
'<color auto="1" />'+
1010
'<cellStyleXfs count="1">'+
1011
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />'+
1013
'<cellXfs count="61">'+
1014
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1015
'<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1016
'<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1017
'<xf numFmtId="0" fontId="3" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1018
'<xf numFmtId="0" fontId="4" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1019
'<xf numFmtId="0" fontId="0" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1020
'<xf numFmtId="0" fontId="1" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1021
'<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1022
'<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1023
'<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1024
'<xf numFmtId="0" fontId="0" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1025
'<xf numFmtId="0" fontId="1" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1026
'<xf numFmtId="0" fontId="2" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1027
'<xf numFmtId="0" fontId="3" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1028
'<xf numFmtId="0" fontId="4" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1029
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1030
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1031
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1032
'<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1033
'<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1034
'<xf numFmtId="0" fontId="0" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1035
'<xf numFmtId="0" fontId="1" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1036
'<xf numFmtId="0" fontId="2" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1037
'<xf numFmtId="0" fontId="3" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1038
'<xf numFmtId="0" fontId="4" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
1039
'<xf numFmtId="0" fontId="0" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1040
'<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1041
'<xf numFmtId="0" fontId="2" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1042
'<xf numFmtId="0" fontId="3" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1043
'<xf numFmtId="0" fontId="4" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1044
'<xf numFmtId="0" fontId="0" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1045
'<xf numFmtId="0" fontId="1" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1046
'<xf numFmtId="0" fontId="2" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1047
'<xf numFmtId="0" fontId="3" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1048
'<xf numFmtId="0" fontId="4" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1049
'<xf numFmtId="0" fontId="0" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1050
'<xf numFmtId="0" fontId="1" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1051
'<xf numFmtId="0" fontId="2" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1052
'<xf numFmtId="0" fontId="3" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1053
'<xf numFmtId="0" fontId="4" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1054
'<xf numFmtId="0" fontId="0" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1055
'<xf numFmtId="0" fontId="1" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1056
'<xf numFmtId="0" fontId="2" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1057
'<xf numFmtId="0" fontId="3" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1058
'<xf numFmtId="0" fontId="4" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1059
'<xf numFmtId="0" fontId="0" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1060
'<xf numFmtId="0" fontId="1" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1061
'<xf numFmtId="0" fontId="2" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1062
'<xf numFmtId="0" fontId="3" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1063
'<xf numFmtId="0" fontId="4" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
1064
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1065
'<alignment horizontal="left"/>'+
1067
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1068
'<alignment horizontal="center"/>'+
1070
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1071
'<alignment horizontal="right"/>'+
1073
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1074
'<alignment horizontal="fill"/>'+
1076
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1077
'<alignment textRotation="90"/>'+
1079
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
1080
'<alignment wrapText="1"/>'+
1082
'<xf numFmtId="9" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1083
'<xf numFmtId="164" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1084
'<xf numFmtId="165" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1085
'<xf numFmtId="166" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1086
'<xf numFmtId="167" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1087
'<xf numFmtId="168" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1088
'<xf numFmtId="169" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1089
'<xf numFmtId="3" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1090
'<xf numFmtId="4" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
1092
'<cellStyles count="1">'+
1093
'<cellStyle name="Normal" xfId="0" builtinId="0" />'+
1095
'<dxfs count="0" />'+
1096
'<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4" />'+
1104
var _excelSpecials = [
1105
{ match: /^\-?\d+\.\d%$/, style: 60, fmt: function (d) { return d/100; } },
1106
{ match: /^\-?\d+\.?\d*%$/, style: 56, fmt: function (d) { return d/100; } },
1107
{ match: /^\-?\$[\d,]+.?\d*$/, style: 57 },
1108
{ match: /^\-?£[\d,]+.?\d*$/, style: 58 },
1109
{ match: /^\-?€[\d,]+.?\d*$/, style: 59 },
1110
{ match: /^\([\d,]+\)$/, style: 61, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } },
1111
{ match: /^\([\d,]+\.\d{2}\)$/, style: 62, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } },
1112
{ match: /^[\d,]+$/, style: 63 },
1113
{ match: /^[\d,]+\.\d{2}$/, style: 64 }
1123
DataTable.Buttons.swfPath = '//cdn.datatables.net/buttons/1.2.4/swf/flashExport.swf';
1127
DataTable.Api.register( 'buttons.resize()', function () {
1128
$.each( ZeroClipboard_TableTools.clients, function ( i, client ) {
1129
if ( client.domElement !== undefined && client.domElement.parentNode ) {
1130
client.positionElement();
1141
DataTable.ext.buttons.copyFlash = $.extend( {}, flashButton, {
1142
className: 'buttons-copy buttons-flash',
1144
text: function ( dt ) {
1145
return dt.i18n( 'buttons.copy', 'Copy' );
1148
action: function ( e, dt, button, config ) {
1150
if ( ! config._fromFlash ) {
1154
this.processing( true );
1156
var flash = config._flash;
1157
var data = _exportData( dt, config );
1158
var output = config.customize ?
1159
config.customize( data.str, config ) :
1162
flash.setAction( 'copy' );
1163
_setText( flash, output );
1165
this.processing( false );
1168
dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
1169
dt.i18n( 'buttons.copySuccess', {
1170
_: 'Copied %d rows to clipboard',
1171
1: 'Copied 1 row to clipboard'
1177
fieldSeparator: '\t',
1183
DataTable.ext.buttons.csvFlash = $.extend( {}, flashButton, {
1184
className: 'buttons-csv buttons-flash',
1186
text: function ( dt ) {
1187
return dt.i18n( 'buttons.csv', 'CSV' );
1190
action: function ( e, dt, button, config ) {
1192
var flash = config._flash;
1193
var data = _exportData( dt, config );
1194
var output = config.customize ?
1195
config.customize( data.str, config ) :
1198
flash.setAction( 'csv' );
1199
flash.setFileName( _filename( config ) );
1200
_setText( flash, output );
1207
DataTable.ext.buttons.excelFlash = $.extend( {}, flashButton, {
1208
className: 'buttons-excel buttons-flash',
1210
text: function ( dt ) {
1211
return dt.i18n( 'buttons.excel', 'Excel' );
1214
action: function ( e, dt, button, config ) {
1215
this.processing( true );
1217
var flash = config._flash;
1219
var rels = $.parseXML( excelStrings['xl/worksheets/sheet1.xml'] ) ;
1220
var relsGet = rels.getElementsByTagName( "sheetData" )[0];
1224
".rels": $.parseXML( excelStrings['_rels/.rels'] )
1228
"workbook.xml.rels": $.parseXML( excelStrings['xl/_rels/workbook.xml.rels'] )
1230
"workbook.xml": $.parseXML( excelStrings['xl/workbook.xml'] ),
1231
"styles.xml": $.parseXML( excelStrings['xl/styles.xml'] ),
1237
"[Content_Types].xml": $.parseXML( excelStrings['[Content_Types].xml'])
1240
var data = dt.buttons.exportData( config.exportOptions );
1241
var currentRow, rowNode;
1242
var addRow = function ( row ) {
1243
currentRow = rowPos+1;
1244
rowNode = _createNode( rels, "row", { attr: {r:currentRow} } );
1246
for ( var i=0, ien=row.length ; i<ien ; i++ ) {
1248
var cellId = createCellPos(i) + '' + currentRow;
1252
if ( row[i] === null || row[i] === undefined || row[i] === '' ) {
1256
row[i] = $.trim( row[i] );
1259
for ( var j=0, jen=_excelSpecials.length ; j<jen ; j++ ) {
1260
var special = _excelSpecials[j];
1265
if ( row[i].match && ! row[i].match(/^0\d+/) && row[i].match( special.match ) ) {
1266
var val = row[i].replace(/[^\d\.\-]/g, '');
1268
if ( special.fmt ) {
1269
val = special.fmt( val );
1272
cell = _createNode( rels, 'c', {
1278
_createNode( rels, 'v', { text: val } )
1287
if ( typeof row[i] === 'number' || (
1289
row[i].match(/^-?\d+(\.\d+)?$/) &&
1290
! row[i].match(/^0\d+/) )
1294
cell = _createNode( rels, 'c', {
1300
_createNode( rels, 'v', { text: row[i] } )
1306
var text = ! row[i].replace ?
1308
row[i].replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');
1310
cell = _createNode( rels, 'c', {
1316
row: _createNode( rels, 'is', {
1318
row: _createNode( rels, 't', {
1328
rowNode.appendChild( cell );
1331
relsGet.appendChild(rowNode);
1335
$( 'sheets sheet', xlsx.xl['workbook.xml'] ).attr( 'name', _sheetname( config ) );
1337
if ( config.customizeData ) {
1338
config.customizeData( data );
1341
if ( config.header ) {
1342
addRow( data.header, rowPos );
1343
$('row c', rels).attr( 's', '2' );
1346
for ( var n=0, ie=data.body.length ; n<ie ; n++ ) {
1347
addRow( data.body[n], rowPos );
1350
if ( config.footer && data.footer ) {
1351
addRow( data.footer, rowPos);
1352
$('row:last c', rels).attr( 's', '2' );
1356
var cols = _createNode( rels, 'cols' );
1357
$('worksheet', rels).prepend( cols );
1359
for ( var i=0, ien=data.header.length ; i<ien ; i++ ) {
1360
cols.appendChild( _createNode( rels, 'col', {
1364
width: _excelColWidth( data, i ),
1371
if ( config.customize ) {
1372
config.customize( xlsx );
1375
_xlsxToStrings( xlsx );
1377
flash.setAction( 'excel' );
1378
flash.setFileName( _filename( config ) );
1379
flash.setSheetData( xlsx );
1380
_setText( flash, '' );
1382
this.processing( false );
1391
DataTable.ext.buttons.pdfFlash = $.extend( {}, flashButton, {
1392
className: 'buttons-pdf buttons-flash',
1394
text: function ( dt ) {
1395
return dt.i18n( 'buttons.pdf', 'PDF' );
1398
action: function ( e, dt, button, config ) {
1399
this.processing( true );
1402
var flash = config._flash;
1403
var data = dt.buttons.exportData( config.exportOptions );
1404
var totalWidth = dt.table().node().offsetWidth;
1407
var ratios = dt.columns( config.columns ).indexes().map( function ( idx ) {
1408
return dt.column( idx ).header().offsetWidth / totalWidth;
1411
flash.setAction( 'pdf' );
1412
flash.setFileName( _filename( config ) );
1414
_setText( flash, JSON.stringify( {
1415
title: _filename(config, false),
1416
message: typeof config.message == 'function' ? config.message(dt, button, config) : config.message,
1417
colWidth: ratios.toArray(),
1418
orientation: config.orientation,
1419
size: config.pageSize,
1420
header: config.header ? data.header : null,
1421
footer: config.footer ? data.footer : null,
1425
this.processing( false );
1430
orientation: 'portrait',
1440
return DataTable.Buttons;