forked from sheetjs/sheetjs
		
	version bump 0.9.6
- new ExtendScript demo - Base64 shim improvements h/t @davidchambers @sheetjsdev - jszip improvements to support extendscript
This commit is contained in:
		
							parent
							
								
									1038400859
								
							
						
					
					
						commit
						471275b761
					
				| @ -101,6 +101,7 @@ The `demos` directory includes sample projects for: | ||||
| 
 | ||||
| - [`angular`](demos/angular/) | ||||
| - [`browserify`](demos/browserify/) | ||||
| - [`Adobe ExtendScript`](demos/extendscript/) | ||||
| - [`requirejs`](demos/requirejs/) | ||||
| - [`systemjs`](demos/systemjs/) | ||||
| - [`webpack`](demos/webpack/) | ||||
|  | ||||
| @ -1 +1 @@ | ||||
| XLSX.version = '0.9.5'; | ||||
| XLSX.version = '0.9.6'; | ||||
|  | ||||
							
								
								
									
										18
									
								
								demos/extendscript/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										18
									
								
								demos/extendscript/Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| APPS= aftereffects estoolkit illustrator indesign photoshop | ||||
| TARGETS=$(patsubst %,%.jsx,$(APPS)) | ||||
| 
 | ||||
| .PHONY: all | ||||
| all: deps $(TARGETS) | ||||
| 
 | ||||
| .PHONY: deps | ||||
| deps: | ||||
| 	cp ../../shim.js . | ||||
| 	cp ../../jszip.js . | ||||
| 	cp ../../xlsx.flow.js . | ||||
| 
 | ||||
| %.base: | ||||
| 	echo "#target $*" > $@ | ||||
| 
 | ||||
| .PHONY: $(TARGETS) | ||||
| $(TARGETS):%.jsx:%.base test.jsx | ||||
| 	cat $^ > $@ | ||||
							
								
								
									
										7
									
								
								demos/extendscript/README.md
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										7
									
								
								demos/extendscript/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| # ExtendScript demos | ||||
| 
 | ||||
| The main file is `test.jsx`.  Target-specific files prepend target directives. | ||||
| 
 | ||||
| Copy the `test.jsx` file as well as the `shim.js`, `jszip.js` and `xlsx.flow.js` | ||||
| files to wherever you want the scripts to reside.  The demo shows opening a file | ||||
| and converting to an array of arrays. | ||||
							
								
								
									
										1
									
								
								demos/extendscript/aftereffects.base
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/aftereffects.base
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #target aftereffects | ||||
							
								
								
									
										2
									
								
								demos/extendscript/aftereffects.jsx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								demos/extendscript/aftereffects.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #target aftereffects | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										1
									
								
								demos/extendscript/estoolkit.base
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/estoolkit.base
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #target estoolkit | ||||
							
								
								
									
										2
									
								
								demos/extendscript/estoolkit.jsx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								demos/extendscript/estoolkit.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #target estoolkit | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										1
									
								
								demos/extendscript/illustrator.base
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/illustrator.base
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #target illustrator | ||||
							
								
								
									
										2
									
								
								demos/extendscript/illustrator.jsx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								demos/extendscript/illustrator.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #target illustrator | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										1
									
								
								demos/extendscript/indesign.base
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/indesign.base
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #target indesign | ||||
							
								
								
									
										2
									
								
								demos/extendscript/indesign.jsx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								demos/extendscript/indesign.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #target indesign | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										1
									
								
								demos/extendscript/photoshop.base
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/photoshop.base
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| #target photoshop | ||||
							
								
								
									
										2
									
								
								demos/extendscript/photoshop.jsx
									
									
									
									
									
										Normal file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								demos/extendscript/photoshop.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| #target photoshop | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										
											BIN
										
									
								
								demos/extendscript/sheetjs.xlsx
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										
											BIN
										
									
								
								demos/extendscript/sheetjs.xlsx
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										1
									
								
								demos/extendscript/test.jsx
									
									
									
									
									
										Executable file
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								demos/extendscript/test.jsx
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1 @@ | ||||
| var thisFile = new File($.fileName);  
var basePath = thisFile.path;  
#include "shim.js";
#include "jszip.js";
#include "xlsx.flow.js";
var filename = "/sheetjs.xlsx";
var infile = File(basePath+filename);
infile.open("r");
infile.encoding = "binary";
var data = infile.read();
var workbook = XLSX.read(data, {type:"binary"});
var first_sheet_name = workbook.SheetNames[0];
var first_worksheet = workbook.Sheets[first_sheet_name];
var data = XLSX.utils.sheet_to_json(first_worksheet, {header:1});
alert(data); | ||||
							
								
								
									
										17
									
								
								dist/jszip.js
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										17
									
								
								dist/jszip.js
									
									
									
									
										vendored
									
									
								
							| @ -9,7 +9,18 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js | ||||
| JSZip uses the library pako released under the MIT license : | ||||
| https://github.com/nodeca/pako/blob/master/LICENSE
 | ||||
