From c5c3eebb09fc9ebcac66d7993565d70e8d1e9022 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sat, 13 Apr 2013 13:00:01 -0400 Subject: [PATCH] LICENSE clarification; get_formulae function To avoid future confusion, any code shared between this and the XLS project relate to concepts discussed in ECMA-376 and hence fall within the purview of this project's license. A similar note should appear in the license for the other projects. --- LICENSE | 6 ++++-- bits/90_utils.js | 15 ++++++++++++++- xlsx.js | 15 ++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index 324d2c9..76f4470 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2012 Niggler +Copyright (C) 2012-2013 Niggler The MIT License (MIT) @@ -11,4 +11,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI Except where noted, this license applies to any and all software programs and associated documentation files created by the Original Author and distributed with the Software: -'jszip.js' is a modified version of JSZip, Copyright (c) Stuart Knightley, David Duponchel, Franz Buchinger, Ant'onio Afonso. JSZip is dual licensed and is used according to the terms of the MIT License. +'jszip.js' is a modified version of JSZip, Copyright (c) Stuart Knightley, David Duponchel, Franz Buchinger, Ant'onio Afonso. JSZip is dual licensed and is used according to the terms of the MIT License. + +Any code shared between this project and the Apache-licensed XLS parser by the same author (all of which draws from the ECMA-376 specification) falls under this license. diff --git a/bits/90_utils.js b/bits/90_utils.js index d0a83d7..6c56597 100644 --- a/bits/90_utils.js +++ b/bits/90_utils.js @@ -50,7 +50,7 @@ function sheet_to_row_object_array(sheet){ emptyRow = false; } break; - case 'e': break; /* thorw */ + case 'e': break; /* throw */ default: throw 'unrecognized type ' + val.t; } } @@ -87,6 +87,18 @@ function sheet_to_csv(sheet) { return out; } +function get_formulae(ws) { + var cmds = []; + for(y in ws) if(y[0] !=='!' && ws.hasOwnProperty(y)) (function(y,x) { + var val = ""; + if(x.f) val = x.f; + else if(typeof x.v === 'number') val = x.v; + else val = x.v; + cmds.push(y + "=" + val); + })(y,ws[y]); + return cmds; +} + var utils = { encode_col: encode_col, encode_row: encode_row, @@ -98,5 +110,6 @@ var utils = { decode_cell: decode_cell, decode_range: decode_range, sheet_to_csv: sheet_to_csv, + get_formulae: get_formulae, sheet_to_row_object_array: sheet_to_row_object_array }; diff --git a/xlsx.js b/xlsx.js index d9b383c..b9c7a68 100644 --- a/xlsx.js +++ b/xlsx.js @@ -877,7 +877,7 @@ function sheet_to_row_object_array(sheet){ emptyRow = false; } break; - case 'e': break; /* thorw */ + case 'e': break; /* throw */ default: throw 'unrecognized type ' + val.t; } } @@ -914,6 +914,18 @@ function sheet_to_csv(sheet) { return out; } +function get_formulae(ws) { + var cmds = []; + for(y in ws) if(y[0] !=='!' && ws.hasOwnProperty(y)) (function(y,x) { + var val = ""; + if(x.f) val = x.f; + else if(typeof x.v === 'number') val = x.v; + else val = x.v; + cmds.push(y + "=" + val); + })(y,ws[y]); + return cmds; +} + var utils = { encode_col: encode_col, encode_row: encode_row, @@ -925,6 +937,7 @@ var utils = { decode_cell: decode_cell, decode_range: decode_range, sheet_to_csv: sheet_to_csv, + get_formulae: get_formulae, sheet_to_row_object_array: sheet_to_row_object_array };