﻿/*!
 * ExcelPlus JavaScript Library v2.2
 *
 * Copyright 2014, aymeric@kodono.info
 * Licensed under GPL Version 3 licenses.
 *
 * http://aymkdn.github.io/ExcelPlus/
 */
;function addEventListener(c,a,b){if(c.addEventListener){c.addEventListener(a,b)}else{if(c.attachEvent){c.attachEvent("on"+a,function(){b.call(c)})}}}var __ExcelPlus_flashPath="";function ExcelPlus(a){this.aLetters=[];this.aLetters.A=1,this.aLetters.B=2,this.aLetters.C=3,this.aLetters.D=4,this.aLetters.E=5,this.aLetters.F=6,this.aLetters.G=7,this.aLetters.H=8,this.aLetters.I=9,this.aLetters.J=10,this.aLetters.K=11,this.aLetters.L=12,this.aLetters.M=13,this.aLetters.N=14,this.aLetters.O=15,this.aLetters.P=16,this.aLetters.Q=17;this.aLetters.R=18,this.aLetters.S=19,this.aLetters.T=20,this.aLetters.U=21,this.aLetters.V=22,this.aLetters.W=23,this.aLetters.X=24,this.aLetters.Y=25,this.aLetters.Z=26;this.oSheet=null;this.selectedSheet="";this.nbSheets=0;this.oFile=null;this.nbRows=0,this.nbColumns=0;this.filename="";this.usedRange="";a=a||{};this.error="";this.showErrors=(a.showErrors===undefined?true:a.showErrors)}ExcelPlus.prototype={reset:function(){this.oFile=null;this.nbSheets=0;this.nbRows=0;this.nbColumns=0;this.usedRange="";this.oSheet=null;this.selectedSheet="";return this},openLocal:function(b,a){if(typeof b==="function"){a=b;b={}}a=a||function(){};b.idButton=b.idButton||"file-object";if(document.getElementById(b.idButton)===null){this.error="[openLocal] You must have a <object> tag in your code.";this._showErrors();return this}b.labelButton=b.labelButton||"Load a file";__ExcelPlus_flashPath=b.flashPath||"";var c=this;if(typeof FileReader==="function"){document.getElementById(b.idButton).outerHTML='<input id="'+b.idButton+'" type="file" value="'+b.labelButton+'" />';addEventListener(document.getElementById(b.idButton),"change",function(h){var g=h.target.files,f;if(!g||g.length==0){return}f=g[0];var d=new FileReader();d.onload=function(i){c.filename=f.name;c.oFile=XLSX.read(i.target.result,{type:"binary",cellDates:true,cellStyles:true});c.nbSheets=c.oFile.SheetNames.length;if(c.nbSheets==1){c.selectSheet(1)}a.call(c,true)};d.readAsBinaryString(f)})}else{Flash.getButtonLabel=function(){return b.labelButton};Flash.createButton(b.idButton,function(d){c.filename="Unknown Name";c.oFile=XLSX.read(d,{type:"base64",cellDates:true,cellStyles:true});c.nbSheets=c.oFile.SheetNames.length;if(c.nbSheets==1){c.selectSheet(1)}a.call(c,true)})}return c},openRemote:function(b,d){var f=this;var e=new XMLHttpRequest();var a=function(g){return g};e.open("GET",b,true);if(e.overrideMimeType){e.overrideMimeType("text/plain; charset=x-user-defined")}else{e.setRequestHeader("Accept-Charset","x-user-defined");var c='<script language="VBScript">\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n  IEBinaryToArray_ByteStr = CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n  Dim lastIndex\r\n  lastIndex = LenB(Binary)\r\n  if lastIndex mod 2 Then\r\n    IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n  Else\r\n    IEBinaryToArray_ByteStr_Last = ""\r\n  End If\r\nEnd Function\r\n<\/script>\r\n';document.write(c);a=function(n){var g={};for(var m=0;m<256;m++){for(var l=0;l<256;l++){g[String.fromCharCode(m+l*256)]=String.fromCharCode(m)+String.fromCharCode(l)}}var h=IEBinaryToArray_ByteStr(n);var k=IEBinaryToArray_ByteStr_Last(n);return h.replace(/[\s\S]/g,function(i){return g[i]})+k}}e.onreadystatechange=function(g){if(e.readyState==4){if(e.status==200){f.filename=b.split("/").slice(-1);var h=(e.overrideMimeType?e.responseText:a(e.responseBody));f.oFile=XLSX.read(h,{type:"binary",cellDates:true,cellStyles:true});f.nbSheets=f.oFile.SheetNames.length;if(f.nbSheets==1){f.selectSheet(1)}d.call(f,true)}else{f.error="[openRemote] Cannot find the remote file";f._showErrors();d.call(f,false)}}};e.send(null);return this},getSheetNames:function(){if(this.oFile==null){this.error="[getSheetNames] No Excel file opened.";this._showErrors();return this}return this.oFile.SheetNames},selectSheet:function(e){if(this.oFile==null){this.error="[selectSheet] No Excel file opened.";this._showErrors();return this}if(!isNaN(e)){var c=this.getSheetNames();e-=1;var b=c.length;if(e>=b){this.error="[selectSheet] Impossible to select sheet #"+e+" because only "+b+" sheet"+(b>1?"s":"")+" found in the file.";this._showErrors();return this}for(var d=0;d<b;d++){if(e==d){e=c[d];break}}}if(!isNaN(e)){this.error="[selectSheet] Impossible to select sheet #"+e+" because I cannot find it.";this._showErrors();return this}if(this.oFile.SheetNames.indexOf(e)===-1){this.error="[selectSheet] Impossible to select sheet "+e+" because there is no sheet with that name.";this._showErrors();return this}this.oSheet=this.oFile.Sheets[e];this.selectedSheet=e;if(this.oSheet["!ref"]){this.usedRange=this.oSheet["!ref"];var a=this._getCellCoord(this.usedRange.split(":")[1]);this.nbRows=a.row*1;this.nbColumns=a.column*1}return this},readAll:function(){if(this._checkSheet()==false){this.error="[readAll] You have to select a sheet before using `readAll`";this._showErrors();return this}var c=[],a;for(var d=1;d<=this.nbRows;d++){a=[];for(var b=1;b<=this.nbColumns;b++){a.push(this.read(this._getColumnName(b)+""+d))}c.push(a)}return c},read:function(b,c){if(this._checkSheet()==false){return this}c=c||{};c.parseDate=(c.parseDate===true?true:false);var g=null;if(this._isRange(b)){b=XLSX.utils.decode_range(b);var e=[],a=[],d,f;for(d=b.s.r;d<=b.e.r;++d){a=[];for(f=b.s.c;f<=b.e.c;++f){a.push(this.read(XLSX.utils.encode_cell({c:f,r:d}),c))}e.push(a)}return e}else{if(this._isCell(b)){g=this.oSheet[b];if(g){if(g.t==="d"&&c.parseDate){g=XLSX.SSF.parse_date_code(g.v);g=new Date(g.y,g.m,g.d,g.H,g.M,g.S)}else{g=g.w||g.v}}else{g=null}return g}}return null},createFile:function(a){a=a||["Sheet1"];if(typeof a==="string"){a=[a]}this.oFile={SheetNames:[],Sheets:{}};for(var b=0;b<a.length;b++){if(this.createSheet(a[b])===false){return this}}return this},write:function(b){b.sheet=b.sheet||this.selectedSheet||this.oFile.SheetNames[0];this.selectSheet(b.sheet);if(!b.content){this.error="[write] Please provide the 'content'";this._showErrors();return this}if(Array.isArray(b.content)){b.cell=null}else{if(!b.cell){this.error="[write] Please provide the 'cell' reference";this._showErrors();return this}}if(!b.cell){var e=b.content,d,f,c,a;for(d=0;d!=e.length;++d){for(f=0;f!=e[d].length;++f){a=this._createCell(e[d][f]);if(a.v==null){continue}c=XLSX.utils.encode_cell({c:f,r:d});this.oFile.Sheets[this.selectedSheet][c]=a;this._updateUsedRange(c)}}}else{this.writeCell(b.cell,b.content)}this.oSheet=this.oFile.Sheets[this.selectedSheet];return this},writeCell:function(a,b){if(!this.selectedSheet){if(this.oFile.SheetNames.length>0){this.error="[writeCell] No sheet selected";this._showErrors();return this}else{this.error="[writeCell] You have to create a sheet first";this._showErrors();return this}}if(!b){this.error="[writeCell] You have to provide the content";this._showErrors();return this}if(!this._isCell(a)){this.error="[writeCell] You have to provide a cell reference, e.g. 'A1'";this._showErrors();return this}if(b==null){delete this.oFile.Sheets[this.selectedSheet][a]}else{this.oFile.Sheets[this.selectedSheet][a]=this._createCell(b)}this._updateUsedRange(a);this.selectSheet(this.selectedSheet);return this},deleteSheet:function(b){b=b||this.selectedSheet;if(b){delete this.oFile.Sheets[b];if(b==this.selectedSheet){this.selectedSheet=""}var a=this.oFile.SheetNames.indexOf(b);if(a>-1){this.oFile.SheetNames.splice(a,1)}}return this},createSheet:function(b,a){a=(a===undefined?true:a);if(!b){this.error="[createSheet] You have to provide a name for the sheet";this._showErrors();return this}if(this.oFile.SheetNames.indexOf(b)!==-1){this.error="[createSheet] There is already a sheet with the name '"+b+"'";this._showErrors();return this}this.oFile.SheetNames.push(b);this.oFile.Sheets[b]={"!ref":"A1:A1"};if(a){this.selectSheet(b)}return this},saveAs:function(b){b=b||"book1.xlsx";var d=b.split(".").pop();if(["xlsx","xlsm","xlsb"].indexOf(d)===-1){d="xlsx";b+="."+d}if(typeof Uint8Array==="undefined"){this.error="[saveAs] Sorry but this function is only supported by modern browsers";this._showErrors();return this}var c=XLSX.write(this.oFile,{bookType:d,bookSST:true,type:"binary"});var a=function(h){var f=new ArrayBuffer(h.length);var e=new Uint8Array(f);for(var g=0;g!=h.length;++g){e[g]=h.charCodeAt(g)&255}return f};saveAs(new Blob([a(c)],{type:"application/octet-stream"}),b);return this},saveTo:function(b,a){return XLSX.write(this.oFile,{bookType:b||"xlsx",bookSST:true,type:a||"base64"})},_createCell:function(b){var a={v:b,t:this._getValueType(b)};if(b instanceof Date){a.z=XLSX.SSF._table[14];a.v=this._dateToNum(b)}return a},_updateUsedRange:function(c){var b=XLSX.utils.decode_range(this.oSheet["!ref"]);if(this._isCell(c)){c=this._getCellCoord(c)}c.row-=1;c.column-=1;var a=false;if(b.s.r>c.row){a=true;b.s.r=c.row}if(b.s.c>c.column){a=true;b.s.c=c.column}if(b.e.r<c.row){a=true;b.e.r=c.row}if(b.e.c<c.column){a=true;b.e.c=c.column}if(a){b=XLSX.utils.encode_range(b);this.oFile.Sheets[this.selectedSheet]["!ref"]=b;this.usedRange=b}return this},_getValueType:function(a){if(typeof a==="number"){return"n"}if(typeof a==="boolean"){return"b"}if(a instanceof Date){return"n"}return"s"},_dateToNum:function(b,a){if(a){b+=1462}var c=Date.parse(b);return(c-new Date(Date.UTC(1899,11,30)))/(24*60*60*1000)},_getColumn:function(c){var b=0;if(c.length==1){return this.aLetters[c]}if(c.length>1){var e=c.split("");var a=e.length;for(var d=0;d<a;d++){if(d+1<a){b+=this.aLetters[e[d]]*26}else{b+=this.aLetters[e[d]]}}return b}else{return 0}},_getColumnName:function(b){if(b<=26){var c=1;for(var d in this.aLetters){if(d.length==1){if(c==b){return d}c++}}}else{var e=0;do{b-=26;e++}while(b>26);var a="";var c=1;for(var d in this.aLetters){if(d.length==1){if(c==e){a=d;break}c++}}c=1;for(var d in this.aLetters){if(d.length==1){if(c==b){return a+""+d}c++}}}},_getCellCoord:function(b){var a=b.match(/([A-Z]+)([0-9]+)/);if(a==null||a.length!=3){this.error="[_getCellCoord] The format of the cell is wrong.";this._showErrors();return this}return{column:this._getColumn(a[1]),row:a[2]*1}},_getColorIndex:function(a){if(!isNaN(a)){return a}switch(a){case"black":return 1;case"white":return 2;case"red":return 3;case"green":return 4;case"darkblue":return 5;case"blue":return 23;case"yellow":return 6;case"magenta":return 7;case"cyan":return 8;case"purple":return 13;case"lightgray":return 15;case"gray":return 16;case"orange":return 45;default:this.error="[_getColorIndex] '"+a+"' is an unknown color. Known colors are: black, white, red, green, blue, yellow, magenta and cyan";this._showErrors();return this}},_isRange:function(a){return(typeof a==="string"&&a.indexOf(":")!=-1&&a.match(/[1-9]/)!=null)},_isCell:function(a){return(typeof a==="string"&&a.indexOf(":")==-1&&a.match(/[1-9]/)!=null)},_isColumn:function(a){return(typeof a==="string"&&a.match(/[1-9]/)==null)},_checkSheet:function(){if(this.oSheet==null){this.error="[_checkSheet] Please select a sheet first";this._showErrors();return this}},_showErrors:function(){if(this.showErrors){if(this.error!==""){throw"[ExcelPlus] "+this.error}else{console.log("[ExcelPlus] No Error")}}}};
/*! FileSaver.js
 *  A saveAs() FileSaver implementation.
 *  2014-01-24
 *
 *  By Eli Grey, http://eligrey.com
 *  License: X11/MIT
 *    See LICENSE.md
 */