| */ | ||||
| !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSZip=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||||
| !function(e){ | ||||
| 	if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(); | ||||
| 	else if("function"==typeof define&&define.amd){JSZip=e();define([],e);} | ||||
| 	else{ | ||||
| 		if(typeof self == 'undefined' && typeof app != 'undefined') self = app; | ||||
| 		var f; | ||||
| 		"undefined"!=typeof window?f=window: | ||||
| 		"undefined"!=typeof global?f=global: | ||||
| 		"undefined"!=typeof $ && $.global?f=$.global: | ||||
| 		"undefined"!=typeof self&&(f=self),f.JSZip=e() | ||||
| 	} | ||||
| }(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||||
| 'use strict'; | ||||
| // private property
 | ||||
| var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||||
| @ -1005,10 +1016,6 @@ var generateZipParts = function(name, file, compressedObject, offset) { | ||||
|         date = o.date; | ||||
|     } | ||||
| 
 | ||||
|     // date
 | ||||
|     // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
 | ||||
|     // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
 | ||||
|     // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
 | ||||
| 
 | ||||
|     dosTime = date.getHours(); | ||||
|     dosTime = dosTime << 6; | ||||
|  | ||||
							
								
								
									
										30
									
								
								dist/xlsx.core.min.js
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										30
									
								
								dist/xlsx.core.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/xlsx.core.min.map
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								dist/xlsx.core.min.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										32
									
								
								dist/xlsx.full.min.js
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										32
									
								
								dist/xlsx.full.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/xlsx.full.min.map
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								dist/xlsx.full.min.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										165
									
								
								dist/xlsx.js
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										165
									
								
								dist/xlsx.js
									
									
									
									
										vendored
									
									
								
							| @ -5,7 +5,7 @@ | ||||
| /*exported XLSX */ | ||||
| var XLSX = {}; | ||||
| (function make_xlsx(XLSX){ | ||||
| XLSX.version = '0.9.5'; | ||||
| XLSX.version = '0.9.6'; | ||||
| var current_codepage = 1200, current_cptable; | ||||
| if(typeof module !== "undefined" && typeof require !== 'undefined') { | ||||
| 	if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel.js'); | ||||
| @ -425,7 +425,7 @@ function write_num_flt(type, fmt, val) { | ||||
| 	if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm(type, fmt, val); | ||||
| 	if(fmt.indexOf('%') !== -1) return write_num_pct(type, fmt, val); | ||||
| 	if(fmt.indexOf('E') !== -1) return write_num_exp(fmt, val); | ||||
| 	if(fmt.charCodeAt(0) === 36) return "$"+write_num_flt(type,fmt.substr(fmt[1]==' '?2:1),val); | ||||
| 	if(fmt.charCodeAt(0) === 36) return "$"+write_num_flt(type,fmt.substr(fmt.charAt(1)==' '?2:1),val); | ||||
| 	var o; | ||||
| 	var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : ""; | ||||
| 	if(fmt.match(/^00+$/)) return sign + pad0r(aval,fmt.length); | ||||
| @ -451,7 +451,7 @@ function write_num_flt(type, fmt, val) { | ||||
| 	if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/))) { | ||||
| 		o = _strrev(write_num_flt(type, fmt.replace(/[\\-]/g,""), val)); | ||||
| 		ri = 0; | ||||
| 		return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o[ri++]:x==='0'?'0':"";})); | ||||
| 		return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o.charAt(ri++):x==='0'?'0':"";})); | ||||
| 	} | ||||
| 	if(fmt.match(phone)) { | ||||
| 		o = write_num_flt(type, "##########", val); | ||||
| @ -463,7 +463,7 @@ function write_num_flt(type, fmt, val) { | ||||
| 		ff = frac(aval, Math.pow(10,ri)-1, false); | ||||
| 		o = "" + sign; | ||||
| 		oa = write_num("n", r[1], ff[1]); | ||||
| 		if(oa[oa.length-1] == " ") oa = oa.substr(0,oa.length-1) + "0"; | ||||
| 		if(oa.charAt(oa.length-1) == " ") oa = oa.substr(0,oa.length-1) + "0"; | ||||
| 		o += oa + r[2] + "/" + r[3]; | ||||
| 		oa = rpad_(ff[2],ri); | ||||
| 		if(oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length-oa.length)) + oa; | ||||
| @ -534,7 +534,7 @@ function write_num_int(type, fmt, val) { | ||||
| 	if(fmt.charCodeAt(fmt.length - 1) === 44) return write_num_cm2(type, fmt, val); | ||||
| 	if(fmt.indexOf('%') !== -1) return write_num_pct2(type, fmt, val); | ||||
| 	if(fmt.indexOf('E') !== -1) return write_num_exp2(fmt, val); | ||||
| 	if(fmt.charCodeAt(0) === 36) return "$"+write_num_int(type,fmt.substr(fmt[1]==' '?2:1),val); | ||||
| 	if(fmt.charCodeAt(0) === 36) return "$"+write_num_int(type,fmt.substr(fmt.charAt(1)==' '?2:1),val); | ||||
| 	var o; | ||||
| 	var r, ri, ff, aval = Math.abs(val), sign = val < 0 ? "-" : ""; | ||||
| 	if(fmt.match(/^00+$/)) return sign + pad0(aval,fmt.length); | ||||
| @ -562,7 +562,7 @@ return "." + $1 + fill("0", r[1].length-$1.length); }); | ||||
| 	if((r = fmt.match(/^([0#]+)(\\?-([0#]+))+$/))) { | ||||
| 		o = _strrev(write_num_int(type, fmt.replace(/[\\-]/g,""), val)); | ||||
| 		ri = 0; | ||||
| 		return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o[ri++]:x==='0'?'0':"";})); | ||||
| 		return _strrev(_strrev(fmt.replace(/\\/g,"")).replace(/[0#]/g,function(x){return ri<o.length?o.charAt(ri++):x==='0'?'0':"";})); | ||||
| 	} | ||||
| 	if(fmt.match(phone)) { | ||||
| 		o = write_num_int(type, "##########", val); | ||||
| @ -574,7 +574,7 @@ return "." + $1 + fill("0", r[1].length-$1.length); }); | ||||
| 		ff = frac(aval, Math.pow(10,ri)-1, false); | ||||
| 		o = "" + sign; | ||||
| 		oa = write_num("n", r[1], ff[1]); | ||||
| 		if(oa[oa.length-1] == " ") oa = oa.substr(0,oa.length-1) + "0"; | ||||
| 		if(oa.charAt(oa.length-1) == " ") oa = oa.substr(0,oa.length-1) + "0"; | ||||
| 		o += oa + r[2] + "/" + r[3]; | ||||
| 		oa = rpad_(ff[2],ri); | ||||
| 		if(oa.length < r[4].length) oa = hashq(r[4].substr(r[4].length-oa.length)) + oa; | ||||
| @ -823,7 +823,7 @@ out[i].v = write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0); | ||||
| 				j=out[i].v.indexOf(".")>-1&&i===decpt?out[i].v.indexOf(".")-1:out[i].v.length-1; | ||||
| 				vv = out[i].v.substr(j+1); | ||||
| 				for(; j>=0; --j) { | ||||
| 					if(jj>=0 && (out[i].v[j] === "0" || out[i].v[j] === "#")) vv = ostr[jj--] + vv; | ||||
| 					if(jj>=0 && (out[i].v.charAt(j) === "0" || out[i].v.charAt(j) === "#")) vv = ostr.charAt(jj--) + vv; | ||||
| 				} | ||||
| 				out[i].v = vv; | ||||
| 				out[i].t = 't'; | ||||
| @ -836,7 +836,7 @@ out[i].v = write_date(out[i].t.charCodeAt(0), out[i].v, dt, ss0); | ||||
| 				j=out[i].v.indexOf(".")>-1&&i===decpt?out[i].v.indexOf(".")+1:0; | ||||
| 				vv = out[i].v.substr(0,j); | ||||
| 				for(; j<out[i].v.length; ++j) { | ||||
| 					if(jj<ostr.length) vv += ostr[jj++]; | ||||
| 					if(jj<ostr.length) vv += ostr.charAt(jj++); | ||||
| 				} | ||||
| 				out[i].v = vv; | ||||
| 				out[i].t = 't'; | ||||
| @ -1353,6 +1353,18 @@ function datenum(v, date1904) { | ||||
| 	if(date1904) epoch += 1462*24*60*60*1000; | ||||
| 	return (epoch + 2209161600000) / (24 * 60 * 60 * 1000); | ||||
| } | ||||
| function numdate(v) { | ||||
| 	var date = SSF.parse_date_code(v); | ||||
| 	var val = new Date(); | ||||
| 	if(date == null) throw new Error("Bad Date Code: " + v); | ||||
| 	val.setUTCDate(date.d); | ||||
| 	val.setUTCMonth(date.m-1); | ||||
| 	val.setUTCFullYear(date.y); | ||||
| 	val.setUTCHours(date.H); | ||||
| 	val.setUTCMinutes(date.M); | ||||
| 	val.setUTCSeconds(date.S); | ||||
| 	return val; | ||||
| } | ||||
| 
 | ||||
| /* ISO 8601 Duration */ | ||||
| function parse_isodur(s) { | ||||
| @ -1601,7 +1613,7 @@ var vtregex = (function(){ var vt_cache = {}; | ||||
| 		if(vt_cache[bt] !== undefined) return vt_cache[bt]; | ||||
| 		return (vt_cache[bt] = new RegExp("<(?:vt:)?" + bt + ">(.*?)</(?:vt:)?" + bt + ">", 'g') ); | ||||
| };})(); | ||||
| var vtvregex = /<\/?(:?vt:)?variant>/g, vtmregex = /<(:?vt:)?([^>]*)>(.*)</; | ||||
| var vtvregex = /<\/?(?:vt:)?variant>/g, vtmregex = /<(?:vt:)([^>]*)>(.*)</; | ||||
| function parseVector(data) { | ||||
| 	var h = parsexmltag(data); | ||||
| 
 | ||||
| @ -1610,7 +1622,7 @@ function parseVector(data) { | ||||
| 	var res = []; | ||||
| 	matches.forEach(function(x) { | ||||
| 		var v = x.replace(vtvregex,"").match(vtmregex); | ||||
| 		res.push({v:v[2], t:v[1]}); | ||||
| 		res.push({v:utf8read(v[2]), t:v[1]}); | ||||
| 	}); | ||||
| 	return res; | ||||
| } | ||||
| @ -1997,6 +2009,42 @@ var make_offcrypto = function(O, _crypto) { | ||||
| }; | ||||
| make_offcrypto(OFFCRYPTO, typeof crypto !== "undefined" ? crypto : undefined); | ||||
| 
 | ||||
| function sheet_to_workbook(sheet, opts) { | ||||
| 	var n = opts && opts.sheet ? opts.sheet : "Sheet1"; | ||||
| 	var sheets = {}; sheets[n] = sheet; | ||||
| 	return { SheetNames: [n], Sheets: sheets }; | ||||
| } | ||||
| 
 | ||||
| function aoa_to_sheet(data, opts) { | ||||
| 	var o = opts || {}; | ||||
| 	var ws = ({}); | ||||
| 	var range = ({s: {c:10000000, r:10000000}, e: {c:0, r:0}}); | ||||
| 	for(var R = 0; R != data.length; ++R) { | ||||
| 		for(var C = 0; C != data[R].length; ++C) { | ||||
| 			if(typeof data[R][C] === 'undefined') continue; | ||||
| 			var cell = ({v: data[R][C] }); | ||||
| 			if(range.s.r > R) range.s.r = R; | ||||
| 			if(range.s.c > C) range.s.c = C; | ||||
| 			if(range.e.r < R) range.e.r = R; | ||||
| 			if(range.e.c < C) range.e.c = C; | ||||
| 			var cell_ref = encode_cell(({c:C,r:R})); | ||||
| 			if(cell.v === null) { if(!o.cellStubs) continue; cell.t = 'z'; } | ||||
| 			else if(typeof cell.v === 'number') cell.t = 'n'; | ||||
| 			else if(typeof cell.v === 'boolean') cell.t = 'b'; | ||||
| 			else if(cell.v instanceof Date) { | ||||
| 				cell.z = o.dateNF || SSF._table[14]; | ||||
| 				if(o.cellDates) cell.t = 'd'; | ||||
| 				else { cell.t = 'n'; cell.v = datenum(cell.v); } | ||||
| 				cell.w = SSF.format(cell.z, cell.v); | ||||
| 			} | ||||
| 			else cell.t = 's'; | ||||
| 			ws[cell_ref] = cell; | ||||
| 		} | ||||
| 	} | ||||
| 	if(range.s.c < 10000000) ws['!ref'] = encode_range(range); | ||||
| 	return ws; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /* [MS-XLSB] 2.5.143 */ | ||||
| function parse_StrRun(data, length) { | ||||
| @ -2924,14 +2972,30 @@ function parse_ext_props(data, p) { | ||||
| 
 | ||||
| 	if(q.HeadingPairs && q.TitlesOfParts) { | ||||
| 		var v = parseVector(q.HeadingPairs); | ||||
| 		var j = 0, widx = 0; | ||||
| 		var j = 0, widx = 0, cidx = -1; | ||||
| 		for(var i = 0; i !== v.length; ++i) { | ||||
| 			switch(v[i].v) { | ||||
| 				case "工作表": | ||||
| 				case "Листы": | ||||
| 				case "ワークシート": | ||||
| 				case "גליונות עבודה": | ||||
| 				case "Arbeitsblätter": | ||||
| 				case "Çalışma Sayfaları": | ||||
| 				case "Feuilles de calcul": | ||||
| 				case "Fogli di lavoro": | ||||
| 				case "Folhas de cálculo": | ||||
| 				case "Planilhas": | ||||
| 				case "Werkbladen": | ||||
| 				case "Worksheets": widx = j; p.Worksheets = +(v[++i].v); break; | ||||
| 
 | ||||
| 				case "Benannte Bereiche": | ||||
| 				case "Named Ranges": ++i; break; // TODO: Handle Named Ranges
 | ||||
| 
 | ||||
| 				case "Charts": cidx = j; p.Charts = +(v[++i].v); break; | ||||
| 				default: break; //throw new Error(v[i].v);
 | ||||
| 			} | ||||
| 		} | ||||
| 		var parts = parseVector(q.TitlesOfParts).map(function(x) { return utf8read(x.v); }); | ||||
| 		var parts = parseVector(q.TitlesOfParts).map(function(x) { return x.v; }); | ||||
| 		p.SheetNames = parts.slice(widx, widx + p.Worksheets); | ||||
| 	} | ||||
| 	return p; | ||||
| @ -5335,7 +5399,7 @@ function parse_numFmts(t, styles, opts) { | ||||
| 
 | ||||
| function write_numFmts(NF, opts) { | ||||
| 	var o = ["<numFmts>"]; | ||||
| 	[[5,8],[23,26],[41,44],[63,66],[164,392]].forEach(function(r) { | ||||
| 	[[5,8],[23,26],[41,44],[/*63*/50,/*66],[164,*/392]].forEach(function(r) { | ||||
| 		for(var i = r[0]; i <= r[1]; ++i) if(NF[i] != null) o[o.length] = (writextag('numFmt',null,{numFmtId:i,formatCode:escapexml(NF[i])})); | ||||
| 	}); | ||||
| 	if(o.length === 1) return ""; | ||||
| @ -6974,18 +7038,18 @@ function stringify_formula(formula/*Array<any>*/, range, cell, supbooks, opts) { | ||||
| 			/* 2.5.198.31 TODO */ | ||||
| 			case 'PtgAreaN': | ||||
| 				type = f[1][0]; r = shift_range_xls(f[1][1], _range, opts); | ||||
| 				stack.push(encode_range_xls(r, opts)); | ||||
| 				stack.push(encode_range_xls((r), opts)); | ||||
| 				break; | ||||
| 			/* 2.5.198.27 TODO: fixed points */ | ||||
| 			case 'PtgArea': | ||||
| 				type = f[1][0]; r = shift_range_xls(f[1][1], _range, opts); | ||||
| 				stack.push(encode_range_xls(r, opts)); | ||||
| 				stack.push(encode_range_xls((r), opts)); | ||||
| 				break; | ||||
| 			/* 2.5.198.28 */ | ||||
| 			case 'PtgArea3d': // TODO: lots of stuff
 | ||||
| 				type = f[1][0]; ixti = f[1][1]; r = f[1][2]; | ||||
| 				sname = (supbooks && supbooks[1] ? supbooks[1][ixti+1] : "**MISSING**"); | ||||
| 				stack.push(sname + "!" + encode_range(r)); | ||||
| 				stack.push(sname + "!" + encode_range((r))); | ||||
| 				break; | ||||
| 			/* 2.5.198.41 */ | ||||
| 			case 'PtgAttrSum': | ||||
| @ -10168,6 +10232,7 @@ function xlml_normalize(d) { | ||||
| var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/mg; | ||||
| //var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg;
 | ||||
| function parse_xlml_xml(d, opts) { | ||||
| 	make_ssf(SSF); | ||||
| 	var str = debom(xlml_normalize(d)); | ||||
| 	if(opts && opts.type == 'binary' && typeof cptable !== 'undefined') str = cptable.utils.decode(65001, char_codes(str)); | ||||
| 	if(str.substr(0,1000).indexOf("<html") >= 0) return parse_html(str, opts); | ||||
| @ -10277,7 +10342,10 @@ for(var cma = c; cma <= cc; ++cma) { | ||||
| 			break; | ||||
| 
 | ||||
| 		case 'NumberFormat': | ||||
| 			stag.nf = xlml_parsexmltag(Rn[0]).Format || "General"; | ||||
| 			stag.nf = unescapexml(xlml_parsexmltag(Rn[0]).Format || "General"); | ||||
| 			if(XLMLFormatMap[stag.nf]) stag.nf = XLMLFormatMap[stag.nf]; | ||||
| 			for(var ssfidx = 0; ssfidx != 0x188; ++ssfidx) if(SSF._table[ssfidx] == stag.nf) break; | ||||
| 			if(ssfidx == 0x188) for(ssfidx = 0x39; ssfidx != 0x188; ++ssfidx) if(SSF._table[ssfidx] == null) { SSF.load(stag.nf, ssfidx); break; } | ||||
| 			break; | ||||
| 
 | ||||
| 		case 'Column': | ||||
| @ -10953,7 +11021,7 @@ function parse_workbook(blob, options) { | ||||
| 	var out = {}; | ||||
| 	var Directory = {}; | ||||
| 	var found_sheet = false; | ||||
| 	var range = {}; | ||||
| 	var range = ({}); | ||||
| 	var last_formula = null; | ||||
| 	var sst = []; | ||||
| 	var cur_sheet = ""; | ||||
| @ -13914,9 +13982,7 @@ function writeSync(wb, opts) { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| function writeFileSync(wb, filename, opts) { | ||||
| 	var o = opts||{}; o.type = 'file'; | ||||
| 	o.file = filename; | ||||
| function resolve_book_type(o/*?WriteFileOpts*/) { | ||||
| 	if(!o.bookType) switch(o.file.slice(-5).toLowerCase()) { | ||||
| 		case '.xlsx': o.bookType = 'xlsx'; break; | ||||
| 		case '.xlsm': o.bookType = 'xlsm'; break; | ||||
| @ -13929,9 +13995,23 @@ function writeFileSync(wb, filename, opts) { | ||||
| 		case '.ods': o.bookType = 'ods'; break; | ||||
| 		case '.csv': o.bookType = 'csv'; break; | ||||
| 	}} | ||||
| } | ||||
| 
 | ||||
| function writeFileSync(wb, filename, opts) { | ||||
| 	var o = opts||{}; o.type = 'file'; | ||||
| 	o.file = filename; | ||||
| 	resolve_book_type(o); | ||||
| 	return writeSync(wb, o); | ||||
| } | ||||
| 
 | ||||
| function writeFileAsync(filename, wb, opts, cb) { | ||||
| 	var o = opts||{}; o.type = 'file'; | ||||
| 	o.file = filename; | ||||
| 	resolve_book_type(o); | ||||
| 	o.type = 'buffer'; | ||||
| 	var _cb = cb; if(!(_cb instanceof Function)) _cb = (opts); | ||||
| 	return _fs.writeFile(filename, writeSync(wb, o), _cb); | ||||
| } | ||||
| function decode_row(rowstr) { return parseInt(unfix_row(rowstr),10) - 1; } | ||||
| function encode_row(row) { return "" + (row + 1); } | ||||
| function fix_row(cstr) { return cstr.replace(/([A-Z]|^)(\d+)$/,"$1$$$2"); } | ||||
| @ -13999,14 +14079,15 @@ function format_cell(cell, v, o) { | ||||
| 	if(cell == null || cell.t == null || cell.t == 'z') return ""; | ||||
| 	if(cell.w !== undefined) return cell.w; | ||||
| 	if(cell.t == 'd' && !cell.z && o && o.dateNF) cell.z = o.dateNF; | ||||
| 	if(v == undefined) return safe_format_cell(cell, cell.v); | ||||
| 	return safe_format_cell(cell, v); | ||||
| 	if(v == undefined) return safe_format_cell(cell, cell.v, o); | ||||
| 	return safe_format_cell(cell, v, o); | ||||
| } | ||||
| 
 | ||||
| function sheet_to_json(sheet, opts){ | ||||
| 	var val, row, range, header = 0, offset = 1, r, hdr = [], isempty, R, C, v, vv; | ||||
| 	var o = opts != null ? opts : {}; | ||||
| 	var raw = o.raw; | ||||
| 	var defval = o.defval; | ||||
| 	if(sheet == null || sheet["!ref"] == null) return []; | ||||
| 	range = o.range != null ? o.range : sheet["!ref"]; | ||||
| 	if(o.header === 1) header = 1; | ||||
| @ -14031,7 +14112,7 @@ function sheet_to_json(sheet, opts){ | ||||
| 			case 3: hdr[C] = o.header[C - r.s.c]; break; | ||||
| 			default: | ||||
| 				if(val == null) continue; | ||||
| 				vv = v = format_cell(val); | ||||
| 				vv = v = format_cell(val, null, o); | ||||
| 				var counter = 0; | ||||
| 				for(var CC = 0; CC < hdr.length; ++CC) if(hdr[CC] == vv) vv = v + "_" + (++counter); | ||||
| 				hdr[C] = vv; | ||||
| @ -14049,27 +14130,35 @@ function sheet_to_json(sheet, opts){ | ||||
| 		} | ||||
| 		for (C = r.s.c; C <= r.e.c; ++C) { | ||||
| 			val = sheet[cols[C] + rr]; | ||||
| 			if(val === undefined || val.t === undefined) continue; | ||||
| 			if(val === undefined || val.t === undefined) { | ||||
| 				if(defval === undefined) continue; | ||||
| 				if(hdr[C] != null) { row[hdr[C]] = defval; isempty = false; } | ||||
| 				continue; | ||||
| 			} | ||||
| 			v = val.v; | ||||
| 			switch(val.t){ | ||||
| 				case 'z': continue; | ||||
| 				case 'z': if(v == null) break; continue; | ||||
| 				case 'e': continue; | ||||
| 				case 's': case 'd': case 'b': case 'n': break; | ||||
| 				default: throw new Error('unrecognized type ' + val.t); | ||||
| 			} | ||||
| 			if(v !== undefined) { | ||||
| 				row[hdr[C]] = raw ? v : format_cell(val,v); | ||||
| 			if(hdr[C] != null) { | ||||
| 				if(v == null) { | ||||
| 					if(defval !== undefined) row[hdr[C]] = defval; | ||||
| 					else if(raw && v === null) row[hdr[C]] = null; | ||||
| 					else continue; | ||||
| 				} else { | ||||
| 					row[hdr[C]] = raw ? v : format_cell(val,v,o); | ||||
| 				} | ||||
| 				isempty = false; | ||||
| 			} | ||||
| 		} | ||||
| 		if(isempty === false || header === 1) out[outi++] = row; | ||||
| 		if((isempty === false) || (header === 1 ? o.blankrows !== false : !!o.blankrows)) out[outi++] = row; | ||||
| 	} | ||||
| 	out.length = outi; | ||||
| 	return out; | ||||
| } | ||||
| 
 | ||||
| function sheet_to_row_object_array(sheet, opts) { return sheet_to_json(sheet, opts != null ? opts : {}); } | ||||
| 
 | ||||
| function sheet_to_csv(sheet, opts) { | ||||
| 	var out = "", txt = "", qreg = /"/g; | ||||
| 	var o = opts == null ? {} : opts; | ||||
| @ -14077,27 +14166,31 @@ function sheet_to_csv(sheet, opts) { | ||||
| 	var r = safe_decode_range(sheet["!ref"]); | ||||
| 	var FS = o.FS !== undefined ? o.FS : ",", fs = FS.charCodeAt(0); | ||||
| 	var RS = o.RS !== undefined ? o.RS : "\n", rs = RS.charCodeAt(0); | ||||
| 	var endregex = new RegExp(FS+"+$"); | ||||
| 	var endregex = new RegExp((FS=="|" ? "\\|" : FS)+"+$"); | ||||
| 	var row = "", rr = "", cols = []; | ||||
| 	var i = 0, cc = 0, val; | ||||
| 	var R = 0, C = 0; | ||||
| 	for(C = r.s.c; C <= r.e.c; ++C) cols[C] = encode_col(C); | ||||
| 	for(R = r.s.r; R <= r.e.r; ++R) { | ||||
| 		var isempty = true; | ||||
| 		row = ""; | ||||
| 		rr = encode_row(R); | ||||
| 		for(C = r.s.c; C <= r.e.c; ++C) { | ||||
| 			val = sheet[cols[C] + rr]; | ||||
| 			if(val == null) txt = ""; | ||||
| 			else if(val.v != null) { | ||||
| 				txt = ''+format_cell(val); | ||||
| 				isempty = false; | ||||
| 				txt = ''+format_cell(val, null, o); | ||||
| 				for(i = 0, cc = 0; i !== txt.length; ++i) if((cc = txt.charCodeAt(i)) === fs || cc === rs || cc === 34) { | ||||
| 					txt = "\"" + txt.replace(qreg, '""') + "\""; break; } | ||||
| 			} else if(val.f != null && !val.F) { | ||||
| 				isempty = false; | ||||
| 				txt = '=' + val.f; if(txt.indexOf(",") >= 0) txt = '"' + txt.replace(qreg, '""') + '"'; | ||||
| 			} else txt = ""; | ||||
| 			/* NOTE: Excel CSV does not support array formulae */ | ||||
| 			row += (C === r.s.c ? "" : FS) + txt; | ||||
| 		} | ||||
| 		if(o.blankrows === false && isempty) continue; | ||||
| 		if(o.strip) row = row.replace(endregex,""); | ||||
| 		out += row + RS; | ||||
| 	} | ||||
| @ -14155,10 +14248,11 @@ var utils = { | ||||
| 	make_csv: sheet_to_csv, | ||||
| 	make_json: sheet_to_json, | ||||
| 	make_formulae: sheet_to_formulae, | ||||
| 	aoa_to_sheet: aoa_to_sheet, | ||||
| 	sheet_to_csv: sheet_to_csv, | ||||
| 	sheet_to_json: sheet_to_json, | ||||
| 	sheet_to_formulae: sheet_to_formulae, | ||||
| 	sheet_to_row_object_array: sheet_to_row_object_array | ||||
| 	sheet_to_row_object_array: sheet_to_json | ||||
| }; | ||||
| XLSX.parse_xlscfb = parse_xlscfb; | ||||
| XLSX.parse_ods = parse_ods; | ||||
| @ -14171,6 +14265,7 @@ XLSX.readFileSync = readFileSync; | ||||
| XLSX.write = writeSync; | ||||
| XLSX.writeFile = writeFileSync; | ||||
| XLSX.writeFileSync = writeFileSync; | ||||
| XLSX.writeFileAsync = writeFileAsync; | ||||
| XLSX.utils = utils; | ||||
| XLSX.CFB = CFB; | ||||
| XLSX.SSF = SSF; | ||||
|  | ||||
							
								
								
									
										24
									
								
								dist/xlsx.min.js
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										24
									
								
								dist/xlsx.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/xlsx.min.map
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								dist/xlsx.min.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -27,6 +27,7 @@ The `demos` directory includes sample projects for: | ||||
| 
 | ||||
| - [`angular`](demos/angular/) | ||||
| - [`browserify`](demos/browserify/) | ||||
| - [`Adobe ExtendScript`](demos/extendscript/) | ||||
| - [`requirejs`](demos/requirejs/) | ||||
| - [`systemjs`](demos/systemjs/) | ||||
| - [`webpack`](demos/webpack/) | ||||
|  | ||||
							
								
								
									
										13
									
								
								jszip.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										13
									
								
								jszip.js
									
									
									
									
									
								
							| @ -9,7 +9,18 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js | ||||
| JSZip uses the library pako released under the MIT license : | ||||
| https://github.com/nodeca/pako/blob/master/LICENSE
 | ||||
| */ | ||||
| !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd){JSZip=e();define([],e);}else{if(typeof self == 'undefined' && typeof app != 'undefined') self = app;var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSZip=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||||
| !function(e){ | ||||
| 	if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(); | ||||
| 	else if("function"==typeof define&&define.amd){JSZip=e();define([],e);} | ||||
| 	else{ | ||||
| 		if(typeof self == 'undefined' && typeof app != 'undefined') self = app; | ||||
| 		var f; | ||||
| 		"undefined"!=typeof window?f=window: | ||||
| 		"undefined"!=typeof global?f=global: | ||||
| 		"undefined"!=typeof $ && $.global?f=$.global: | ||||
| 		"undefined"!=typeof self&&(f=self),f.JSZip=e() | ||||
| 	} | ||||
| }(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||||
| 'use strict'; | ||||
| // private property
 | ||||
| var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| { | ||||
| 	"name": "xlsx", | ||||
| 	"version": "0.9.5", | ||||
| 	"version": "0.9.6", | ||||
| 	"author": "sheetjs", | ||||
| 	"description": "Excel (XLSB/XLSX/XLSM/XLS/XML) and ODS (ODS/FODS/UOS) spreadsheet parser and writer", | ||||
| 	"keywords": [ "excel", "xls", "xlsx", "xlsb", "xlsm", "ods", "office", "spreadsheet" ], | ||||
|  | ||||
							
								
								
									
										10
									
								
								shim.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										10
									
								
								shim.js
									
									
									
									
									
								
							| @ -239,10 +239,13 @@ if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) { | ||||
| // https://github.com/davidchambers/Base64.js
 | ||||
| // (C) 2015 David Chambers
 | ||||
| // Base64.js may be freely distributed under the Apache 2.0 License.
 | ||||
| 
 | ||||
| ;(function () { | ||||
| 
 | ||||
|   var object = typeof exports != 'undefined' ? exports : typeof self != 'undefined' ? self : (1,eval)("this"); | ||||
|   var object = | ||||
|     typeof exports != 'undefined' ? exports : | ||||
|     typeof self != 'undefined' ? self : // #8: web workers
 | ||||
|     $.global; // #31: ExtendScript
 | ||||
| 
 | ||||
|   var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||||
| 
 | ||||
|   function InvalidCharacterError(message) { | ||||
| @ -279,7 +282,7 @@ if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) { | ||||
|   // [https://gist.github.com/1020396] by [https://github.com/atk]
 | ||||
|   object.atob || ( | ||||
|   object.atob = function (input) { | ||||
|     var str = String(input).replace(new RegExp("=+$"), ''); | ||||
|     var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
 | ||||
|     if (str.length % 4 == 1) { | ||||
|       throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); | ||||
|     } | ||||
| @ -299,7 +302,6 @@ if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) { | ||||
|     } | ||||
|     return output; | ||||
|   }); | ||||
|   if(typeof app != 'undefined') { app.btoa = object.btoa; app.atob = object.atob; } | ||||
| }()); | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										146
									
								
								tests/core.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										146
									
								
								tests/core.js
									
									
									
									
									
								
							| @ -639,6 +639,31 @@ describe('parse features', function() { | ||||
| 		}); | ||||
| 	}); | ||||
| 
 | ||||
| 	describe('cellDates', function() { | ||||
| 		var fmts = [ | ||||
| 			/* desc     path        sheet     cell   formatted */ | ||||
| 			['XLSX', paths.dtxlsx, 'Sheet1',  'B5',  '2/14/14'], | ||||
| 			['XLSB', paths.dtxlsb, 'Sheet1',  'B5',  '2/14/14'], | ||||
| 			['XLS',  paths.dtxls,  'Sheet1',  'B5',  '2/14/14'], | ||||
| 			['XLML', paths.dtxml,  'Sheet1',  'B5',  '2/14/14'], | ||||
| 			['XLSM', paths.nfxlsx, 'Implied', 'B13', '18-Oct-33'] | ||||
| 		]; | ||||
| 		it('should not generate date cells by default', function() { fmts.forEach(function(f) { | ||||
| 			var wb, ws; | ||||
| 			wb = X.read(fs.readFileSync(f[1]), {type:"binary"}); | ||||
| 			ws = wb.Sheets[f[2]]; | ||||
| 			assert.equal(ws[f[3]].w, f[4]); | ||||
| 			assert.equal(ws[f[3]].t, 'n'); | ||||
| 		}); }); | ||||
| 		it('should generate date cells if cellDates is true', function() { fmts.forEach(function(f) { | ||||
| 			var wb, ws; | ||||
| 			wb = X.read(fs.readFileSync(f[1]), {type:"binary", cellDates:true}); | ||||
| 			ws = wb.Sheets[f[2]]; | ||||
| 			assert.equal(ws[f[3]].w, f[4]); | ||||
| 			assert.equal(ws[f[3]].t, 'd'); | ||||
| 		}); }); | ||||
| 	}); | ||||
| 
 | ||||
| 	describe('should correctly handle styles', function() { | ||||
| 		var wsxls, wsxlsx, rn, rn2; | ||||
| 		var bef = (function() { | ||||
| @ -858,33 +883,6 @@ function datenum(v/*:Date*/, date1904/*:?boolean*/)/*:number*/ { | ||||
| 	if(date1904) epoch += 1462*24*60*60*1000; | ||||
| 	return (epoch + 2209161600000) / (24 * 60 * 60 * 1000); | ||||
| } | ||||
| function sheet_from_array_of_arrays(data, opts) { | ||||
| 	var ws = {}; | ||||
| 	var range = {s: {c:10000000, r:10000000}, e: {c:0, r:0 }}; | ||||
| 	for(var R = 0; R != data.length; ++R) { | ||||
| 		for(var C = 0; C != data[R].length; ++C) { | ||||
| 			if(range.s.r > R) range.s.r = R; | ||||
| 			if(range.s.c > C) range.s.c = C; | ||||
| 			if(range.e.r < R) range.e.r = R; | ||||
| 			if(range.e.c < C) range.e.c = C; | ||||
| 			var cell = {v: data[R][C] }; | ||||
| 			if(cell.v == null) continue; | ||||
| 			var cell_ref = X.utils.encode_cell({c:C,r:R}); | ||||
| 			if(typeof cell.v === 'number') cell.t = 'n'; | ||||
| 			else if(typeof cell.v === 'boolean') cell.t = 'b'; | ||||
| 			else if(cell.v instanceof Date) { | ||||
| 				cell.z = X.SSF._table[14]; | ||||
| 				if(opts && opts.cellDates) cell.t = 'd'; | ||||
| 				else { cell.t = 'n'; cell.v = datenum(cell.v); } | ||||
| 			} | ||||
| 			else cell.t = 's'; | ||||
| 			ws[cell_ref] = cell; | ||||
| 		} | ||||
| 	} | ||||
| 	if(range.s.c < 10000000) ws['!ref'] = X.utils.encode_range(range); | ||||
| 	return ws; | ||||
| } | ||||
| 
 | ||||
| var good_pd_date = new Date('2017-02-19T19:06:09.000Z'); | ||||
| var good_pd = good_pd_date.getFullYear() == 2017; | ||||
| function parseDate(str/*:string|Date*/)/*:Date*/ { | ||||
| @ -908,9 +906,9 @@ describe('json output', function() { | ||||
| 			[1,2,3], | ||||
| 			[true, false, null, "sheetjs"], | ||||
| 			["foo","bar", parseDate("2014-02-19T14:30:00.000Z"), "0.3"], | ||||
| 			["baz", null, "qux"] | ||||
| 			["baz", undefined, "qux"] | ||||
| 		]; | ||||
| 		ws = sheet_from_array_of_arrays(data); | ||||
| 		ws = X.utils.aoa_to_sheet(data); | ||||
| 	}); | ||||
| 	if(typeof before != 'undefined') before(bef); | ||||
| 	else it('before', bef); | ||||
| @ -965,9 +963,22 @@ describe('json output', function() { | ||||
| 			assert.throws(function() { seeker(json, [0,1,2], "baz"); }); | ||||
| 		}); | ||||
| 	}); | ||||
| 	it('should use defval if requested', function() { | ||||
| 		var json = X.utils.sheet_to_json(ws, {defval: 'jimjin'}); | ||||
| 		assert.equal(json.length, data.length - 1); | ||||
| 		assert.equal(json[0][1], "TRUE"); | ||||
| 		assert.equal(json[1][2], "bar"); | ||||
| 		assert.equal(json[2][3], "qux"); | ||||
| 		assert.equal(json[2][2], "jimjin"); | ||||
| 		assert.equal(json[0][3], "jimjin"); | ||||
| 		assert.doesNotThrow(function() { seeker(json, [1,2,3], "sheetjs"); }); | ||||
| 		assert.throws(function() { seeker(json, [1,2,3], "baz"); }); | ||||
| 		var json = X.utils.sheet_to_json(ws, {raw:true}); | ||||
| 		var json = X.utils.sheet_to_json(ws, {raw:true, defval: 'jimjin'}); | ||||
| 	}); | ||||
| 	it('should disambiguate headers', function() { | ||||
| 		var _data = [["S","h","e","e","t","J","S"],[1,2,3,4,5,6,7],[2,3,4,5,6,7,8]]; | ||||
| 		var _ws = sheet_from_array_of_arrays(_data); | ||||
| 		var _ws = X.utils.aoa_to_sheet(_data); | ||||
| 		var json = X.utils.sheet_to_json(_ws); | ||||
| 		for(var i = 0; i < json.length; ++i) { | ||||
| 			assert.equal(json[i].S,   1 + i); | ||||
| @ -980,14 +991,81 @@ describe('json output', function() { | ||||
| 		} | ||||
| 	}); | ||||
| 	it('should handle raw data if requested', function() { | ||||
| 		var _ws = sheet_from_array_of_arrays(data, {cellDates:true}); | ||||
| 		var _ws = X.utils.aoa_to_sheet(data, {cellDates:true}); | ||||
| 		var json = X.utils.sheet_to_json(_ws, {header:1, raw:true}); | ||||
| 		assert.equal(json.length, data.length); | ||||
| 		assert.equal(json[1][0], true); | ||||
| 		assert.equal(json[1][2], null); | ||||
| 		assert.equal(json[2][1], "bar"); | ||||
| 		assert.equal(json[2][2].getTime(), parseDate("2014-02-19T14:30:00.000Z").getTime()); | ||||
| 		assert.equal(json[3][2], "qux"); | ||||
| 	}); | ||||
| 	it('should include __rowNum__', function() { | ||||
| 		var _data = [["S","h","e","e","t","J","S"],[1,2,3,4,5,6,7],[],[2,3,4,5,6,7,8]]; | ||||
| 		var _ws = X.utils.aoa_to_sheet(_data); | ||||
| 		var json = X.utils.sheet_to_json(_ws); | ||||
| 		assert.equal(json[0].__rowNum__, 1); | ||||
| 		assert.equal(json[1].__rowNum__, 3); | ||||
| 	}); | ||||
| 	it('should handle blankrows', function() { | ||||
| 		var _data = [["S","h","e","e","t","J","S"],[1,2,3,4,5,6,7],[],[2,3,4,5,6,7,8]]; | ||||
| 		var _ws = X.utils.aoa_to_sheet(_data); | ||||
| 		var json1 = X.utils.sheet_to_json(_ws); | ||||
| 		var json2 = X.utils.sheet_to_json(_ws, {header:1}); | ||||
| 		var json3 = X.utils.sheet_to_json(_ws, {blankrows:true}); | ||||
| 		var json4 = X.utils.sheet_to_json(_ws, {blankrows:true, header:1}); | ||||
| 		var json5 = X.utils.sheet_to_json(_ws, {blankrows:false}); | ||||
| 		var json6 = X.utils.sheet_to_json(_ws, {blankrows:false, header:1}); | ||||
| 		assert.equal(json1.length, 2); // = 2 non-empty records
 | ||||
| 		assert.equal(json2.length, 4); // = 4 sheet rows
 | ||||
| 		assert.equal(json3.length, 3); // = 2 records + 1 blank row
 | ||||
| 		assert.equal(json4.length, 4); // = 4 sheet rows
 | ||||
| 		assert.equal(json5.length, 2); // = 2 records
 | ||||
| 		assert.equal(json6.length, 3); // = 4 sheet rows - 1 blank row
 | ||||
| 	}); | ||||
| }); | ||||
| 
 | ||||
| describe('csv output', function() { | ||||
| 	var data, ws; | ||||
| 	var bef = (function() { | ||||
| 		data = [ | ||||
| 			[1,2,3,null], | ||||
| 			[true, false, null, "sheetjs"], | ||||
| 			["foo", "bar", parseDate("2014-02-19T14:30:00.000Z"), "0.3"], | ||||
| 			[null, null, null], | ||||
| 			["baz", undefined, "qux"] | ||||
| 		]; | ||||
| 		ws = X.utils.aoa_to_sheet(data); | ||||
| 	}); | ||||
| 	if(typeof before != 'undefined') before(bef); | ||||
| 	else it('before', bef); | ||||
| 	it('should generate csv', function() { | ||||
| 		var baseline = "1,2,3,\nTRUE,FALSE,,sheetjs\nfoo,bar,2/19/14,0.3\n,,,\nbaz,,qux,\n"; | ||||
| 		assert.equal(baseline, X.utils.sheet_to_csv(ws)); | ||||
| 	}); | ||||
| 	it('should handle FS', function() { | ||||
| 		assert.equal(X.utils.sheet_to_csv(ws, {FS:"|"}).replace(/[|]/g,","), X.utils.sheet_to_csv(ws)); | ||||
| 		assert.equal(X.utils.sheet_to_csv(ws, {FS:";"}).replace(/[;]/g,","), X.utils.sheet_to_csv(ws)); | ||||
| 	}); | ||||
| 	it('should handle RS', function() { | ||||
| 		assert.equal(X.utils.sheet_to_csv(ws, {RS:"|"}).replace(/[|]/g,"\n"), X.utils.sheet_to_csv(ws)); | ||||
| 		assert.equal(X.utils.sheet_to_csv(ws, {RS:";"}).replace(/[;]/g,"\n"), X.utils.sheet_to_csv(ws)); | ||||
| 	}); | ||||
| 	it('should handle dateNF', function() { | ||||
| 		var baseline = "1,2,3,\nTRUE,FALSE,,sheetjs\nfoo,bar,20140219,0.3\n,,,\nbaz,,qux,\n"; | ||||
| 		var _ws =  X.utils.aoa_to_sheet(data, {cellDates:true}); | ||||
| 		delete _ws.C3.w; | ||||
| 		delete _ws.C3.z; | ||||
| 		assert.equal(baseline, X.utils.sheet_to_csv(_ws, {dateNF:"YYYYMMDD"})); | ||||
| 	}); | ||||
| 	it('should handle strip', function() { | ||||
| 		var baseline = "1,2,3\nTRUE,FALSE,,sheetjs\nfoo,bar,2/19/14,0.3\n\nbaz,,qux\n"; | ||||
| 		assert.equal(baseline, X.utils.sheet_to_csv(ws, {strip:true})); | ||||
| 	}); | ||||
| 	it('should handle blankrows', function() { | ||||
| 		var baseline = "1,2,3,\nTRUE,FALSE,,sheetjs\nfoo,bar,2/19/14,0.3\nbaz,,qux,\n"; | ||||
| 		assert.equal(baseline, X.utils.sheet_to_csv(ws, {blankrows:false})); | ||||
| 	}); | ||||
| }); | ||||
| 
 | ||||
| describe('js -> file -> js', function() { | ||||
| @ -999,7 +1077,7 @@ describe('js -> file -> js', function() { | ||||
| 			["foo","bar", parseDate("2014-02-19T14:30:00.000Z"), "0.3"], | ||||
| 			["baz", 6.9, "qux"] | ||||
| 		]; | ||||
| 		ws = sheet_from_array_of_arrays(data); | ||||
| 		ws = X.utils.aoa_to_sheet(data); | ||||
| 		wb = { SheetNames: ['Sheet1'], Sheets: {Sheet1: ws} }; | ||||
| 	}); | ||||
| 	if(typeof before != 'undefined') before(bef); | ||||
| @ -1038,10 +1116,10 @@ describe('corner cases', function() { | ||||
| 		var data = [ | ||||
| 			[1,2,3], | ||||
| 			[true, false, null, "sheetjs"], | ||||
| 			["foo","bar", parseDate("2014-02-19T14:30Z"), "0.3"], | ||||
| 			["foo","bar", parseDate("2014-02-19T14:30:00.000Z"), "0.3"], | ||||
| 			["baz", null, "q\"ux"] | ||||
| 		]; | ||||
| 		var ws = sheet_from_array_of_arrays(data); | ||||
| 		var ws = X.utils.aoa_to_sheet(data); | ||||
| 		ws.A1.f = ""; ws.A1.w = ""; | ||||
| 		delete ws.C3.w; delete ws.C3.z; ws.C3.XF = {ifmt:14}; | ||||
| 		ws.A4.t = "e"; | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
| /*exported XLSX */ | ||||
| var XLSX = {}; | ||||
| (function make_xlsx(XLSX){ | ||||
| XLSX.version = '0.9.5'; | ||||
| XLSX.version = '0.9.6'; | ||||
| var current_codepage = 1200, current_cptable; | ||||
| /*:: declare var cptable:any; */ | ||||
| if(typeof module !== "undefined" && typeof require !== 'undefined') { | ||||
|  | ||||
							
								
								
									
										2
									
								
								xlsx.js
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										2
									
								
								xlsx.js
									
									
									
									
									
								
							| @ -5,7 +5,7 @@ | ||||
| /*exported XLSX */ | ||||
| var XLSX = {}; | ||||
| (function make_xlsx(XLSX){ | ||||
| XLSX.version = '0.9.5'; | ||||
| XLSX.version = '0.9.6'; | ||||
| var current_codepage = 1200, current_cptable; | ||||
| if(typeof module !== "undefined" && typeof require !== 'undefined') { | ||||
| 	if(typeof cptable === 'undefined') cptable = require('./dist/cpexcel.js'); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user