Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
version bump 0.0.3: basic sylk support
Browse files Browse the repository at this point in the history
  • Loading branch information
SheetJSDev committed Oct 2, 2014
1 parent 4537481 commit 80cda54
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 15 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.8"
before_install:
- "npm install -g mocha"
- "npm install blanket"
- "npm install xlsx xlsjs"
- "npm install coveralls mocha-lcov-reporter"
before_script:
- "make init"
- "cd test_files; make all; cd -"
after_success:
- "make coveralls-spin"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Currently supported formats:

- DIF (Data Interchange Format)
- CSV/TSV/TXT
- SYLK (Symbolic Link)
- SocialCalc

Planned but not currently implemented:

- SYLK (Symbolic Link)
- SC (Spreadsheet Calculator)
- PRN (Space-Delimited Format)

Expand Down
5 changes: 5 additions & 0 deletions bin/harb.njs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

var HARB = require('../');

console.log(HARB.readFile(process.argv[2]).Sheets.Sheet1);
2 changes: 1 addition & 1 deletion bits/01_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HARB.version = '0.0.2';
HARB.version = '0.0.3';
28 changes: 27 additions & 1 deletion bits/65_slk.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
var sylk_to_sheet = function(f) { throw new Error('SYLK files unsupported'); };
/* TODO: find an actual specification */
var sylk_to_aoa = function(str) {
var records = str.split(/[\n\r]+/), R = -1, C = -1, ri = 0, rj = 0, arr = [];
for (; ri !== records.length; ++ri) {
var record = records[ri].trim().split(";");
var RT = record[0], val;
if(RT !== 'C' && RT !== 'F') continue;
for(rj=1; rj<record.length; ++rj) switch(record[rj].charAt(0)) {
case 'Y':
R = parseInt(record[rj].substr(1))-1; C = 0;
for(var j = arr.length; j <= R; ++j) arr[j] = [];
break;
case 'X': C = parseInt(record[rj].substr(1))-1; break;
case 'K':
val = record[rj].substr(1);
if(val.charAt(0) === '"') val = val.substr(1,val.length - 2);
else if(val === 'TRUE') val = true;
else if(val === 'FALSE') val = false;
else if(+val === +val) val = +val;
arr[R][C] = val;
break;
}
}
return arr;
};

var sylk_to_sheet = function(str) { return aoa_to_sheet(sylk_to_aoa(str)); };

var sylk_to_workbook = function (str) { return sheet_to_workbook(sylk_to_sheet(str)); };

2 changes: 1 addition & 1 deletion dist/harb.core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80cda54

Please sign in to comment.