diff --git a/CHANGELOG.md b/CHANGELOG.md index 201296b..4185cc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This log is intended to keep track of backwards-incompatible changes, including but not limited to API changes and file location changes. Minor behavioral changes may not be included if they are not expected to break existing code. +## 0.13.0 (2018-06-01) + +* Library reshaped to support AMD out of the box + ## 0.12.11 (2018-04-27) * XLS/XLSX/XLSB range truncation (errors in `WTF` mode) diff --git a/README.md b/README.md index cff83dc..f26cf29 100644 --- a/README.md +++ b/README.md @@ -364,11 +364,11 @@ Multiple tables on a web page can be converted to individual worksheets: var workbook = XLSX.utils.book_new(); /* convert table 'table1' to worksheet named "Sheet1" */ -var ws1 = XLSX.utils.table_to_book(document.getElementById('table1')); +var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table1')); XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1"); /* convert table 'table2' to worksheet named "Sheet2" */ -var ws2 = XLSX.utils.table_to_book(document.getElementById('table2')); +var ws2 = XLSX.utils.table_to_sheet(document.getElementById('table2')); XLSX.utils.book_append_sheet(workbook, ws2, "Sheet2"); /* workbook now has 2 worksheets */ @@ -1555,6 +1555,17 @@ ws.A1.c.push({a:"SheetJS", t:"I'm a little comment, short and stout!"}); Note: XLSB enforces a 54 character limit on the Author name. Names longer than 54 characters may cause issues with other formats. +To mark a comment as normally hidden, set the `hidden` property: + +```js +if(!ws.A1.c) ws.A1.c = []; +ws.A1.c.push({a:"SheetJS", t:"This comment is visible"}); + +if(!ws.A2.c) ws.A2.c = []; +ws.A2.c.hidden = true; +ws.A2.c.push({a:"SheetJS", t:"This comment will be hidden"}); +``` + #### Sheet Visibility Excel enables hiding sheets in the lower tab bar. The sheet data is stored in diff --git a/bits/00_header.js b/bits/00_header.js index 84090f4..ead5056 100644 --- a/bits/00_header.js +++ b/bits/00_header.js @@ -1,6 +1,6 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ +/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ /*exported XLSX */ /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false */ var XLSX = {}; -(function make_xlsx(XLSX){ +function make_xlsx_lib(XLSX){ diff --git a/bits/01_version.js b/bits/01_version.js index db0f167..25baadd 100644 --- a/bits/01_version.js +++ b/bits/01_version.js @@ -1 +1 @@ -XLSX.version = '0.12.13'; +XLSX.version = '0.13.0'; diff --git a/bits/55_vml.js b/bits/55_vml.js index ff86aa5..3a5529d 100644 --- a/bits/55_vml.js +++ b/bits/55_vml.js @@ -1,6 +1,6 @@ /* L.5.5.2 SpreadsheetML Comments + VML Schema */ var _shapeid = 1024; -function write_comments_vml(rId, comments) { +function write_comments_vml(rId/*:number*/, comments) { var csize = [21600, 21600]; /* L.5.2.1.2 Path Attribute */ var bbox = ["m0,0l0",csize[1],csize[0],csize[1],csize[0],"0xe"].join(","); @@ -19,7 +19,7 @@ function write_comments_vml(rId, comments) { '', @@ -35,7 +35,7 @@ function write_comments_vml(rId, comments) { writetag('x:AutoFill', "False"), writetag('x:Row', String(c.r)), writetag('x:Column', String(c.c)), - '', + x[1].hidden ? '' : '', '', '' ]); }); diff --git a/bits/99_footer.js b/bits/99_footer.js index 294595a..0ec8613 100644 --- a/bits/99_footer.js +++ b/bits/99_footer.js @@ -1,3 +1,9 @@ -})(typeof exports !== 'undefined' ? exports : XLSX); +} +/*global define */ +/*:: declare var define:any; */ +if(typeof exports !== 'undefined') make_xlsx_lib(exports); +else if(typeof module !== 'undefined' && module.exports) make_xlsx_lib(module.exports); +else if(typeof define === 'function' && define.amd) define('xlsx', function() { if(!XLSX.version) make_xlsx_lib(XLSX); return XLSX; }); +else make_xlsx_lib(XLSX); /*exported XLS, ODS */ var XLS = XLSX, ODS = XLSX; diff --git a/demos/requirejs/README.md b/demos/requirejs/README.md index 0a59adf..415aa54 100644 --- a/demos/requirejs/README.md +++ b/demos/requirejs/README.md @@ -1,16 +1,7 @@ # RequireJS -The minified dist files trip up the RequireJS mechanism. To bypass, the scripts -automatically expose an `XLSX` variable that can be used if the require callback -argument is `_XLSX` rather than `XLSX`. This trick is employed in the included -`xlsx-shim.js` script: - -```js -/* xlsx-shim.js */ -define(['xlsx'], function (_XLSX) { - return XLSX; -}); -``` +The module complies with the AMD `define` semantics, enabling use in RequireJS +out of the box. The require config should set `xlsx` path to the appropriate dist file: @@ -20,10 +11,10 @@ The require config should set `xlsx` path to the appropriate dist file: }, ``` -Once that is set, app code can freely require `"xlsx-shim"`: +Once that is set, app code can freely require `"xlsx"`: ```js -require(["xlsx-shim"], function(XLSX) { +require(["xlsx"], function(XLSX) { /* use XLSX here */ }); ``` @@ -69,7 +60,7 @@ node r.js -o build.js paths.requireLib=./require include=requireLib That step creates a file `app-built.js` that can be included in a page: ```html - + ``` diff --git a/demos/requirejs/app.js b/demos/requirejs/app.js index b5f1281..6de5ce5 100644 --- a/demos/requirejs/app.js +++ b/demos/requirejs/app.js @@ -1,5 +1,5 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -require(["xlsx-shim"], function(XLSX) { +require(["xlsx"], function(XLSX) { console.log(XLSX); var X = XLSX; diff --git a/demos/requirejs/xlsx-shim.js b/demos/requirejs/xlsx-shim.js deleted file mode 100644 index 0462527..0000000 --- a/demos/requirejs/xlsx-shim.js +++ /dev/null @@ -1,5 +0,0 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -define(['xlsx'], function (_XLSX) { - /* work around require.js */ - return XLSX; -}); diff --git a/dist/jszip.js b/dist/jszip.js index 2ff0100..f9fd7aa 100644 --- a/dist/jszip.js +++ b/dist/jszip.js @@ -1,4 +1,4 @@ -/*! +/* JSZip - A Javascript class for generating and reading zip files @@ -14,7 +14,7 @@ Note: since JSZip 3 removed critical functionality, this version assigns to the */ (function(e){ if("object"==typeof exports&&"undefined"!=typeof module&&"undefined"==typeof DO_NOT_EXPORT_JSZIP)module.exports=e(); - else if("function"==typeof define&&define.amd){JSZipSync=e();define([],e);} + else if("function"==typeof define&&define.amd&&"undefined"==typeof DO_NOT_EXPORT_JSZIP){JSZipSync=e();define([],e);} else{ var f; "undefined"!=typeof window?f=window: diff --git a/dist/shim.min.js b/dist/shim.min.js index 880a01b..a421ac0 100644 --- a/dist/shim.min.js +++ b/dist/shim.min.js @@ -1,2 +1,2 @@ -/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -if(!Object.keys)Object.keys=function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],i=r.length;return function(n){if(typeof n!=="object"&&typeof n!=="function"||n===null)throw new TypeError("Object.keys called on non-object");var o=[];for(var a in n)if(t.call(n,a))o.push(a);if(e)for(var l=0;l=0;--e)if(!t.charAt(e).match(/^\s/))return t.slice(0,e+1);return""};if(!Array.prototype.forEach)Array.prototype.forEach=function(t){var e=this.length>>>0,r=arguments[1]||void 0;for(var i=0;i>>0,r=arguments[1]||void 0,i=new Array(e);for(var n=0;n>>0,r=arguments[1]|0||0;for(r<0&&(r+=e)<0&&(r=0);r>>0,r=e-1;for(;r>=0;--r)if(this[r]===t)return r;return-1};if(!Array.isArray)Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"};if(!Date.prototype.toISOString)Date.prototype.toISOString=function(){function t(t,e){return("0000000"+t).slice(-(e||2))}return function e(){var e=this.getUTCFullYear(),r="";if(e>9999)r="+"+t(e,6);else if(e<0)r="-"+t(-e,6);else r=t(e,4);return[r,t(this.getUTCMonth()+1),t(this.getUTCDate())].join("-")+"T"+[t(this.getUTCHours()),t(this.getUTCMinutes()),t(this.getUTCSeconds())].join(":")+"."+t(this.getUTCMilliseconds(),3)+"Z"}}();if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice)ArrayBuffer.prototype.slice=function(t,e){if(t==null)t=0;if(t<0){t+=this.byteLength;if(t<0)t=0}if(t>=this.byteLength)return new Uint8Array(0);if(e==null)e=this.byteLength;if(e<0){e+=this.byteLength;if(e<0)e=0}if(e>this.byteLength)e=this.byteLength;if(t>e)return new Uint8Array(0);var r=new ArrayBuffer(e-t);var i=new Uint8Array(r);var n=new Uint8Array(this,t,e-t);if(i.set)i.set(n);else while(t<=--e)i[e-t]=n[e];return r};if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=function(t,e){if(t==null)t=0;if(t<0){t+=this.length;if(t<0)t=0}if(t>=this.length)return new Uint8Array(0);if(e==null)e=this.length;if(e<0){e+=this.length;if(e<0)e=0}if(e>this.length)e=this.length;if(t>e)return new Uint8Array(0);var r=new Uint8Array(e-t);while(t<=--e)r[e-t]=this[e];return r};var IE_SaveFile=function(){try{if(typeof IE_SaveFile_Impl=="undefined")document.write(['