From 61b17e6d9d2544304cff2a57bdac09225360d660 Mon Sep 17 00:00:00 2001 From: harbhub Date: Thu, 13 Nov 2014 03:42:15 -0500 Subject: [PATCH] handle internal links (fixes #145) --- bits/67_wsxml.js | 6 +++++- xlsx.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bits/67_wsxml.js b/bits/67_wsxml.js index 43cd4ca..eeae99b 100644 --- a/bits/67_wsxml.js +++ b/bits/67_wsxml.js @@ -74,11 +74,15 @@ function parse_ws_xml_hlinks(s, data, rels) { for(var i = 0; i != data.length; ++i) { var val = parsexmltag(data[i], true); if(!val.ref) return; - var rel = rels['!id'][val.id]; + var rel = rels ? rels['!id'][val.id] : null; if(rel) { val.Target = rel.Target; if(val.location) val.Target += "#"+val.location; val.Rel = rel; + } else { + val.Target = val.location; + rel = {Target: val.location, TargetMode: 'Internal'}; + val.Rel = rel; } var rng = safe_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) { diff --git a/xlsx.js b/xlsx.js index 6f1fab8..641f820 100644 --- a/xlsx.js +++ b/xlsx.js @@ -2904,11 +2904,15 @@ function parse_ws_xml_hlinks(s, data, rels) { for(var i = 0; i != data.length; ++i) { var val = parsexmltag(data[i], true); if(!val.ref) return; - var rel = rels['!id'][val.id]; + var rel = rels ? rels['!id'][val.id] : null; if(rel) { val.Target = rel.Target; if(val.location) val.Target += "#"+val.location; val.Rel = rel; + } else { + val.Target = val.location; + rel = {Target: val.location, TargetMode: 'Internal'}; + val.Rel = rel; } var rng = safe_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) {