1
1
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
2
2
/* vim: set ts=2: */
3
- /*jshint eqnull:true */
4
3
var XLSX = { } ;
5
4
( function ( XLSX ) {
6
- XLSX . version = '0.6.1' ;
5
+ XLSX . version = '0.6.2' ;
6
+ var current_codepage = 1252 , current_cptable ;
7
+ if ( typeof module !== "undefined" && typeof require !== 'undefined' ) {
8
+ if ( typeof cptable === 'undefined' ) cptable = require ( 'codepage' ) ;
9
+ current_cptable = cptable [ current_codepage ] ;
10
+ }
11
+ function reset_cp ( ) { set_cp ( 1252 ) ; }
12
+ function set_cp ( cp ) { current_codepage = cp ; if ( typeof cptable !== 'undefined' ) current_cptable = cptable [ cp ] ; }
13
+
14
+ var _getchar = function ( x ) { return String . fromCharCode ( x ) ; } ;
15
+ if ( typeof cptable !== 'undefined' ) _getchar = function ( x ) {
16
+ if ( current_codepage === 1200 ) return String . fromCharCode ( x ) ;
17
+ if ( current_cptable ) return current_cptable . dec [ x ] ;
18
+ return cptable . utils . decode ( current_codepage , [ x % 256 , x >> 8 ] ) [ 0 ] ;
19
+ } ;
7
20
/* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
8
21
var SSF = { } ;
9
22
var make_ssf = function ( SSF ) {
10
23
var _strrev = function ( x ) { return String ( x ) . split ( "" ) . reverse ( ) . join ( "" ) ; } ;
11
24
function fill ( c , l ) { return new Array ( l + 1 ) . join ( c ) ; }
12
25
function pad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ?t :( fill ( c || 0 , d - t . length ) + t ) ; }
13
26
function rpad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ?t :( t + fill ( c || 0 , d - t . length ) ) ; }
14
- SSF . version = '0.6.4 ' ;
27
+ SSF . version = '0.6.5 ' ;
15
28
/* Options */
16
- var opts_fmt = { } ;
29
+ var opts_fmt = {
30
+ date1904 :0 ,
31
+ output :"" ,
32
+ WTF :false
33
+ } ;
17
34
function fixopts ( o ) { for ( var y in opts_fmt ) if ( o [ y ] === undefined ) o [ y ] = opts_fmt [ y ] ; }
18
35
SSF . opts = opts_fmt ;
19
- opts_fmt . date1904 = 0 ;
20
- opts_fmt . output = "" ;
21
36
var table_fmt = {
22
37
0 : 'General' ,
23
38
1 : '0' ,
@@ -95,7 +110,7 @@ var frac = function frac(x, D, mixed) {
95
110
var q = Math . floor ( sgn * P / Q ) ;
96
111
return [ q , sgn * P - q * Q , Q ] ;
97
112
} ;
98
- var general_fmt = function ( v ) {
113
+ var general_fmt = function ( v , opts ) {
99
114
if ( typeof v === 'boolean' ) return v ? "TRUE" : "FALSE" ;
100
115
if ( typeof v === 'number' ) {
101
116
var o , V = v < 0 ? - v : v ;
@@ -106,12 +121,12 @@ var general_fmt = function(v) {
106
121
else if ( V >= Math . pow ( 10 , 10 ) && V < Math . pow ( 10 , 11 ) ) o = v . toFixed ( 10 ) . substr ( 0 , 12 ) ;
107
122
else if ( V > Math . pow ( 10 , - 9 ) && V < Math . pow ( 10 , 11 ) ) {
108
123
o = v . toFixed ( 12 ) . replace ( / ( \. [ 0 - 9 ] * [ 1 - 9 ] ) 0 * $ / , "$1" ) . replace ( / \. $ / , "" ) ;
109
- if ( o . length > 11 + ( v < 0 ?1 : 0 ) ) o = v . toPrecision ( 10 ) ;
110
- if ( o . length > 11 + ( v < 0 ?1 : 0 ) ) o = v . toExponential ( 5 ) ;
124
+ if ( o . length > ( v < 0 ?12 : 11 ) ) o = v . toPrecision ( 10 ) ;
125
+ if ( o . length > ( v < 0 ?12 : 11 ) ) o = v . toExponential ( 5 ) ;
111
126
}
112
127
else {
113
128
o = v . toFixed ( 11 ) . replace ( / ( \. [ 0 - 9 ] * [ 1 - 9 ] ) 0 * $ / , "$1" ) ;
114
- if ( o . length > 11 + ( v < 0 ?1 : 0 ) ) o = v . toPrecision ( 6 ) ;
129
+ if ( o . length > ( v < 0 ?12 : 11 ) ) o = v . toPrecision ( 6 ) ;
115
130
}
116
131
o = o . replace ( / ( \. [ 0 - 9 ] * [ 1 - 9 ] ) 0 + e / , "$1e" ) . replace ( / \. 0 * e / , "e" ) ;
117
132
return o . replace ( "e" , "E" ) . replace ( / \. 0 * $ / , "" ) . replace ( / \. ( [ 0 - 9 ] * [ ^ 0 ] ) 0 * $ / , ".$1" ) . replace ( / ( E [ + - ] ) ( [ 0 - 9 ] ) $ / , "$1" + "0" + "$2" ) ;
@@ -120,10 +135,12 @@ var general_fmt = function(v) {
120
135
throw new Error ( "unsupported value in General format: " + v ) ;
121
136
} ;
122
137
SSF . _general = general_fmt ;
123
- function fix_hijri ( date , o ) { }
138
+ function fix_hijri ( date , o ) { return 0 ; }
124
139
var parse_date_code = function parse_date_code ( v , opts , b2 ) {
125
140
var date = Math . floor ( v ) , time = Math . floor ( 86400 * ( v - date ) + 1e-6 ) , dow = 0 ;
126
- var dout = [ ] , out = { D :date , T :time , u :86400 * ( v - date ) - time } ; fixopts ( opts = ( opts || { } ) ) ;
141
+ var dout = [ ] ;
142
+ var out = { D :date , T :time , u :86400 * ( v - date ) - time , y :0 , m :0 , d :0 , H :0 , M :0 , S :0 , q :0 } ;
143
+ fixopts ( opts = ( opts || { } ) ) ;
127
144
if ( opts . date1904 ) date += 1462 ;
128
145
if ( date > 2958465 ) return null ;
129
146
if ( out . u > 0.999 ) {
@@ -152,7 +169,6 @@ var parse_date_code = function parse_date_code(v,opts,b2) {
152
169
SSF . parse_date_code = parse_date_code ;
153
170
/*jshint -W086 */
154
171
var write_date = function ( type , fmt , val ) {
155
- if ( val < 0 ) return "" ;
156
172
var o , ss , y = val . y ;
157
173
switch ( type ) {
158
174
case 'b' : y = val . y + 543 ;
@@ -224,11 +240,11 @@ var write_num = function(type, fmt, val) {
224
240
var idx = fmt . indexOf ( "E" ) - fmt . indexOf ( "." ) - 1 ;
225
241
if ( fmt . match ( / ^ # + 0 .0 E \+ 0 $ / ) ) {
226
242
var period = fmt . indexOf ( "." ) ; if ( period === - 1 ) period = fmt . indexOf ( 'E' ) ;
227
- var ee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ) ) ) ) % period ;
243
+ var ee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ? 1 : 0 ) ) ) ) % period ;
228
244
if ( ee < 0 ) ee += period ;
229
245
o = ( val / Math . pow ( 10 , ee ) ) . toPrecision ( idx + 1 + ( period + ee ) % period ) ;
230
246
if ( ! o . match ( / [ E e ] / ) ) {
231
- var fakee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ) ) ) ) ;
247
+ var fakee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ? 1 : 0 ) ) ) ) ;
232
248
if ( o . indexOf ( "." ) === - 1 ) o = o [ 0 ] + "." + o . substr ( 1 ) + "E+" + ( fakee - o . length + ee ) ;
233
249
else o += "E+" + ( fakee - ee ) ;
234
250
while ( o . substr ( 0 , 2 ) === "0." ) {
@@ -248,7 +264,7 @@ var write_num = function(type, fmt, val) {
248
264
if ( ( r = fmt . match ( / # ( \? + ) ( [ ] ? ) \/ ( [ ] ? ) ( \d + ) / ) ) ) {
249
265
var den = Number ( r [ 4 ] ) , rnd = Math . round ( aval * den ) , base = Math . floor ( rnd / den ) ;
250
266
var myn = ( rnd - base * den ) , myd = den ;
251
- return sign + ( base ? base : "" ) + " " + ( myn === 0 ? fill ( " " , r [ 1 ] . length + 1 + r [ 4 ] . length ) : pad ( myn , r [ 1 ] . length , " " ) + r [ 2 ] + "/" + r [ 3 ] + pad ( myd , r [ 4 ] . length ) ) ;
267
+ return sign + String ( base || "" ) + " " + ( myn === 0 ? fill ( " " , r [ 1 ] . length + 1 + r [ 4 ] . length ) : pad ( myn , r [ 1 ] . length , " " ) + r [ 2 ] + "/" + r [ 3 ] + pad ( myd , r [ 4 ] . length ) ) ;
252
268
}
253
269
if ( fmt . match ( / ^ # + 0 + $ / ) ) fmt = fmt . replace ( / # / g, "" ) ;
254
270
if ( fmt . match ( / ^ 0 0 + $ / ) ) return ( val < 0 ?"-" :"" ) + pad ( Math . round ( aval ) , fmt . length ) ;
@@ -269,13 +285,10 @@ var write_num = function(type, fmt, val) {
269
285
return val < 0 ? "-" + write_num ( type , fmt , - val ) : commaify ( String ( Math . floor ( val ) ) ) + "." + pad ( rr , r [ 1 ] . length , 0 ) ;
270
286
}
271
287
if ( ( r = fmt . match ( / ^ # , # * , # 0 / ) ) ) return write_num ( type , fmt . replace ( / ^ # , # * , / , "" ) , val ) ;
272
- if ( ( r = fmt . match ( / ^ ( [ 0 # ] + ) \\ ? - ( [ 0 # ] + ) $ / ) ) ) {
273
- ff = write_num ( type , fmt . replace ( / [ \\ - ] / g, "" ) , val ) ;
274
- return ff . substr ( 0 , ff . length - r [ 2 ] . length ) + "-" + ff . substr ( ff . length - r [ 2 ] . length ) ;
275
- }
276
- if ( ( r = fmt . match ( / ^ ( [ 0 # ] + ) \\ ? - ( [ 0 # ] + ) \\ ? - ( [ 0 # ] + ) $ / ) ) ) {
277
- ff = write_num ( type , fmt . replace ( / [ \\ - ] / g, "" ) , val ) ;
278
- return ff . substr ( 0 , ff . length - r [ 2 ] . length - r [ 3 ] . length ) + "-" + ff . substr ( ff . length - r [ 2 ] . length - r [ 3 ] . length , r [ 2 ] . length ) + "-" + ff . substr ( ff . length - r [ 3 ] . length ) ;
288
+ if ( ( r = fmt . match ( / ^ ( [ 0 # ] + ) ( \\ ? - ( [ 0 # ] + ) ) + $ / ) ) ) {
289
+ ff = _strrev ( write_num ( type , fmt . replace ( / [ \\ - ] / g, "" ) , val ) ) ;
290
+ rr = 0 ;
291
+ return _strrev ( _strrev ( fmt . replace ( / \\ / g, "" ) ) . replace ( / [ 0 # ] / g, function ( x ) { return rr < ff . length ?ff [ rr ++ ] :x === '0' ?'0' :'' ; } ) ) ;
279
292
}
280
293
if ( fmt . match ( / \( # # # \) # # # \\ ? - # # # # / ) ) {
281
294
ff = write_num ( type , "##########" , val ) ;
@@ -296,7 +309,7 @@ var write_num = function(type, fmt, val) {
296
309
return val < 0 ? "-" + write_num ( type , fmt , - val ) : commaify ( String ( Math . floor ( val ) ) ) . replace ( / ^ \d , \d { 3 } $ / , "0$&" ) . replace ( / ^ \d * $ / , function ( $$ ) { return "00," + ( $$ . length < 3 ? pad ( 0 , 3 - $$ . length ) : "" ) + $$ ; } ) + "." + pad ( rr , r [ 1 ] . length , 0 ) ;
297
310
}
298
311
switch ( fmt ) {
299
- case "0" : case "#0" : return Math . round ( val ) ;
312
+ case "0" : case "#0" : return "" + Math . round ( val ) ;
300
313
case "#,###" : var x = commaify ( String ( Math . round ( aval ) ) ) ; return x !== "0" ? sign + x : "" ;
301
314
default :
302
315
}
@@ -319,7 +332,7 @@ function split_fmt(fmt) {
319
332
}
320
333
SSF . _split = split_fmt ;
321
334
function eval_fmt ( fmt , v , opts , flen ) {
322
- var out = [ ] , o = "" , i = 0 , c = "" , lst = 't' , q = { } , dt ;
335
+ var out = [ ] , o = "" , i = 0 , c = "" , lst = 't' , q , dt ;
323
336
fixopts ( opts = ( opts || { } ) ) ;
324
337
var hr = 'H' ;
325
338
/* Tokenize */
@@ -498,16 +511,6 @@ SSF.get_table = function() { return table_fmt; };
498
511
SSF . load_table = function ( tbl ) { for ( var i = 0 ; i != 0x0188 ; ++ i ) if ( tbl [ i ] ) SSF . load ( tbl [ i ] , i ) ; } ;
499
512
} ;
500
513
make_ssf ( SSF ) ;
501
- var current_codepage , current_cptable ;
502
- if ( typeof module !== "undefined" && typeof require !== 'undefined' ) {
503
- if ( typeof cptable === 'undefined' ) cptable = require ( 'codepage' ) ;
504
- current_codepage = 1252 ; current_cptable = cptable [ 1252 ] ;
505
- }
506
- function reset_cp ( ) {
507
- current_codepage = 1252 ; if ( typeof cptable !== 'undefined' ) current_cptable = cptable [ 1252 ] ;
508
- }
509
- function _getchar ( x ) { return String . fromCharCode ( x ) ; }
510
-
511
514
function getdata ( data ) {
512
515
if ( ! data ) return null ;
513
516
if ( data . data ) return data . name . substr ( - 4 ) !== ".bin" ? data . data : data . data . split ( "" ) . map ( function ( x ) { return x . charCodeAt ( 0 ) ; } ) ;
@@ -543,6 +546,7 @@ if (typeof exports !== 'undefined') {
543
546
_fs = require ( 'fs' ) ;
544
547
}
545
548
}
549
+ var _chr = function ( c ) { return String . fromCharCode ( c ) ; } ;
546
550
var attregexg = / ( [ \w : ] + ) = ( (?: " ) ( [ ^ " ] * ) (?: " ) | (?: ' ) ( [ ^ ' ] * ) (?: ' ) ) / g;
547
551
var attregex = / ( [ \w : ] + ) = ( (?: " ) (?: [ ^ " ] * ) (?: " ) | (?: ' ) (?: [ ^ ' ] * ) (?: ' ) ) / ;
548
552
function parsexmltag ( tag ) {
@@ -677,8 +681,6 @@ function ReadShift(size, t) {
677
681
/* falls through */
678
682
case 16 : o = this . toString ( 'hex' , this . l , this . l + size ) ; break ;
679
683
680
- /* sbcs and dbcs support continue records in the SST way TODO codepages */
681
- /* TODO: DBCS http://msdn.microsoft.com/en-us/library/cc194788.aspx */
682
684
case 'dbcs' : size = 2 * t ; loc = this . l ;
683
685
for ( i = 0 ; i != t ; ++ i ) {
684
686
oo . push ( _getchar ( __readUInt16LE ( this , loc ) ) ) ;
@@ -2231,6 +2233,7 @@ var CustomWBViewDef = {
2231
2233
yWindow : '0'
2232
2234
} ;
2233
2235
var XMLNS_WB = [
2236
+ 'http://purl.oclc.org/ooxml/spreadsheetml/main' ,
2234
2237
'http://schemas.openxmlformats.org/spreadsheetml/2006/main' ,
2235
2238
'http://schemas.microsoft.com/office/excel/2006/main' ,
2236
2239
'http://schemas.microsoft.com/office/excel/2006/2'
@@ -3420,33 +3423,47 @@ function readFileSync(data, options) {
3420
3423
return readSync ( data , o ) ;
3421
3424
}
3422
3425
3423
- var _chr = function ( c ) { return String . fromCharCode ( c ) ; } ;
3426
+ function decode_row ( rowstr ) { return Number ( unfix_row ( rowstr ) ) - 1 ; }
3427
+ function encode_row ( row ) { return "" + ( row + 1 ) ; }
3428
+ function fix_row ( cstr ) { return cstr . replace ( / ( [ A - Z ] | ^ ) ( [ 0 - 9 ] + ) $ / , "$1$$$2" ) ; }
3429
+ function unfix_row ( cstr ) { return cstr . replace ( / \$ ( [ 0 - 9 ] + ) $ / , "$1" ) ; }
3424
3430
3431
+ function decode_col ( colstr ) { var c = unfix_col ( colstr ) , d = 0 , i = 0 ; for ( ; i !== c . length ; ++ i ) d = 26 * d + c . charCodeAt ( i ) - 64 ; return d - 1 ; }
3425
3432
function encode_col ( col ) { var s = "" ; for ( ++ col ; col ; col = Math . floor ( ( col - 1 ) / 26 ) ) s = _chr ( ( ( col - 1 ) % 26 ) + 65 ) + s ; return s ; }
3426
- function encode_row ( row ) { return "" + ( row + 1 ) ; }
3427
- function encode_cell ( cell ) { return encode_col ( cell . c ) + encode_row ( cell . r ) ; }
3433
+ function fix_col ( cstr ) { return cstr . replace ( / ^ ( [ A - Z ] ) / , "$$$1" ) ; }
3434
+ function unfix_col ( cstr ) { return cstr . replace ( / ^ \$ ( [ A - Z ] ) / , "$1" ) ; }
3428
3435
3429
- function decode_col ( c ) { var d = 0 , i = 0 ; for ( ; i !== c . length ; ++ i ) d = 26 * d + c . charCodeAt ( i ) - 64 ; return d - 1 ; }
3430
- function decode_row ( rowstr ) { return Number ( rowstr ) - 1 ; }
3431
3436
function split_cell ( cstr ) { return cstr . replace ( / ( \$ ? [ A - Z ] * ) ( \$ ? [ 0 - 9 ] * ) / , "$1,$2" ) . split ( "," ) ; }
3432
3437
function decode_cell ( cstr ) { var splt = split_cell ( cstr ) ; return { c :decode_col ( splt [ 0 ] ) , r :decode_row ( splt [ 1 ] ) } ; }
3438
+ function encode_cell ( cell ) { return encode_col ( cell . c ) + encode_row ( cell . r ) ; }
3439
+ function fix_cell ( cstr ) { return fix_col ( fix_row ( cstr ) ) ; }
3440
+ function unfix_cell ( cstr ) { return unfix_col ( unfix_row ( cstr ) ) ; }
3433
3441
function decode_range ( range ) { var x = range . split ( ":" ) . map ( decode_cell ) ; return { s :x [ 0 ] , e :x [ x . length - 1 ] } ; }
3434
- function encode_range ( range ) { return encode_cell ( range . s ) + ":" + encode_cell ( range . e ) ; }
3442
+ function encode_range ( cs , ce ) {
3443
+ if ( typeof ce === 'undefined' || typeof ce === 'number' ) return encode_range ( cs . s , cs . e ) ;
3444
+ if ( typeof cs !== 'string' ) cs = encode_cell ( cs ) ; if ( typeof ce !== 'string' ) ce = encode_cell ( ce ) ;
3445
+ return cs == ce ? cs : cs + ":" + ce ;
3446
+ }
3447
+
3448
+ function format_cell ( cell , v ) {
3449
+ if ( ! cell || ! cell . t ) return "" ;
3450
+ if ( typeof cell . w !== 'undefined' ) return cell . w ;
3451
+ if ( typeof v === 'undefined' ) v = cell . v ;
3452
+ if ( typeof cell . z !== 'undefined' ) try { return ( cell . w = SSF . format ( cell . z , v ) ) ; } catch ( e ) { }
3453
+ if ( ! cell . XF ) return v ;
3454
+ try { return ( cell . w = SSF . format ( cell . XF . ifmt || 0 , v ) ) ; } catch ( e ) { return v ; }
3455
+ }
3435
3456
3436
3457
function sheet_to_row_object_array ( sheet , opts ) {
3437
- var val , row , r , hdr = { } , isempty , R , C ;
3458
+ var val , row , r , hdr = { } , isempty , R , C , v ;
3438
3459
var out = [ ] ;
3439
3460
opts = opts || { } ;
3440
3461
if ( ! sheet || ! sheet [ "!ref" ] ) return out ;
3441
- r = XLSX . utils . decode_range ( sheet [ "!ref" ] ) ;
3462
+ r = decode_range ( sheet [ "!ref" ] ) ;
3442
3463
for ( R = r . s . r , C = r . s . c ; C <= r . e . c ; ++ C ) {
3443
3464
val = sheet [ encode_cell ( { c :C , r :R } ) ] ;
3444
3465
if ( ! val ) continue ;
3445
- if ( val . w ) hdr [ C ] = val . w ;
3446
- else switch ( val . t ) {
3447
- case 's' : case 'str' : hdr [ C ] = val . v ; break ;
3448
- case 'n' : hdr [ C ] = val . v ; break ;
3449
- }
3466
+ hdr [ C ] = format_cell ( val ) ;
3450
3467
}
3451
3468
3452
3469
for ( R = r . s . r + 1 ; R <= r . e . r ; ++ R ) {
@@ -3456,47 +3473,36 @@ function sheet_to_row_object_array(sheet, opts){
3456
3473
for ( C = r . s . c ; C <= r . e . c ; ++ C ) {
3457
3474
val = sheet [ encode_cell ( { c : C , r : R } ) ] ;
3458
3475
if ( ! val || ! val . t ) continue ;
3459
- if ( typeof val . w !== 'undefined' && ! opts . raw ) { row [ hdr [ C ] ] = val . w ; isempty = false ; }
3460
- else switch ( val . t ) {
3461
- case 's' : case 'str' : case 'b' : case 'n' :
3462
- if ( typeof val . v !== 'undefined' ) {
3463
- row [ hdr [ C ] ] = val . v ;
3464
- isempty = false ;
3465
- }
3466
- break ;
3467
- case 'e' : break ; /* throw */
3476
+ v = ( val || { } ) . v ;
3477
+ switch ( val . t ) {
3478
+ case 'e' : continue ;
3479
+ case 's' : case 'str' : break ;
3480
+ case 'b' : case 'n' : break ;
3468
3481
default : throw 'unrecognized type ' + val . t ;
3469
3482
}
3483
+ if ( typeof v !== 'undefined' ) {
3484
+ row [ hdr [ C ] ] = opts . raw ? v || val . v : format_cell ( val , v ) ;
3485
+ isempty = false ;
3486
+ }
3470
3487
}
3471
3488
if ( ! isempty ) out . push ( row ) ;
3472
3489
}
3473
3490
return out ;
3474
3491
}
3475
3492
3476
3493
function sheet_to_csv ( sheet , opts ) {
3477
- var stringify = function stringify ( val ) {
3478
- if ( ! val . t ) return "" ;
3479
- if ( typeof val . w !== 'undefined' ) return val . w ;
3480
- switch ( val . t ) {
3481
- case 'n' : return String ( val . v ) ;
3482
- case 's' : case 'str' : return typeof val . v !== 'undefined' ? val . v : "" ;
3483
- case 'b' : return val . v ? "TRUE" : "FALSE" ;
3484
- case 'e' : return val . v ; /* throw out value in case of error */
3485
- default : throw 'unrecognized type ' + val . t ;
3486
- }
3487
- } ;
3488
3494
var out = [ ] , txt = "" ;
3489
3495
opts = opts || { } ;
3490
3496
if ( ! sheet || ! sheet [ "!ref" ] ) return "" ;
3491
- var r = XLSX . utils . decode_range ( sheet [ "!ref" ] ) ;
3497
+ var r = decode_range ( sheet [ "!ref" ] ) ;
3492
3498
var fs = opts . FS || "," , rs = opts . RS || "\n" ;
3493
3499
3494
3500
for ( var R = r . s . r ; R <= r . e . r ; ++ R ) {
3495
3501
var row = [ ] ;
3496
3502
for ( var C = r . s . c ; C <= r . e . c ; ++ C ) {
3497
- var val = sheet [ XLSX . utils . encode_cell ( { c :C , r :R } ) ] ;
3503
+ var val = sheet [ encode_cell ( { c :C , r :R } ) ] ;
3498
3504
if ( ! val ) { row . push ( "" ) ; continue ; }
3499
- txt = String ( stringify ( val ) ) ;
3505
+ txt = String ( format_cell ( val ) ) ;
3500
3506
if ( txt . indexOf ( fs ) !== - 1 || txt . indexOf ( rs ) !== - 1 || txt . indexOf ( '"' ) !== - 1 )
3501
3507
txt = "\"" + txt . replace ( / " / g, '""' ) + "\"" ;
3502
3508
row . push ( txt ) ;
@@ -3521,7 +3527,7 @@ function get_formulae(ws) {
3521
3527
return cmds ;
3522
3528
}
3523
3529
3524
- XLSX . utils = {
3530
+ var utils = {
3525
3531
encode_col : encode_col ,
3526
3532
encode_row : encode_row ,
3527
3533
encode_cell : encode_cell ,
@@ -3533,11 +3539,14 @@ XLSX.utils = {
3533
3539
decode_range : decode_range ,
3534
3540
sheet_to_csv : sheet_to_csv ,
3535
3541
make_csv : sheet_to_csv ,
3542
+ make_json : sheet_to_row_object_array ,
3536
3543
get_formulae : get_formulae ,
3544
+ format_cell : format_cell ,
3537
3545
sheet_to_row_object_array : sheet_to_row_object_array
3538
3546
} ;
3547
+ XLSX . parseZip = parseZip ;
3539
3548
XLSX . read = readSync ;
3540
3549
XLSX . readFile = readFileSync ;
3541
- XLSX . parseZip = parseZip ;
3550
+ XLSX . utils = utils ;
3542
3551
XLSX . SSF = SSF ;
3543
3552
} ) ( typeof exports !== 'undefined' ? exports : XLSX ) ;
0 commit comments