Socket
Socket
Sign inDemoInstall

xlsx

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xlsx - npm Package Compare versions

Comparing version 0.5.17 to 0.6.0

bits/01_version.js

2

bits/00_header.js
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*jshint eqnull:true */
var XLSX = {};
(function(XLSX){

1

bits/10_ssf.js

@@ -1,2 +0,1 @@

/* Spreadsheet Format -- jump to XLSX for the XLSX code */
/* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */

@@ -3,0 +2,0 @@ var SSF = {};

@@ -1,2 +0,2 @@

var current_codepage, current_cptable, cptable;
var current_codepage, current_cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {

@@ -3,0 +3,0 @@ if(typeof cptable === 'undefined') cptable = require('codepage');

@@ -70,3 +70,3 @@ var attregexg=/([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g;

// matches <foo>...</foo> extracts content
function matchtag(f,g) {return new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?>([^\u2603]*)</(?:\\w+:)?'+f+'>',(g||"")+"m");}
function matchtag(f,g) {return new RegExp('<(?:\\w+:)?'+f+'(?: xml:space="preserve")?(?:[^>]*)>([^\u2603]*)</(?:\\w+:)?'+f+'>',(g||"")+"m");}

@@ -73,0 +73,0 @@ function parseVector(data) {

@@ -277,3 +277,3 @@ /* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */

var rels = {};
var hash = {};
var resolveRelativePathIntoAbsolute = function (to) {

@@ -300,7 +300,8 @@ var toksFrom = currentFilePath.split('/');

var rel = {}; rel.Type = y.Type; rel.Target = y.Target; rel.Id = y.Id; rel.TargetMode = y.TargetMode;
var canonictarget = resolveRelativePathIntoAbsolute(y.Target);
var canonictarget = y.TargetMode === 'External' ? y.Target : resolveRelativePathIntoAbsolute(y.Target);
rels[canonictarget] = rel;
hash[y.Id] = rel;
}
});
rels["!id"] = hash;
return rels;

@@ -307,0 +308,0 @@ }

/* 18.3 Worksheets */
function parse_ws_xml(data, opts) {
function parse_ws_xml(data, opts, rels) {
if(!data) return data;

@@ -90,2 +90,21 @@ /* 18.3.1.99 worksheet CT_Worksheet */

});
/* 18.3.1.48 hyperlinks CT_Hyperlinks */
if(data.match(/<\/hyperlinks>/)) data.match(/<hyperlink[^>]*\/>/g).forEach(function(h) {
var val = parsexmltag(h); delete val[0];
if(!val.ref) return;
var rel = rels['!id'][val.id];
if(rel) {
val.Target = rel.Target;
if(val.location) val.Target += "#"+val.location;
val.Rel = rel;
}
var rng = decode_range(val.ref);
for(var R=rng.s.r;R<=rng.e.r;++R) for(var C=rng.s.c;C<=rng.e.c;++C) {
var addr = encode_cell({c:C,r:R});
if(!s[addr]) s[addr] = {t:"str",v:undefined};
s[addr].l = val;
}
});
if(!s["!ref"] && refguess.e.c >= refguess.s.c && refguess.e.r >= refguess.s.r) s["!ref"] = encode_range(refguess);

@@ -92,0 +111,0 @@ if(opts.sheetRows && s["!ref"]) {

@@ -126,5 +126,18 @@

/* [MS-XLSB] 2.4.656 BrtHLink */
var parse_BrtHLink = function(data, length, opts) {
var end = data.l + length;
var rfx = parse_UncheckedRfX(data, 16);
var relId = parse_XLNullableWideString(data);
var loc = parse_XLWideString(data);
var tooltip = parse_XLWideString(data);
var display = parse_XLWideString(data);
data.l = end;
return {rfx:rfx, relId:relId, loc:loc, tooltip:tooltip, display:display};
};
/* [MS-XLSB] 2.1.7.61 Worksheet */
var parse_ws_bin = function(data, opts) {
var parse_ws_bin = function(data, opts, rels) {
if(!data) return data;
if(!rels) rels = {'!id':{}};
var s = {};

@@ -136,3 +149,3 @@

var pass = false, end = false;
var row, p, cf;
var row, p, cf, R, C,addr;
var mergecells = [];

@@ -191,3 +204,17 @@ recordhopper(data, function(val, R) {

case 'BrtMergeCell': mergecells.push(val); break;
case 'BrtHLink':
var rel = rels['!id'][val.relId];
if(rel) {
val.Target = rel.Target;
if(val.loc) val.Target += "#"+val.loc;
val.Rel = rel;
}
for(R=val.rfx.s.r;R<=val.rfx.e.r;++R) for(C=val.rfx.s.c;C<=val.rfx.e.c;++C) {
addr = encode_cell({c:C,r:R});
if(!s[addr]) s[addr] = {t:"str",v:undefined};
s[addr].l = val;
}
break;
case 'BrtArrFmla': break; // TODO

@@ -221,3 +248,2 @@ case 'BrtShrFmla': break; // TODO

case 'BrtEndSheet': break; // TODO
case 'BrtHLink': break; // TODO
case 'BrtDrawing': break; // TODO

@@ -273,3 +299,3 @@ case 'BrtLegacyDrawing': break; // TODO

case 'BrtBeginFilters': break;
case 'BrtFilter': break;
case 'BrtFilter': break;
case 'BrtEndFilters': break;

@@ -276,0 +302,0 @@ case 'BrtEndFilterColumn': break;

@@ -5,4 +5,4 @@ function parse_wb(data, name, opts) {

function parse_ws(data, name, opts) {
return name.substr(-4)===".bin" ? parse_ws_bin(data, opts) : parse_ws_xml(data, opts);
function parse_ws(data, name, opts, rels) {
return name.substr(-4)===".bin" ? parse_ws_bin(data, opts, rels) : parse_ws_xml(data, opts, rels);
}

@@ -9,0 +9,0 @@

@@ -426,3 +426,3 @@ /* [MS-XLSB] 2.3 Record Enumeration */

0x01ED: { n:"BrtEndMap", f:parsenoop },
0x01EE: { n:"BrtHLink", f:parsenoop },
0x01EE: { n:"BrtHLink", f:parse_BrtHLink },
0x01EF: { n:"BrtBeginDCon", f:parsenoop },

@@ -429,0 +429,0 @@ 0x01F0: { n:"BrtEndDCon", f:parsenoop },

@@ -79,4 +79,4 @@ function parseZip(zip, opts) {

relsPath = path.replace(/^(.*)(\/)([^\/]*)$/, "$1/_rels/$3.rels");
sheets[props.SheetNames[i]]=parse_ws(getzipdata(zip, path),path,opts);
sheetRels[props.SheetNames[i]]=parseRels(getzipdata(zip, relsPath, true), path);
sheets[props.SheetNames[i]]=parse_ws(getzipdata(zip, path),path,opts,sheetRels[props.SheetNames[i]]);
} catch(e) { if(opts.WTF) throw e; }

@@ -83,0 +83,0 @@ }

@@ -20,4 +20,1 @@ function readSync(data, options) {

XLSX.read = readSync;
XLSX.readFile = readFileSync;
XLSX.parseZip = parseZip;

@@ -1,7 +0,1 @@

if(typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.read = XLSX.read;
exports.readFile = XLSX.readFile;
exports.utils = XLSX.utils;
exports.version = XLSX.version;
}
})(typeof exports !== 'undefined' ? exports : XLSX);
{
"name": "xlsx",
"version": "0.5.17",
"version": "0.6.0",
"author": "sheetjs",

@@ -12,3 +12,3 @@ "description": "XLSB / XLSX / XLSM (Excel 2007+ Spreadsheet) parser",

"dependencies": {
"ssf":"~0.6.3",
"ssf":"~0.6.4",
"codepage":"",

@@ -15,0 +15,0 @@ "cfb":"",

@@ -69,2 +69,3 @@ # xlsx

- `.z` : the number format string associated with the cell (if requested)
- `.l` : the hyperlink of the cell (.Target holds link, .tooltip is tooltip)

@@ -71,0 +72,0 @@ For dates, `.v` holds the raw date code from the sheet and `.w` holds the text

@@ -31,2 +31,4 @@ /* vim: set ts=2: */

fstb: dir + 'formula_stress_test.xlsb',
hl1: dir + 'hyperlink_stress_test_2011.xlsx',
hl2: dir + 'hyperlink_stress_test_2011.xlsb',
lon1: dir + 'LONumbers.xlsx',

@@ -77,3 +79,3 @@ mc1: dir + 'merge_cells.xlsx',

});
if(!full) return;
if(!full) return;
describe(x + ' should generate correct output', function() {

@@ -110,3 +112,3 @@ wb.SheetNames.forEach(function(ws, i) {

});
fileA.forEach(function(x) {
fileA.forEach(function(x) {
it(x, x.substr(-8) == ".pending" ? null : function() {

@@ -378,2 +380,25 @@ var wb = X.readFile(dir + x, {WTF:opts.wtf, sheetRows:10});

describe('should find hyperlinks', function() {
var wb1, wb2;
before(function() {
X = require('./');
wb1 = X.readFile(paths.hl1);
wb2 = X.readFile(paths.hl2);
});
function hlink(wb) {
var ws = wb.Sheets.Sheet1;
assert.equal(ws.A1.l.Target, "http://www.sheetjs.com");
assert.equal(ws.A2.l.Target, "http://oss.sheetjs.com");
assert.equal(ws.A3.l.Target, "http://oss.sheetjs.com#foo");
assert.equal(ws.A4.l.Target, "mailto:dev@sheetjs.com");
assert.equal(ws.A5.l.Target, "mailto:dev@sheetjs.com?subject=hyperlink");
assert.equal(ws.A6.l.Target, "../../sheetjs/Documents/Test.xlsx");
assert.equal(ws.A7.l.Target, "http://sheetjs.com");
}
it(N1, function() { hlink(wb1); });
it(N2, function() { hlink(wb2); });
});
describe('should parse cells with date type (XLSX/XLSM)', function() {

@@ -380,0 +405,0 @@ var wb, ws;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc