From ed4348a6b6b1721b721cebe777ebb8ea3df37035 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Tue, 17 Oct 2017 23:05:05 -0400 Subject: [PATCH] XLS cellText option (fixes #841 h/t @cyzeng-Luca) --- .gitattributes | 5 +++++ README.md | 17 +++++++++++++++++ bits/76_xls.js | 6 +++--- docbits/95_contrib.md | 16 ++++++++++++++++ misc/docs/README.md | 17 +++++++++++++++++ misc/docs/SUMMARY.md | 2 +- test.js | 1 + xlsx.flow.js | 6 +++--- xlsx.js | 6 +++--- 9 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ed7490c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.md text eol=lf +bits/*.js text eol=lf +test.js text eol=lf +xlsx*.js text eol=lf +*.flow.js text eol=lf diff --git a/README.md b/README.md index 48815f3..9f1be81 100644 --- a/README.md +++ b/README.md @@ -2401,6 +2401,22 @@ make book -- rebuild README and summary make help -- display this message ``` +As explained in [Test Files](#test-files), on Windows the release ZIP file must +be downloaded and extracted. If Bash on Windows is available, it is possible +to run the OSX/Linux workflow. The following steps prepares the environment: + +```bash +# Install support programs for the build and test commands +sudo apt-get install make git subversion mercurial + +# Install nodejs and NPM within the WSL +wget -qO- https://deb.nodesource.com/setup_8.x | sudo bash +sudo apt-get install nodejs + +# Install dev dependencies +sudo npm install -g mocha voc blanket xlsjs +``` + ### Tests @@ -2463,3 +2479,4 @@ granted by the Apache 2.0 License are reserved by the Original Author. - ISO/IEC 29500:2012(E) "Information technology — Document description and processing languages — Office Open XML File Formats" - Open Document Format for Office Applications Version 1.2 (29 September 2011) - Worksheet File Format (From Lotus) December 1984 + diff --git a/bits/76_xls.js b/bits/76_xls.js index de306fe..ec7e9c2 100644 --- a/bits/76_xls.js +++ b/bits/76_xls.js @@ -82,10 +82,10 @@ function safe_format_xf(p/*:any*/, opts/*:ParseOpts*/, date1904/*:?boolean*/) { else p.w = SSF._general(p.v); } else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904}); - if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { - var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } - } } catch(e) { if(opts.WTF) throw e; } + if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { + var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } + } } function make_cell(val, ixfe, t)/*:Cell*/ { diff --git a/docbits/95_contrib.md b/docbits/95_contrib.md index e42e5b5..ff8950c 100644 --- a/docbits/95_contrib.md +++ b/docbits/95_contrib.md @@ -78,6 +78,22 @@ make book -- rebuild README and summary make help -- display this message ``` +As explained in [Test Files](#test-files), on Windows the release ZIP file must +be downloaded and extracted. If Bash on Windows is available, it is possible +to run the OSX/Linux workflow. The following steps prepares the environment: + +```bash +# Install support programs for the build and test commands +sudo apt-get install make git subversion mercurial + +# Install nodejs and NPM within the WSL +wget -qO- https://deb.nodesource.com/setup_8.x | sudo bash +sudo apt-get install nodejs + +# Install dev dependencies +sudo npm install -g mocha voc blanket xlsjs +``` + ### Tests diff --git a/misc/docs/README.md b/misc/docs/README.md index 870be9f..4ded4e1 100644 --- a/misc/docs/README.md +++ b/misc/docs/README.md @@ -2177,6 +2177,22 @@ make book -- rebuild README and summary make help -- display this message ``` +As explained in [Test Files](#test-files), on Windows the release ZIP file must +be downloaded and extracted. If Bash on Windows is available, it is possible +to run the OSX/Linux workflow. The following steps prepares the environment: + +```bash +# Install support programs for the build and test commands +sudo apt-get install make git subversion mercurial + +# Install nodejs and NPM within the WSL +wget -qO- https://deb.nodesource.com/setup_8.x | sudo bash +sudo apt-get install nodejs + +# Install dev dependencies +sudo npm install -g mocha voc blanket xlsjs +``` + ### Tests @@ -2232,3 +2248,4 @@ granted by the Apache 2.0 License are reserved by the Original Author. - ISO/IEC 29500:2012(E) "Information technology — Document description and processing languages — Office Open XML File Formats" - Open Document Format for Office Applications Version 1.2 (29 September 2011) - Worksheet File Format (From Lotus) December 1984 + diff --git a/misc/docs/SUMMARY.md b/misc/docs/SUMMARY.md index c43105e..42008b7 100644 --- a/misc/docs/SUMMARY.md +++ b/misc/docs/SUMMARY.md @@ -86,4 +86,4 @@ * [Windows](README.md#windows) * [Tests](README.md#tests) - [License](README.md#license) -- [References](README.md#references) +- [References](README.md#references) \ No newline at end of file diff --git a/test.js b/test.js index 2869626..c7d6f82 100644 --- a/test.js +++ b/test.js @@ -541,6 +541,7 @@ describe('parse options', function() { }); it('bookProps && bookSheets should not generate sheets', function() { PMPaths.forEach(function(p) { + if(!fs.existsSync(p)) return; var wb = X.read(fs.readFileSync(p), {type:TYPE, bookProps:true, bookSheets:true}); assert(typeof wb.Sheets === 'undefined'); }); diff --git a/xlsx.flow.js b/xlsx.flow.js index 21b17b2..67c3eb5 100644 --- a/xlsx.flow.js +++ b/xlsx.flow.js @@ -14668,10 +14668,10 @@ function safe_format_xf(p/*:any*/, opts/*:ParseOpts*/, date1904/*:?boolean*/) { else p.w = SSF._general(p.v); } else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904}); - if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { - var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } - } } catch(e) { if(opts.WTF) throw e; } + if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { + var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } + } } function make_cell(val, ixfe, t)/*:Cell*/ { diff --git a/xlsx.js b/xlsx.js index 831bad0..1bc048a 100644 --- a/xlsx.js +++ b/xlsx.js @@ -14570,10 +14570,10 @@ function safe_format_xf(p, opts, date1904) { else p.w = SSF._general(p.v); } else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904}); - if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { - var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } - } } catch(e) { if(opts.WTF) throw e; } + if(opts.cellDates && fmtid && p.t == 'n' && SSF.is_date(SSF._table[fmtid] || String(fmtid))) { + var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); } + } } function make_cell(val, ixfe, t) {