Skip to content

Commit

Permalink
Empty cells now return null
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeTraxx committed Sep 23, 2015
1 parent 0c47aef commit 3a9cad0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/Sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ function Sheet(basedir, file, contents, sharedStrings) {
if (cell.$.t == 's') {
return sharedStrings[parseInt(cell.v)].t[0];
} else if(cell.f && cell.v) {
return cell.v[0].hasOwnProperty('_') ? cell.v[0]._ : cell.v[0];
var value = cell.v[0].hasOwnProperty('_') ? cell.v[0]._ : cell.v[0];
return ( value != '' ) ? value : null;
} else if (cell.f) {
// formula
return '=' + cell.f[0];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kexcel",
"version": "2.0.13",
"version": "2.0.14",
"description": "Create or open and then edit existing XLSX files",
"keywords": [
"xlsx",
Expand Down
7 changes: 5 additions & 2 deletions test/functionvalues.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ var fs = require('fs');
var path = require('path');
var should = chai.should();
var kexcel = require('..');


var expect = chai.expect;
describe('Return values instead of functions', function () {
var workbook;
it('Open a input file...', function (done) {
Expand All @@ -22,4 +21,8 @@ describe('Return values instead of functions', function () {
workbook.getSheet(0).getCellValue(2,1).should.equal('test with trailing white space ');
});

it('Null test', function () {
expect( workbook.getSheet(0).getCellValue(3,1)).to.be.null;
});

});
Binary file modified test/input-files/42.xlsx
Binary file not shown.

0 comments on commit 3a9cad0

Please sign in to comment.