XLS cellText option (fixes #841 h/t @cyzeng-Luca)

This commit is contained in:
SheetJS 2017-10-17 23:05:05 -04:00
parent f968dfe4ed
commit ed4348a6b6
9 changed files with 66 additions and 10 deletions

5
.gitattributes vendored Normal file

@ -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

@ -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
```
</details>
### 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

@ -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*/ {

@ -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
```
</details>
### Tests

@ -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

@ -86,4 +86,4 @@
* [Windows](README.md#windows)
* [Tests](README.md#tests)
- [License](README.md#license)
- [References](README.md#references)
- [References](README.md#references)

@ -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');
});

@ -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*/ {

@ -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) {