;
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
;var saveAs=saveAs||(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator))||(function(C){if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var s=C.document,y=function(){return C.URL||C.webkitURL||C},F=C.URL||C.webkitURL||C,w=s.createElementNS("http://www.w3.org/1999/xhtml","a"),D=!C.externalHost&&"download" in w,A=function(a){var b=s.createEvent("MouseEvents");b.initMouseEvent("click",true,false,C,0,0,0,0,0,false,false,false,false,0,null);a.dispatchEvent(b)},v=C.webkitRequestFileSystem,u=C.requestFileSystem||v||C.mozRequestFileSystem,x=function(a){(C.setImmediate||C.setTimeout)(function(){throw a},0)},H="application/octet-stream",z=0,I=[],B=function(){var a=I.length;while(a--){var b=I[a];if(typeof b==="string"){F.revokeObjectURL(b)}else{b.remove()}}I.length=0},t=function(e,f,b){f=[].concat(f);var c=f.length;while(c--){var a=e["on"+f[c]];if(typeof a==="function"){try{a.call(e,b||e)}catch(d){x(d)}}}},E=function(l,i){var h=this,b=l.type,k=false,f,g,n=function(){var o=y().createObjectURL(l);I.push(o);return o},c=function(){t(h,"writestart progress write writeend".split(" "))},m=function(){if(k||!f){f=n(l)}if(g){g.location.href=f}else{if(navigator.userAgent.match(/7\.[\d\s\.]+Safari/)&&typeof window.FileReader!=="undefined"&&l.size<=1024*1024*150){var o=new window.FileReader();o.readAsDataURL(l);o.onloadend=function(){var p=s.createElement("iframe");p.src=o.result;p.style.display="none";s.body.appendChild(p);c();return};h.readyState=h.DONE;h.savedAs=h.SAVEDASUNKNOWN;return}else{window.open(f,"_blank");h.readyState=h.DONE;h.savedAs=h.SAVEDASBLOB;c();return}}},d=function(o){return function(){if(h.readyState!==h.DONE){return o.apply(this,arguments)}}},e={create:true,exclusive:false},a;h.readyState=h.INIT;if(!i){i="download"}if(D){f=n(l);s=C.document;w=s.createElementNS("http://www.w3.org/1999/xhtml","a");w.href=f;w.download=i;var j=s.createEvent("MouseEvents");j.initMouseEvent("click",true,false,C,0,0,0,0,0,false,false,false,false,0,null);w.dispatchEvent(j);h.readyState=h.DONE;h.savedAs=h.SAVEDASBLOB;c();return}if(C.chrome&&b&&b!==H){a=l.slice||l.webkitSlice;l=a.call(l,0,l.size,H);k=true}if(v&&i!=="download"){i+=".download"}if(b===H||v){g=C}if(!u){m();return}z+=l.size;u(C.TEMPORARY,z,d(function(o){o.root.getDirectory("saved",e,d(function(q){var p=function(){q.getFile(i,e,d(function(r){r.createWriter(d(function(L){L.onwriteend=function(K){g.location.href=r.toURL();I.push(r);h.readyState=h.DONE;h.savedAs=h.SAVEDASBLOB;t(h,"writeend",K)};L.onerror=function(){var K=L.error;if(K.code!==K.ABORT_ERR){m()}};"writestart progress write abort".split(" ").forEach(function(K){L["on"+K]=h["on"+K]});L.write(l);h.abort=function(){L.abort();h.readyState=h.DONE;h.savedAs=h.FAILED};h.readyState=h.WRITING}),m)}),m)};q.getFile(i,{create:false},d(function(r){r.remove();p()}),d(function(r){if(r.code===r.NOT_FOUND_ERR){p()}else{m()}}))}),m)}),m)},G=E.prototype,J=function(b,a){return new E(b,a)};G.abort=function(){var a=this;a.readyState=a.DONE;a.savedAs=a.FAILED;t(a,"abort")};G.readyState=G.INIT=0;G.WRITING=1;G.DONE=2;G.FAILED=-1;G.SAVEDASBLOB=1;G.SAVEDASURI=2;G.SAVEDASUNKNOWN=3;G.error=G.onwritestart=G.onprogress=G.onwrite=G.onabort=G.onerror=G.onwriteend=null;C.addEventListener("unload",B,false);J.unload=function(){B();C.removeEventListener("unload",B,false)};return J}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content));var swfobject;var __Flash_getFileData_callback;var Flash={callback:function(){},createButton:function(d,c){if(typeof c==="function"){this.callback=c}__Flash_getFileData_callback=this.callback;if(swfobject==undefined){var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("src",__ExcelPlus_flashPath+"/swfobject.js");document.getElementsByTagName("head")[0].appendChild(b);return this._waitForObjectToBeLoaded(d,c)}else{var a=120;swfobject.embedSWF(__ExcelPlus_flashPath+"/FileToDataURI.swf",d,a+"px","22px","10",__ExcelPlus_flashPath+"/expressInstall.swf",{},{},{})}},getFileData:function(a){__Flash_getFileData_callback(a)},_waitForObjectToBeLoaded:function(b,a){if(swfobject==undefined){setTimeout(function(){Flash._waitForObjectToBeLoaded(b,a)},50)}else{this.createButton(b,a)}}};