2014-02-17 08:44:22 +00:00
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
2014-04-15 09:04:03 +00:00
var XLSX = { } ;
( function ( XLSX ) {
2014-05-29 22:30:03 +00:00
XLSX . version = '0.7.4' ;
2014-05-03 18:51:10 +00:00
var current _codepage = 1252 , current _cptable ;
if ( typeof module !== "undefined" && typeof require !== 'undefined' ) {
2014-05-25 09:04:08 +00:00
if ( typeof cptable === 'undefined' ) cptable = require ( './dist/cpexcel' ) ;
2014-05-03 18:51:10 +00:00
current _cptable = cptable [ current _codepage ] ;
}
function reset _cp ( ) { set _cp ( 1252 ) ; }
function set _cp ( cp ) { current _codepage = cp ; if ( typeof cptable !== 'undefined' ) current _cptable = cptable [ cp ] ; }
var _getchar = function ( x ) { return String . fromCharCode ( x ) ; } ;
if ( typeof cptable !== 'undefined' ) _getchar = function ( x ) {
if ( current _codepage === 1200 ) return String . fromCharCode ( x ) ;
if ( current _cptable ) return current _cptable . dec [ x ] ;
return cptable . utils . decode ( current _codepage , [ x % 256 , x >> 8 ] ) [ 0 ] ;
} ;
2014-05-22 12:16:51 +00:00
function char _codes ( data ) { return data . split ( "" ) . map ( function ( x ) { return x . charCodeAt ( 0 ) ; } ) ; }
function debom _xml ( data ) {
if ( typeof cptable !== 'undefined' ) {
if ( data . charCodeAt ( 0 ) === 0xFF && data . charCodeAt ( 1 ) === 0xFE ) { return cptable . utils . decode ( 1200 , char _codes ( data . substr ( 2 ) ) ) ; }
}
return data ;
}
2014-02-17 08:44:22 +00:00
/* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
var SSF = { } ;
var make _ssf = function ( SSF ) {
var _strrev = function ( x ) { return String ( x ) . split ( "" ) . reverse ( ) . join ( "" ) ; } ;
function fill ( c , l ) { return new Array ( l + 1 ) . join ( c ) ; }
function pad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ? t : ( fill ( c || 0 , d - t . length ) + t ) ; }
function rpad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ? t : ( t + fill ( c || 0 , d - t . length ) ) ; }
2014-05-22 12:16:51 +00:00
SSF . version = '0.7.0' ;
2014-02-17 08:44:22 +00:00
/* Options */
2014-05-03 18:51:10 +00:00
var opts _fmt = {
date1904 : 0 ,
output : "" ,
WTF : false
} ;
2014-02-17 08:44:22 +00:00
function fixopts ( o ) { for ( var y in opts _fmt ) if ( o [ y ] === undefined ) o [ y ] = opts _fmt [ y ] ; }
SSF . opts = opts _fmt ;
var table _fmt = {
0 : 'General' ,
1 : '0' ,
2 : '0.00' ,
3 : '#,##0' ,
4 : '#,##0.00' ,
9 : '0%' ,
10 : '0.00%' ,
11 : '0.00E+00' ,
12 : '# ?/?' ,
13 : '# ??/??' ,
14 : 'm/d/yy' ,
15 : 'd-mmm-yy' ,
16 : 'd-mmm' ,
17 : 'mmm-yy' ,
18 : 'h:mm AM/PM' ,
19 : 'h:mm:ss AM/PM' ,
20 : 'h:mm' ,
21 : 'h:mm:ss' ,
22 : 'm/d/yy h:mm' ,
37 : '#,##0 ;(#,##0)' ,
38 : '#,##0 ;[Red](#,##0)' ,
39 : '#,##0.00;(#,##0.00)' ,
40 : '#,##0.00;[Red](#,##0.00)' ,
45 : 'mm:ss' ,
46 : '[h]:mm:ss' ,
47 : 'mmss.0' ,
48 : '##0.0E+0' ,
49 : '@' ,
56 : '"上午/下午 "hh"時"mm"分"ss"秒 "' ,
65535 : 'General'
} ;
var days = [
[ 'Sun' , 'Sunday' ] ,
[ 'Mon' , 'Monday' ] ,
[ 'Tue' , 'Tuesday' ] ,
[ 'Wed' , 'Wednesday' ] ,
[ 'Thu' , 'Thursday' ] ,
[ 'Fri' , 'Friday' ] ,
[ 'Sat' , 'Saturday' ]
] ;
var months = [
[ 'J' , 'Jan' , 'January' ] ,
[ 'F' , 'Feb' , 'February' ] ,
[ 'M' , 'Mar' , 'March' ] ,
[ 'A' , 'Apr' , 'April' ] ,
[ 'M' , 'May' , 'May' ] ,
[ 'J' , 'Jun' , 'June' ] ,
[ 'J' , 'Jul' , 'July' ] ,
[ 'A' , 'Aug' , 'August' ] ,
[ 'S' , 'Sep' , 'September' ] ,
[ 'O' , 'Oct' , 'October' ] ,
[ 'N' , 'Nov' , 'November' ] ,
[ 'D' , 'Dec' , 'December' ]
] ;
var frac = function frac ( x , D , mixed ) {
var sgn = x < 0 ? - 1 : 1 ;
var B = x * sgn ;
var P _2 = 0 , P _1 = 1 , P = 0 ;
var Q _2 = 1 , Q _1 = 0 , Q = 0 ;
var A = Math . floor ( B ) ;
while ( Q _1 < D ) {
A = Math . floor ( B ) ;
P = A * P _1 + P _2 ;
Q = A * Q _1 + Q _2 ;
if ( ( B - A ) < 0.0000000005 ) break ;
B = 1 / ( B - A ) ;
P _2 = P _1 ; P _1 = P ;
Q _2 = Q _1 ; Q _1 = Q ;
}
if ( Q > D ) { Q = Q _1 ; P = P _1 ; }
if ( Q > D ) { Q = Q _2 ; P = P _2 ; }
if ( ! mixed ) return [ 0 , sgn * P , Q ] ;
if ( Q === 0 ) throw "Unexpected state: " + P + " " + P _1 + " " + P _2 + " " + Q + " " + Q _1 + " " + Q _2 ;
var q = Math . floor ( sgn * P / Q ) ;
return [ q , sgn * P - q * Q , Q ] ;
} ;
2014-05-03 18:51:10 +00:00
var general _fmt = function ( v , opts ) {
2014-02-17 08:44:22 +00:00
if ( typeof v === 'boolean' ) return v ? "TRUE" : "FALSE" ;
if ( typeof v === 'number' ) {
var o , V = v < 0 ? - v : v ;
if ( V >= 0.1 && V < 1 ) o = v . toPrecision ( 9 ) ;
else if ( V >= 0.01 && V < 0.1 ) o = v . toPrecision ( 8 ) ;
else if ( V >= 0.001 && V < 0.01 ) o = v . toPrecision ( 7 ) ;
else if ( V >= 0.0001 && V < 0.001 ) o = v . toPrecision ( 6 ) ;
else if ( V >= Math . pow ( 10 , 10 ) && V < Math . pow ( 10 , 11 ) ) o = v . toFixed ( 10 ) . substr ( 0 , 12 ) ;
else if ( V > Math . pow ( 10 , - 9 ) && V < Math . pow ( 10 , 11 ) ) {
o = v . toFixed ( 12 ) . replace ( /(\.[0-9]*[1-9])0*$/ , "$1" ) . replace ( /\.$/ , "" ) ;
2014-05-03 18:51:10 +00:00
if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toPrecision ( 10 ) ;
if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toExponential ( 5 ) ;
2014-02-17 08:44:22 +00:00
}
else {
o = v . toFixed ( 11 ) . replace ( /(\.[0-9]*[1-9])0*$/ , "$1" ) ;
2014-05-03 18:51:10 +00:00
if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toPrecision ( 6 ) ;
2014-02-17 08:44:22 +00:00
}
o = o . replace ( /(\.[0-9]*[1-9])0+e/ , "$1e" ) . replace ( /\.0*e/ , "e" ) ;
return o . replace ( "e" , "E" ) . replace ( /\.0*$/ , "" ) . replace ( /\.([0-9]*[^0])0*$/ , ".$1" ) . replace ( /(E[+-])([0-9])$/ , "$1" + "0" + "$2" ) ;
}
if ( typeof v === 'string' ) return v ;
throw new Error ( "unsupported value in General format: " + v ) ;
} ;
SSF . _general = general _fmt ;
2014-05-03 18:51:10 +00:00
function fix _hijri ( date , o ) { return 0 ; }
2014-04-03 22:51:54 +00:00
var parse _date _code = function parse _date _code ( v , opts , b2 ) {
2014-02-17 08:44:22 +00:00
var date = Math . floor ( v ) , time = Math . floor ( 86400 * ( v - date ) + 1e-6 ) , dow = 0 ;
2014-05-03 18:51:10 +00:00
var dout = [ ] ;
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 } ;
fixopts ( opts = ( opts || { } ) ) ;
2014-02-17 08:44:22 +00:00
if ( opts . date1904 ) date += 1462 ;
if ( date > 2958465 ) return null ;
2014-03-29 22:53:15 +00:00
if ( out . u > 0.999 ) {
2014-03-29 02:05:50 +00:00
out . u = 0 ;
if ( ++ time == 86400 ) { time = 0 ; ++ date ; }
}
2014-04-03 22:51:54 +00:00
if ( date === 60 ) { dout = b2 ? [ 1317 , 10 , 29 ] : [ 1900 , 2 , 29 ] ; dow = 3 ; }
else if ( date === 0 ) { dout = b2 ? [ 1317 , 8 , 29 ] : [ 1900 , 1 , 0 ] ; dow = 6 ; }
2014-02-17 08:44:22 +00:00
else {
if ( date > 60 ) -- date ;
/* 1 = Jan 1 1900 */
var d = new Date ( 1900 , 0 , 1 ) ;
d . setDate ( d . getDate ( ) + date - 1 ) ;
dout = [ d . getFullYear ( ) , d . getMonth ( ) + 1 , d . getDate ( ) ] ;
dow = d . getDay ( ) ;
2014-04-03 22:51:54 +00:00
if ( date < 60 ) dow = ( dow + 6 ) % 7 ;
if ( b2 ) dow = fix _hijri ( d , dout ) ;
2014-02-17 08:44:22 +00:00
}
out . y = dout [ 0 ] ; out . m = dout [ 1 ] ; out . d = dout [ 2 ] ;
out . S = time % 60 ; time = Math . floor ( time / 60 ) ;
out . M = time % 60 ; time = Math . floor ( time / 60 ) ;
out . H = time ;
out . q = dow ;
return out ;
} ;
SSF . parse _date _code = parse _date _code ;
/*jshint -W086 */
2014-05-22 12:16:51 +00:00
var write _date = function ( type , fmt , val , ss0 ) {
var o , ss , tt , y = val . y , sss0 ;
2014-02-17 08:44:22 +00:00
switch ( type ) {
2014-04-03 22:51:54 +00:00
case 'b' : y = val . y + 543 ;
/* falls through */
case 'y' : switch ( fmt . length ) { /* year */
case 1 : case 2 : return pad ( y % 100 , 2 ) ;
default : return pad ( y % 10000 , 4 ) ;
2014-02-17 08:44:22 +00:00
}
2014-04-03 22:51:54 +00:00
case 'm' : switch ( fmt ) {
2014-02-17 08:44:22 +00:00
case 'm' : return val . m ;
case 'mm' : return pad ( val . m , 2 ) ;
case 'mmm' : return months [ val . m - 1 ] [ 1 ] ;
case 'mmmmm' : return months [ val . m - 1 ] [ 0 ] ;
default : return months [ val . m - 1 ] [ 2 ] ;
}
case 'd' : switch ( fmt ) { /* day */
case 'd' : return val . d ;
case 'dd' : return pad ( val . d , 2 ) ;
case 'ddd' : return days [ val . q ] [ 0 ] ;
default : return days [ val . q ] [ 1 ] ;
}
case 'h' : switch ( fmt ) { /* 12-hour */
case 'h' : return 1 + ( val . H + 11 ) % 12 ;
case 'hh' : return pad ( 1 + ( val . H + 11 ) % 12 , 2 ) ;
default : throw 'bad hour format: ' + fmt ;
}
case 'H' : switch ( fmt ) { /* 24-hour */
case 'h' : return val . H ;
case 'hh' : return pad ( val . H , 2 ) ;
default : throw 'bad hour format: ' + fmt ;
}
case 'M' : switch ( fmt ) { /* minutes */
case 'm' : return val . M ;
case 'mm' : return pad ( val . M , 2 ) ;
default : throw 'bad minute format: ' + fmt ;
}
case 's' : switch ( fmt ) { /* seconds */
2014-05-22 12:16:51 +00:00
case 's' : case 'ss' : case '.0' : case '.00' : case '.000' :
sss0 = ss0 || 0 ;
tt = Math . pow ( 10 , sss0 ) ;
ss = Math . round ( ( tt ) * ( val . S + val . u ) ) ;
if ( fmt === 's' ) return ss >= 60 * tt ? 0 : ss / tt ;
else if ( fmt === 'ss' ) { if ( ss >= 60 * tt ) ss = 0 ; return pad ( ss , ( 2 + sss0 ) ) . substr ( 0 , 2 ) ; }
if ( ss >= 60 * tt ) ss = 0 ;
o = pad ( ss , 2 + sss0 ) ;
return "." + o . substr ( 2 , fmt . length - 1 ) ;
2014-02-17 08:44:22 +00:00
default : throw 'bad second format: ' + fmt ;
}
case 'Z' : switch ( fmt ) {
case '[h]' : case '[hh]' : o = val . D * 24 + val . H ; break ;
case '[m]' : case '[mm]' : o = ( val . D * 24 + val . H ) * 60 + val . M ; break ;
case '[s]' : case '[ss]' : o = ( ( val . D * 24 + val . H ) * 60 + val . M ) * 60 + Math . round ( val . S + val . u ) ; break ;
default : throw 'bad abstime format: ' + fmt ;
} return fmt . length === 3 ? o : pad ( o , 2 ) ;
case 'e' : { return val . y ; } break ;
}
} ;
/*jshint +W086 */
var commaify = function ( s ) { return _strrev ( _strrev ( s ) . replace ( /.../g , "$&," ) ) . replace ( /^,/ , "" ) ; } ;
var write _num = function ( type , fmt , val ) {
2014-03-29 22:53:15 +00:00
if ( type === '(' && ! fmt . match ( /\).*[0#]/ ) ) {
2014-02-17 08:44:22 +00:00
var ffmt = fmt . replace ( /\( */ , "" ) . replace ( / \)/ , "" ) . replace ( /\)/ , "" ) ;
if ( val >= 0 ) return write _num ( 'n' , ffmt , val ) ;
return '(' + write _num ( 'n' , ffmt , - val ) + ')' ;
}
var mul = 0 , o ;
2014-03-29 22:53:15 +00:00
fmt = fmt . replace ( /%/g , function ( ) { mul ++ ; return "" ; } ) ;
2014-02-17 08:44:22 +00:00
if ( mul !== 0 ) return write _num ( type , fmt , val * Math . pow ( 10 , 2 * mul ) ) + fill ( "%" , mul ) ;
2014-03-29 02:05:50 +00:00
fmt = fmt . replace ( /(\.0+)(,+)$/g , function ( $$ , $1 , $2 ) { mul = $2 . length ; return $1 ; } ) ;
if ( mul !== 0 ) return write _num ( type , fmt , val / Math . pow ( 10 , 3 * mul ) ) ;
2014-02-17 08:44:22 +00:00
if ( fmt . indexOf ( "E" ) > - 1 ) {
var idx = fmt . indexOf ( "E" ) - fmt . indexOf ( "." ) - 1 ;
if ( fmt . match ( /^#+0.0E\+0$/ ) ) {
2014-04-23 01:37:08 +00:00
var period = fmt . indexOf ( "." ) ; if ( period === - 1 ) period = fmt . indexOf ( 'E' ) ;
2014-05-03 18:51:10 +00:00
var ee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ? 1 : 0 ) ) ) ) % period ;
2014-02-17 08:44:22 +00:00
if ( ee < 0 ) ee += period ;
o = ( val / Math . pow ( 10 , ee ) ) . toPrecision ( idx + 1 + ( period + ee ) % period ) ;
if ( ! o . match ( /[Ee]/ ) ) {
2014-05-03 18:51:10 +00:00
var fakee = ( Number ( val . toExponential ( 0 ) . substr ( 2 + ( val < 0 ? 1 : 0 ) ) ) ) ;
2014-02-17 08:44:22 +00:00
if ( o . indexOf ( "." ) === - 1 ) o = o [ 0 ] + "." + o . substr ( 1 ) + "E+" + ( fakee - o . length + ee ) ;
else o += "E+" + ( fakee - ee ) ;
while ( o . substr ( 0 , 2 ) === "0." ) {
o = o [ 0 ] + o . substr ( 2 , period ) + "." + o . substr ( 2 + period ) ;
o = o . replace ( /^0+([1-9])/ , "$1" ) . replace ( /^0+\./ , "0." ) ;
}
o = o . replace ( /\+-/ , "-" ) ;
}
o = o . replace ( /^([+-]?)([0-9]*)\.([0-9]*)[Ee]/ , function ( $$ , $1 , $2 , $3 ) { return $1 + $2 + $3 . substr ( 0 , ( period + ee ) % period ) + "." + $3 . substr ( ee ) + "E" ; } ) ;
} else o = val . toExponential ( idx ) ;
if ( fmt . match ( /E\+00$/ ) && o . match ( /e[+-][0-9]$/ ) ) o = o . substr ( 0 , o . length - 1 ) + "0" + o [ o . length - 1 ] ;
if ( fmt . match ( /E\-/ ) && o . match ( /e\+/ ) ) o = o . replace ( /e\+/ , "e" ) ;
return o . replace ( "e" , "E" ) ;
}
if ( fmt [ 0 ] === "$" ) return "$" + write _num ( type , fmt . substr ( fmt [ 1 ] == ' ' ? 2 : 1 ) , val ) ;
var r , rr , ff , aval = val < 0 ? - val : val , sign = val < 0 ? "-" : "" ;
if ( ( r = fmt . match ( /# (\?+)([ ]?)\/([ ]?)(\d+)/ ) ) ) {
var den = Number ( r [ 4 ] ) , rnd = Math . round ( aval * den ) , base = Math . floor ( rnd / den ) ;
var myn = ( rnd - base * den ) , myd = den ;
2014-05-03 18:51:10 +00:00
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 ) ) ;
2014-02-17 08:44:22 +00:00
}
if ( fmt . match ( /^#+0+$/ ) ) fmt = fmt . replace ( /#/g , "" ) ;
if ( fmt . match ( /^00+$/ ) ) return ( val < 0 ? "-" : "" ) + pad ( Math . round ( aval ) , fmt . length ) ;
if ( fmt . match ( /^[#?]+$/ ) ) return String ( Math . round ( val ) ) . replace ( /^0$/ , "" ) ;
2014-03-29 02:05:50 +00:00
if ( ( r = fmt . match ( /^#*0*\.(0+)/ ) ) ) {
2014-02-17 08:44:22 +00:00
o = Math . round ( val * Math . pow ( 10 , r [ 1 ] . length ) ) ;
2014-03-29 02:05:50 +00:00
rr = String ( o / Math . pow ( 10 , r [ 1 ] . length ) ) . replace ( /^([^\.]+)$/ , "$1." + r [ 1 ] ) . replace ( /\.$/ , "." + r [ 1 ] ) . replace ( /\.([0-9]*)$/ , function ( $$ , $1 ) { return "." + $1 + fill ( "0" , r [ 1 ] . length - $1 . length ) ; } ) ;
return fmt . match ( /0\./ ) ? rr : rr . replace ( /^0\./ , "." ) ;
2014-02-17 08:44:22 +00:00
}
2014-03-29 02:05:50 +00:00
fmt = fmt . replace ( /^#+([0.])/ , "$1" ) ;
2014-02-17 08:44:22 +00:00
if ( ( r = fmt . match ( /^(0*)\.(#*)$/ ) ) ) {
2014-03-19 17:53:20 +00:00
o = Math . round ( aval * Math . pow ( 10 , r [ 2 ] . length ) ) ;
return sign + String ( o / Math . pow ( 10 , r [ 2 ] . length ) ) . replace ( /\.(\d*[1-9])0*$/ , ".$1" ) . replace ( /^([-]?\d*)$/ , "$1." ) . replace ( /^0\./ , r [ 1 ] . length ? "0." : "." ) ;
2014-02-17 08:44:22 +00:00
}
if ( ( r = fmt . match ( /^#,##0([.]?)$/ ) ) ) return sign + commaify ( String ( Math . round ( aval ) ) ) ;
if ( ( r = fmt . match ( /^#,##0\.([#0]*0)$/ ) ) ) {
rr = Math . round ( ( val - Math . floor ( val ) ) * Math . pow ( 10 , r [ 1 ] . length ) ) ;
return val < 0 ? "-" + write _num ( type , fmt , - val ) : commaify ( String ( Math . floor ( val ) ) ) + "." + pad ( rr , r [ 1 ] . length , 0 ) ;
}
2014-03-29 02:05:50 +00:00
if ( ( r = fmt . match ( /^#,#*,#0/ ) ) ) return write _num ( type , fmt . replace ( /^#,#*,/ , "" ) , val ) ;
2014-05-03 18:51:10 +00:00
if ( ( r = fmt . match ( /^([0#]+)(\\?-([0#]+))+$/ ) ) ) {
ff = _strrev ( write _num ( type , fmt . replace ( /[\\-]/g , "" ) , val ) ) ;
rr = 0 ;
return _strrev ( _strrev ( fmt . replace ( /\\/g , "" ) ) . replace ( /[0#]/g , function ( x ) { return rr < ff . length ? ff [ rr ++ ] : x === '0' ? '0' : '' ; } ) ) ;
2014-03-29 22:53:15 +00:00
}
2014-04-03 22:51:54 +00:00
if ( fmt . match ( /\(###\) ###\\?-####/ ) ) {
2014-03-29 22:53:15 +00:00
ff = write _num ( type , "##########" , val ) ;
return "(" + ff . substr ( 0 , 3 ) + ") " + ff . substr ( 3 , 3 ) + "-" + ff . substr ( 6 ) ;
}
2014-03-29 02:05:50 +00:00
if ( ( r = fmt . match ( /^([?]+)([ ]?)\/([ ]?)([?]+)/ ) ) ) {
rr = Math . min ( Math . max ( r [ 1 ] . length , r [ 4 ] . length ) , 7 ) ;
ff = frac ( aval , Math . pow ( 10 , rr ) - 1 , false ) ;
return sign + ( ff [ 0 ] || ( ff [ 1 ] ? "" : "0" ) ) + ( ff [ 1 ] ? pad ( ff [ 1 ] , rr , " " ) + r [ 2 ] + "/" + r [ 3 ] + rpad ( ff [ 2 ] , rr , " " ) : fill ( " " , 2 * rr + 1 + r [ 2 ] . length + r [ 3 ] . length ) ) ;
}
2014-02-17 08:44:22 +00:00
if ( ( r = fmt . match ( /^# ([?]+)([ ]?)\/([ ]?)([?]+)/ ) ) ) {
rr = Math . min ( Math . max ( r [ 1 ] . length , r [ 4 ] . length ) , 7 ) ;
ff = frac ( aval , Math . pow ( 10 , rr ) - 1 , true ) ;
return sign + ( ff [ 0 ] || ( ff [ 1 ] ? "" : "0" ) ) + " " + ( ff [ 1 ] ? pad ( ff [ 1 ] , rr , " " ) + r [ 2 ] + "/" + r [ 3 ] + rpad ( ff [ 2 ] , rr , " " ) : fill ( " " , 2 * rr + 1 + r [ 2 ] . length + r [ 3 ] . length ) ) ;
}
2014-05-22 12:16:51 +00:00
if ( ( r = fmt . match ( /^[#0]+$/ ) ) ) {
o = "" + Math . round ( val ) ;
if ( fmt . length <= o . length ) return o ;
return fmt . substr ( 0 , fmt . length - o . length ) . replace ( /#/g , "" ) + o ;
}
if ( ( r = fmt . match ( /^([#0]+)\.([#0]+)$/ ) ) ) {
o = "" + val . toFixed ( Math . min ( r [ 2 ] . length , 10 ) ) . replace ( /([^0])0+$/ , "$1" ) ;
rr = o . indexOf ( "." ) ;
var lres = fmt . indexOf ( "." ) - rr , rres = fmt . length - o . length - lres ;
return fmt . substr ( 0 , lres ) . replace ( /#/g , "" ) + o + fmt . substr ( fmt . length - rres ) . replace ( /#/g , "" ) ;
}
2014-03-29 02:05:50 +00:00
if ( ( r = fmt . match ( /^00,000\.([#0]*0)$/ ) ) ) {
rr = val == Math . floor ( val ) ? 0 : Math . round ( ( val - Math . floor ( val ) ) * Math . pow ( 10 , r [ 1 ] . length ) ) ;
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 ) ;
}
2014-02-17 08:44:22 +00:00
switch ( fmt ) {
case "#,###" : var x = commaify ( String ( Math . round ( aval ) ) ) ; return x !== "0" ? sign + x : "" ;
default :
}
throw new Error ( "unsupported format |" + fmt + "|" ) ;
} ;
function split _fmt ( fmt ) {
var out = [ ] ;
var in _str = - 1 ;
for ( var i = 0 , j = 0 ; i < fmt . length ; ++ i ) {
if ( in _str != - 1 ) { if ( fmt [ i ] == '"' ) in _str = - 1 ; continue ; }
if ( fmt [ i ] == "_" || fmt [ i ] == "*" || fmt [ i ] == "\\" ) { ++ i ; continue ; }
if ( fmt [ i ] == '"' ) { in _str = i ; continue ; }
if ( fmt [ i ] != ";" ) continue ;
out . push ( fmt . slice ( j , i ) ) ;
j = i + 1 ;
}
out . push ( fmt . slice ( j ) ) ;
if ( in _str != - 1 ) throw new Error ( "Format |" + fmt + "| unterminated string at " + in _str ) ;
return out ;
}
SSF . _split = split _fmt ;
function eval _fmt ( fmt , v , opts , flen ) {
2014-05-22 12:16:51 +00:00
var out = [ ] , o = "" , i = 0 , c = "" , lst = 't' , q , dt , j ;
2014-02-17 08:44:22 +00:00
fixopts ( opts = ( opts || { } ) ) ;
var hr = 'H' ;
/* Tokenize */
while ( i < fmt . length ) {
switch ( ( c = fmt [ i ] ) ) {
case 'G' : /* General */
2014-04-03 22:51:54 +00:00
if ( fmt . substr ( i , 7 ) . toLowerCase ( ) !== "general" )
2014-02-17 08:44:22 +00:00
throw new Error ( 'unrecognized character ' + fmt [ i ] + ' in ' + fmt ) ;
out . push ( { t : 'G' , v : 'General' } ) ; i += 7 ; break ;
case '"' : /* Literal text */
for ( o = "" ; fmt [ ++ i ] !== '"' && i < fmt . length ; ) o += fmt [ i ] ;
out . push ( { t : 't' , v : o } ) ; ++ i ; break ;
case '\\' : var w = fmt [ ++ i ] , t = "()" . indexOf ( w ) === - 1 ? 't' : w ;
out . push ( { t : t , v : w } ) ; ++ i ; break ;
case '_' : out . push ( { t : 't' , v : " " } ) ; i += 2 ; break ;
case '@' : /* Text Placeholder */
out . push ( { t : 'T' , v : v } ) ; ++ i ; break ;
2014-04-03 22:51:54 +00:00
case 'B' : case 'b' :
if ( fmt [ i + 1 ] === "1" || fmt [ i + 1 ] === "2" ) {
if ( ! dt ) dt = parse _date _code ( v , opts , fmt [ i + 1 ] === "2" ) ;
q = { t : 'X' , v : fmt . substr ( i , 2 ) } ; out . push ( q ) ; lst = c ; i += 2 ; break ;
}
/* falls through */
2014-02-17 08:44:22 +00:00
case 'M' : case 'D' : case 'Y' : case 'H' : case 'S' : case 'E' :
c = c . toLowerCase ( ) ;
/* falls through */
2014-03-29 02:05:50 +00:00
case 'm' : case 'd' : case 'y' : case 'h' : case 's' : case 'e' : case 'g' :
2014-02-17 08:44:22 +00:00
if ( v < 0 ) return "" ;
if ( ! dt ) dt = parse _date _code ( v , opts ) ;
if ( ! dt ) return "" ;
o = fmt [ i ] ; while ( ( fmt [ ++ i ] || "" ) . toLowerCase ( ) === c ) o += c ;
if ( c === 'm' && lst . toLowerCase ( ) === 'h' ) c = 'M' ; /* m = minute */
if ( c === 'h' ) c = hr ;
o = o . toLowerCase ( ) ;
q = { t : c , v : o } ; out . push ( q ) ; lst = c ; break ;
case 'A' :
if ( ! dt ) dt = parse _date _code ( v , opts ) ;
if ( ! dt ) return "" ;
q = { t : c , v : "A" } ;
if ( fmt . substr ( i , 3 ) === "A/P" ) { q . v = dt . H >= 12 ? "P" : "A" ; q . t = 'T' ; hr = 'h' ; i += 3 ; }
else if ( fmt . substr ( i , 5 ) === "AM/PM" ) { q . v = dt . H >= 12 ? "PM" : "AM" ; q . t = 'T' ; i += 5 ; hr = 'h' ; }
else { q . t = "t" ; i ++ ; }
out . push ( q ) ; lst = c ; break ;
2014-04-03 22:51:54 +00:00
case '[' :
2014-02-17 08:44:22 +00:00
o = c ;
while ( fmt [ i ++ ] !== ']' && i < fmt . length ) o += fmt [ i ] ;
if ( o . substr ( - 1 ) !== ']' ) throw 'unterminated "[" block: |' + o + '|' ;
if ( o . match ( /\[[HhMmSs]*\]/ ) ) {
if ( ! dt ) dt = parse _date _code ( v , opts ) ;
if ( ! dt ) return "" ;
out . push ( { t : 'Z' , v : o . toLowerCase ( ) } ) ;
} else { o = "" ; }
break ;
/* Numbers */
2014-05-22 12:16:51 +00:00
case '.' :
if ( dt ) {
o = c ; while ( ( c = fmt [ ++ i ] ) === "0" ) o += c ;
out . push ( { t : 's' , v : o } ) ; break ;
}
/* falls through */
case '0' : case '#' :
2014-04-03 22:51:54 +00:00
o = c ; while ( "0#?.,E+-%" . indexOf ( c = fmt [ ++ i ] ) > - 1 || c == '\\' && fmt [ i + 1 ] == "-" && "0#" . indexOf ( fmt [ i + 2 ] ) > - 1 ) o += c ;
2014-02-17 08:44:22 +00:00
out . push ( { t : 'n' , v : o } ) ; break ;
case '?' :
o = fmt [ i ] ; while ( fmt [ ++ i ] === c ) o += c ;
q = { t : c , v : o } ; out . push ( q ) ; lst = c ; break ;
2014-03-29 02:05:50 +00:00
case '*' : ++ i ; if ( fmt [ i ] == ' ' || fmt [ i ] == '*' ) ++ i ; break ; // **
2014-02-17 08:44:22 +00:00
case '(' : case ')' : out . push ( { t : ( flen === 1 ? 't' : c ) , v : c } ) ; ++ i ; break ;
case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' :
o = fmt [ i ] ; while ( "0123456789" . indexOf ( fmt [ ++ i ] ) > - 1 ) o += fmt [ i ] ;
out . push ( { t : 'D' , v : o } ) ; break ;
case ' ' : out . push ( { t : c , v : c } ) ; ++ i ; break ;
default :
2014-04-03 22:51:54 +00:00
if ( ",$-+/():!^&'~{}<>=€acfijklopqrtuvwxz" . indexOf ( c ) === - 1 )
2014-02-17 08:44:22 +00:00
throw 'unrecognized character ' + fmt [ i ] + ' in ' + fmt ;
out . push ( { t : 't' , v : c } ) ; ++ i ; break ;
}
}
2014-05-22 12:16:51 +00:00
var bt = 0 , ss0 = 0 , ssm ;
2014-02-17 08:44:22 +00:00
for ( i = out . length - 1 , lst = 't' ; i >= 0 ; -- i ) {
switch ( out [ i ] . t ) {
2014-03-29 02:05:50 +00:00
case 'h' : case 'H' : out [ i ] . t = hr ; lst = 'h' ; if ( bt < 1 ) bt = 1 ; break ;
2014-05-22 12:16:51 +00:00
case 's' :
if ( ( ssm = out [ i ] . v . match ( /\.0+$/ ) ) ) ss0 = Math . max ( ss0 , ssm [ 0 ] . length - 1 ) ;
if ( bt < 3 ) bt = 3 ;
2014-03-29 02:05:50 +00:00
/* falls through */
case 'd' : case 'y' : case 'M' : case 'e' : lst = out [ i ] . t ; break ;
case 'm' : if ( lst === 's' ) { out [ i ] . t = 'M' ; if ( bt < 2 ) bt = 2 ; } break ;
2014-04-03 22:51:54 +00:00
case 'X' : if ( out [ i ] . v === "B2" ) ;
break ;
2014-03-29 02:05:50 +00:00
case 'Z' :
if ( bt < 1 && out [ i ] . v . match ( /[Hh]/ ) ) bt = 1 ;
if ( bt < 2 && out [ i ] . v . match ( /[Mm]/ ) ) bt = 2 ;
if ( bt < 3 && out [ i ] . v . match ( /[Ss]/ ) ) bt = 3 ;
2014-02-17 08:44:22 +00:00
}
}
2014-03-29 02:05:50 +00:00
switch ( bt ) {
case 0 : break ;
case 1 :
2014-03-29 22:53:15 +00:00
if ( dt . u >= 0.5 ) { dt . u = 0 ; ++ dt . S ; }
2014-03-29 02:05:50 +00:00
if ( dt . S >= 60 ) { dt . S = 0 ; ++ dt . M ; }
if ( dt . M >= 60 ) { dt . M = 0 ; ++ dt . H ; }
break ;
case 2 :
2014-03-29 22:53:15 +00:00
if ( dt . u >= 0.5 ) { dt . u = 0 ; ++ dt . S ; }
2014-03-29 02:05:50 +00:00
if ( dt . S >= 60 ) { dt . S = 0 ; ++ dt . M ; }
break ;
}
2014-02-17 08:44:22 +00:00
/* replace fields */
2014-05-22 12:16:51 +00:00
var nstr = "" , jj ;
2014-02-17 08:44:22 +00:00
for ( i = 0 ; i < out . length ; ++ i ) {
switch ( out [ i ] . t ) {
case 't' : case 'T' : case ' ' : case 'D' : break ;
2014-04-03 22:51:54 +00:00
case 'X' : delete out [ i ] ; break ;
case 'd' : case 'm' : case 'y' : case 'h' : case 'H' : case 'M' : case 's' : case 'e' : case 'b' : case 'Z' :
2014-05-22 12:16:51 +00:00
out [ i ] . v = write _date ( out [ i ] . t , out [ i ] . v , dt , ss0 ) ;
2014-02-17 08:44:22 +00:00
out [ i ] . t = 't' ; break ;
case 'n' : case '(' : case '?' :
2014-05-22 12:16:51 +00:00
jj = i + 1 ;
2014-03-29 22:53:15 +00:00
while ( out [ jj ] && ( "?D" . indexOf ( out [ jj ] . t ) > - 1 || ( " t" . indexOf ( out [ jj ] . t ) > - 1 && "?t" . indexOf ( ( out [ jj + 1 ] || { } ) . t ) > - 1 && ( out [ jj + 1 ] . t == '?' || out [ jj + 1 ] . v == '/' ) ) || out [ i ] . t == '(' && ( ")n " . indexOf ( out [ jj ] . t ) > - 1 ) || out [ jj ] . t == 't' && ( out [ jj ] . v == '/' || '$€' . indexOf ( out [ jj ] . v ) > - 1 || ( out [ jj ] . v == ' ' && ( out [ jj + 1 ] || { } ) . t == '?' ) ) ) ) {
2014-02-17 08:44:22 +00:00
out [ i ] . v += out [ jj ] . v ;
delete out [ jj ] ; ++ jj ;
}
2014-05-22 12:16:51 +00:00
nstr += out [ i ] . v ;
2014-02-17 08:44:22 +00:00
i = jj - 1 ; break ;
case 'G' : out [ i ] . t = 't' ; out [ i ] . v = general _fmt ( v , opts ) ; break ;
}
}
2014-05-22 12:16:51 +00:00
if ( nstr ) {
var ostr = write _num ( nstr [ 0 ] == '(' ? '(' : 'n' , nstr , ( v < 0 && nstr [ 0 ] == "-" ? - v : v ) ) ;
jj = ostr . length - 1 ;
var decpt = out . length ;
for ( i = 0 ; i < out . length ; ++ i ) if ( out [ i ] && out [ i ] . v . indexOf ( "." ) > - 1 ) { decpt = i ; break ; }
var lasti = out . length , vv ;
if ( decpt === out . length && ! ostr . match ( /E/ ) ) {
for ( i = out . length - 1 ; i >= 0 ; -- i ) {
if ( ! out [ i ] || 'n?(' . indexOf ( out [ i ] . t ) === - 1 ) continue ;
vv = out [ i ] . v . split ( "" ) ;
for ( j = vv . length - 1 ; j >= 0 ; -- j ) {
if ( jj >= 0 ) vv [ j ] = ostr [ jj -- ] ;
else vv [ j ] = "" ;
}
out [ i ] . v = vv . join ( "" ) ;
out [ i ] . t = 't' ;
lasti = i ;
}
if ( jj >= 0 && lasti < out . length ) out [ lasti ] . v = ostr . substr ( 0 , jj + 1 ) + out [ lasti ] . v ;
}
else if ( decpt !== out . length && ! ostr . match ( /E/ ) ) {
jj = ostr . indexOf ( "." ) - 1 ;
for ( i = decpt ; i >= 0 ; -- i ) {
if ( ! out [ i ] || 'n?(' . indexOf ( out [ i ] . t ) === - 1 ) continue ;
vv = out [ i ] . v . split ( "" ) ;
for ( j = out [ i ] . v . indexOf ( "." ) > - 1 && i == decpt ? out [ i ] . v . indexOf ( "." ) - 1 : vv . length - 1 ; j >= 0 ; -- j ) {
if ( jj >= 0 && "0#" . indexOf ( vv [ j ] ) > - 1 ) vv [ j ] = ostr [ jj -- ] ;
else vv [ j ] = "" ;
}
out [ i ] . v = vv . join ( "" ) ;
out [ i ] . t = 't' ;
lasti = i ;
}
if ( jj >= 0 && lasti < out . length ) out [ lasti ] . v = ostr . substr ( 0 , jj + 1 ) + out [ lasti ] . v ;
jj = ostr . indexOf ( "." ) + 1 ;
for ( i = decpt ; i < out . length ; ++ i ) {
if ( ! out [ i ] || 'n?(' . indexOf ( out [ i ] . t ) === - 1 && i != decpt ) continue ;
vv = out [ i ] . v . split ( "" ) ;
for ( j = out [ i ] . v . indexOf ( "." ) > - 1 && i == decpt ? out [ i ] . v . indexOf ( "." ) + 1 : 0 ; j < vv . length ; ++ j ) {
if ( jj < ostr . length ) vv [ j ] = ostr [ jj ++ ] ;
else vv [ j ] = "" ;
}
out [ i ] . v = vv . join ( "" ) ;
out [ i ] . t = 't' ;
lasti = i ;
}
}
}
for ( i = 0 ; i < out . length ; ++ i ) if ( out [ i ] && 'n(?' . indexOf ( out [ i ] . t ) > - 1 ) {
out [ i ] . v = write _num ( out [ i ] . t , out [ i ] . v , ( flen > 1 && v < 0 && i > 0 && out [ i - 1 ] . v == "-" ? - v : v ) ) ;
out [ i ] . t = 't' ;
}
2014-02-17 08:44:22 +00:00
return out . map ( function ( x ) { return x . v ; } ) . join ( "" ) ;
}
SSF . _eval = eval _fmt ;
function choose _fmt ( fmt , v , o ) {
if ( typeof fmt === 'number' ) fmt = ( ( o && o . table ) ? o . table : table _fmt ) [ fmt ] ;
if ( typeof fmt === "string" ) fmt = split _fmt ( fmt ) ;
var l = fmt . length ;
if ( l < 4 && fmt [ l - 1 ] . indexOf ( "@" ) > - 1 ) -- l ;
switch ( fmt . length ) {
case 1 : fmt = fmt [ 0 ] . indexOf ( "@" ) > - 1 ? [ "General" , "General" , "General" , fmt [ 0 ] ] : [ fmt [ 0 ] , fmt [ 0 ] , fmt [ 0 ] , "@" ] ; break ;
case 2 : fmt = fmt [ 1 ] . indexOf ( "@" ) > - 1 ? [ fmt [ 0 ] , fmt [ 0 ] , fmt [ 0 ] , fmt [ 1 ] ] : [ fmt [ 0 ] , fmt [ 1 ] , fmt [ 0 ] , "@" ] ; break ;
case 3 : fmt = fmt [ 2 ] . indexOf ( "@" ) > - 1 ? [ fmt [ 0 ] , fmt [ 1 ] , fmt [ 0 ] , fmt [ 2 ] ] : [ fmt [ 0 ] , fmt [ 1 ] , fmt [ 2 ] , "@" ] ; break ;
case 4 : break ;
default : throw "cannot find right format for |" + fmt + "|" ;
}
if ( typeof v !== "number" ) return [ fmt . length , fmt [ 3 ] ] ;
2014-03-29 22:53:15 +00:00
var ff = v > 0 ? fmt [ 0 ] : v < 0 ? fmt [ 1 ] : fmt [ 2 ] ;
if ( fmt [ 0 ] . match ( /\[[=<>]/ ) || fmt [ 1 ] . match ( /\[[=<>]/ ) ) {
var chk = function ( v , rr , out ) {
if ( ! rr ) return null ;
var found = false ;
var thresh = Number ( rr [ 2 ] ) ;
switch ( rr [ 1 ] ) {
case "=" : if ( v == thresh ) found = true ; break ;
case ">" : if ( v > thresh ) found = true ; break ;
case "<" : if ( v < thresh ) found = true ; break ;
case "<>" : if ( v != thresh ) found = true ; break ;
case ">=" : if ( v >= thresh ) found = true ; break ;
case "<=" : if ( v <= thresh ) found = true ; break ;
}
return found ? out : null ;
} ;
var m1 = fmt [ 0 ] . match ( /\[([=<>]*)([-]?\d+)\]/ ) ;
var m2 = fmt [ 1 ] . match ( /\[([=<>]*)([-]?\d+)\]/ ) ;
return chk ( v , m1 , [ l , fmt [ 0 ] ] ) || chk ( v , m2 , [ l , fmt [ 1 ] ] ) || [ l , fmt [ m1 && m2 ? 2 : 1 ] ] ;
}
return [ l , ff ] ;
2014-02-17 08:44:22 +00:00
}
var format = function format ( fmt , v , o ) {
fixopts ( o = ( o || { } ) ) ;
if ( typeof fmt === "string" && fmt . toLowerCase ( ) === "general" ) return general _fmt ( v , o ) ;
if ( typeof fmt === 'number' ) fmt = ( o . table || table _fmt ) [ fmt ] ;
var f = choose _fmt ( fmt , v , o ) ;
if ( f [ 1 ] . toLowerCase ( ) === "general" ) return general _fmt ( v , o ) ;
if ( v === true ) v = "TRUE" ; if ( v === false ) v = "FALSE" ;
if ( v === "" || typeof v === "undefined" ) return "" ;
return eval _fmt ( f [ 1 ] , v , o , f [ 0 ] ) ;
} ;
SSF . _choose = choose _fmt ;
SSF . _table = table _fmt ;
SSF . load = function ( fmt , idx ) { table _fmt [ idx ] = fmt ; } ;
SSF . format = format ;
SSF . get _table = function ( ) { return table _fmt ; } ;
SSF . load _table = function ( tbl ) { for ( var i = 0 ; i != 0x0188 ; ++ i ) if ( tbl [ i ] ) SSF . load ( tbl [ i ] , i ) ; } ;
} ;
make _ssf ( SSF ) ;
2014-05-16 00:33:34 +00:00
function isval ( x ) { return typeof x !== "undefined" && x !== null ; }
function keys ( o ) { return Object . keys ( o ) . filter ( function ( x ) { return o . hasOwnProperty ( x ) ; } ) ; }
function evert ( obj , arr ) {
var o = { } ;
keys ( obj ) . forEach ( function ( k ) {
if ( ! obj . hasOwnProperty ( k ) ) return ;
2014-05-29 22:30:03 +00:00
if ( arr && typeof arr === "string" ) o [ obj [ k ] [ arr ] ] = k ;
2014-05-16 00:33:34 +00:00
if ( ! arr ) o [ obj [ k ] ] = k ;
else ( o [ obj [ k ] ] = o [ obj [ k ] ] || [ ] ) . push ( k ) ;
} ) ;
return o ;
}
2014-05-22 12:16:51 +00:00
/* TODO: date1904 logic */
function datenum ( v , date1904 ) {
if ( date1904 ) v += 1462 ;
var epoch = Date . parse ( v ) ;
return ( epoch - new Date ( Date . UTC ( 1899 , 11 , 30 ) ) ) / ( 24 * 60 * 60 * 1000 ) ;
}
2014-02-17 08:44:22 +00:00
function getdata ( data ) {
if ( ! data ) return null ;
2014-05-22 12:16:51 +00:00
if ( data . data ) return data . name . substr ( - 4 ) !== ".bin" ? debom _xml ( data . data ) : data . data . split ( "" ) . map ( function ( x ) { return x . charCodeAt ( 0 ) ; } ) ;
2014-02-17 08:44:22 +00:00
if ( data . asNodeBuffer && typeof Buffer !== 'undefined' && data . name . substr ( - 4 ) === ".bin" ) return data . asNodeBuffer ( ) ;
2014-05-22 12:16:51 +00:00
if ( data . asBinary && data . name . substr ( - 4 ) !== ".bin" ) return debom _xml ( data . asBinary ( ) ) ;
2014-02-17 08:44:22 +00:00
if ( data . _data && data . _data . getContent ) {
/* TODO: something far more intelligent */
if ( data . name . substr ( - 4 ) === ".bin" ) return Array . prototype . slice . call ( data . _data . getContent ( ) ) ;
return Array . prototype . slice . call ( data . _data . getContent ( ) , 0 ) . map ( function ( x ) { return String . fromCharCode ( x ) ; } ) . join ( "" ) ;
}
return null ;
}
function getzipfile ( zip , file ) {
var f = file ; if ( zip . files [ f ] ) return zip . files [ f ] ;
f = file . toLowerCase ( ) ; if ( zip . files [ f ] ) return zip . files [ f ] ;
f = f . replace ( /\//g , '\\' ) ; if ( zip . files [ f ] ) return zip . files [ f ] ;
throw new Error ( "Cannot find file " + file + " in zip" ) ;
}
function getzipdata ( zip , file , safe ) {
if ( ! safe ) return getdata ( getzipfile ( zip , file ) ) ;
if ( ! file ) return null ;
try { return getzipdata ( zip , file ) ; } catch ( e ) { return null ; }
}
var _fs , jszip ;
if ( typeof JSZip !== 'undefined' ) jszip = JSZip ;
if ( typeof exports !== 'undefined' ) {
if ( typeof module !== 'undefined' && module . exports ) {
if ( typeof Buffer !== 'undefined' && typeof jszip === 'undefined' ) jszip = require ( 'jszip' ) ;
if ( typeof jszip === 'undefined' ) jszip = require ( './jszip' ) . JSZip ;
_fs = require ( 'fs' ) ;
}
}
2014-05-03 18:51:10 +00:00
var _chr = function ( c ) { return String . fromCharCode ( c ) ; } ;
2014-05-16 00:33:34 +00:00
var _ord = function ( c ) { return c . charCodeAt ( 0 ) ; } ;
2014-04-03 22:51:54 +00:00
var attregexg = /([\w:]+)=((?:")([^"]*)(?:")|(?:')([^']*)(?:'))/g ;
var attregex = /([\w:]+)=((?:")(?:[^"]*)(?:")|(?:')(?:[^']*)(?:'))/ ;
2014-02-17 08:44:22 +00:00
function parsexmltag ( tag ) {
var words = tag . split ( /\s+/ ) ;
var z = { '0' : words [ 0 ] } ;
if ( words . length === 1 ) return z ;
2014-04-03 22:51:54 +00:00
( tag . match ( attregexg ) || [ ] ) . map ( function ( x ) {
var y = x . match ( attregex ) ;
y [ 1 ] = y [ 1 ] . replace ( /xmlns:/ , "xmlns" ) ;
z [ y [ 1 ] . replace ( /^[a-zA-Z]*:/ , "" ) ] = y [ 2 ] . substr ( 1 , y [ 2 ] . length - 2 ) ;
} ) ;
2014-02-17 08:44:22 +00:00
return z ;
}
var encodings = {
'"' : '"' ,
''' : "'" ,
'>' : '>' ,
'<' : '<' ,
'&' : '&'
} ;
var rencoding = evert ( encodings ) ;
var rencstr = "&<>'\"" . split ( "" ) ;
// TODO: CP remap (need to read file version to determine OS)
function unescapexml ( text ) {
var s = text + '' ;
2014-05-25 09:04:08 +00:00
s = s . replace ( /"/g , '"' ) . replace ( /'/g , "'" ) . replace ( />/g , ">" ) . replace ( /</g , "<" ) . replace ( /&/g , "&" ) ;
2014-02-17 08:44:22 +00:00
return s . replace ( /_x([0-9a-fA-F]*)_/g , function ( m , c ) { return _chr ( parseInt ( c , 16 ) ) ; } ) ;
}
function escapexml ( text ) {
var s = text + '' ;
rencstr . forEach ( function ( y ) { s = s . replace ( new RegExp ( y , 'g' ) , rencoding [ y ] ) ; } ) ;
2014-05-29 22:30:03 +00:00
s = s . replace ( /[\u0000-\u0008\u000b-\u001f]/g , function ( s ) { return "_x" + ( "0000" + _ord ( s ) . toString ( 16 ) ) . substr ( - 4 ) + "_" ; } ) ;
2014-02-17 08:44:22 +00:00
return s ;
}
function parsexmlbool ( value , tag ) {
switch ( value ) {
case '0' : case 0 : case 'false' : case 'FALSE' : return false ;
case '1' : case 1 : case 'true' : case 'TRUE' : return true ;
default : throw "bad boolean value " + value + " in " + ( tag || "?" ) ;
}
}
var utf8read = function ( orig ) {
2014-02-26 19:30:32 +00:00
var out = [ ] , i = 0 , c = 0 , c1 = 0 , c2 = 0 , c3 = 0 ;
2014-05-25 09:04:08 +00:00
if ( ! orig . match ( /[\u0080-\uffff]/ ) ) return orig ;
2014-02-17 08:44:22 +00:00
while ( i < orig . length ) {
c = orig . charCodeAt ( i ++ ) ;
2014-02-26 19:30:32 +00:00
if ( c < 128 ) out . push ( _chr ( c ) ) ;
2014-02-17 08:44:22 +00:00
else {
c2 = orig . charCodeAt ( i ++ ) ;
2014-02-26 19:30:32 +00:00
if ( c > 191 && c < 224 ) out . push ( _chr ( ( c & 31 ) << 6 | c2 & 63 ) ) ;
2014-02-17 08:44:22 +00:00
else {
c3 = orig . charCodeAt ( i ++ ) ;
2014-02-26 19:30:32 +00:00
out . push ( _chr ( ( c & 15 ) << 12 | ( c2 & 63 ) << 6 | c3 & 63 ) ) ;
2014-02-17 08:44:22 +00:00
}
}
}
2014-02-26 19:30:32 +00:00
return out . join ( "" ) ;
2014-02-17 08:44:22 +00:00
} ;
// matches <foo>...</foo> extracts content
2014-04-15 09:04:03 +00:00
function matchtag ( f , g ) { return new RegExp ( '<(?:\\w+:)?' + f + '(?: xml:space="preserve")?(?:[^>]*)>([^\u2603]*)</(?:\\w+:)?' + f + '>' , ( g || "" ) + "m" ) ; }
2014-02-17 08:44:22 +00:00
function parseVector ( data ) {
var h = parsexmltag ( data ) ;
var matches = data . match ( new RegExp ( "<vt:" + h . baseType + ">(.*?)</vt:" + h . baseType + ">" , 'g' ) ) || [ ] ;
if ( matches . length != h . size ) throw "unexpected vector length " + matches . length + " != " + h . size ;
var res = [ ] ;
matches . forEach ( function ( x ) {
var v = x . replace ( /<[/]?vt:variant>/g , "" ) . match ( /<vt:([^>]*)>(.*)</ ) ;
res . push ( { v : v [ 2 ] , t : v [ 1 ] } ) ;
} ) ;
return res ;
}
2014-05-16 00:33:34 +00:00
function writetag ( f , g ) { return '<' + f + ( g . match ( /(^\s|\s$|\n)/ ) ? ' xml:space="preserve"' : "" ) + '>' + g + '</' + f + '>' ; }
2014-05-29 22:30:03 +00:00
function writextag ( f , g , h ) { return '<' + f + ( h !== null && h !== undefined ? keys ( h ) . map ( function ( k ) { return " " + k + '="' + h [ k ] + '"' ; } ) . join ( "" ) : "" ) + ( g === null || g === undefined ? "/" : ( g . match ( /(^\s|\s$|\n)/ ) ? ' xml:space="preserve"' : "" ) + '>' + g + '</' + f ) + '>' ; }
2014-05-16 00:33:34 +00:00
function write _w3cdtf ( d , t ) { try { return d . toISOString ( ) . replace ( /\.\d*/ , "" ) ; } catch ( e ) { if ( t ) throw e ; } }
function write _vt ( s ) {
if ( typeof s == 'string' ) return writextag ( 'vt:lpwstr' , s ) ;
if ( typeof s == 'number' ) return writextag ( ( s | 0 ) == s ? 'vt:i4' : 'vt:r8' , String ( s ) ) ;
if ( typeof s == 'boolean' ) return writextag ( 'vt:bool' , s ? 'true' : 'false' ) ;
if ( s instanceof Date ) return writextag ( 'vt:filetime' , write _w3cdtf ( s ) ) ;
throw new Error ( "Unable to serialize " + s ) ;
}
var XML _HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n' ;
var XMLNS = {
'dc' : 'http://purl.org/dc/elements/1.1/' ,
'dcterms' : 'http://purl.org/dc/terms/' ,
'dcmitype' : 'http://purl.org/dc/dcmitype/' ,
'mx' : 'http://schemas.microsoft.com/office/mac/excel/2008/main' ,
'r' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' ,
'sjs' : 'http://schemas.openxmlformats.org/package/2006/sheetjs/core-properties' ,
'vt' : 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes' ,
'xsi' : 'http://www.w3.org/2001/XMLSchema-instance' ,
'xsd' : 'http://www.w3.org/2001/XMLSchema'
} ;
XMLNS . main = [
'http://schemas.openxmlformats.org/spreadsheetml/2006/main' ,
'http://purl.oclc.org/ooxml/spreadsheetml/main' ,
'http://schemas.microsoft.com/office/excel/2006/main' ,
'http://schemas.microsoft.com/office/excel/2006/2'
] ;
2014-02-17 08:44:22 +00:00
function readIEEE754 ( buf , idx , isLE , nl , ml ) {
if ( isLE === undefined ) isLE = true ;
if ( ! nl ) nl = 8 ;
if ( ! ml && nl === 8 ) ml = 52 ;
var e , m , el = nl * 8 - ml - 1 , eMax = ( 1 << el ) - 1 , eBias = eMax >> 1 ;
var bits = - 7 , d = isLE ? - 1 : 1 , i = isLE ? ( nl - 1 ) : 0 , s = buf [ idx + i ] ;
i += d ;
e = s & ( ( 1 << ( - bits ) ) - 1 ) ; s >>>= ( - bits ) ; bits += el ;
for ( ; bits > 0 ; e = e * 256 + buf [ idx + i ] , i += d , bits -= 8 ) ;
m = e & ( ( 1 << ( - bits ) ) - 1 ) ; e >>>= ( - bits ) ; bits += ml ;
for ( ; bits > 0 ; m = m * 256 + buf [ idx + i ] , i += d , bits -= 8 ) ;
if ( e === eMax ) return m ? NaN : ( ( s ? - 1 : 1 ) * Infinity ) ;
else if ( e === 0 ) e = 1 - eBias ;
else { m = m + Math . pow ( 2 , ml ) ; e = e - eBias ; }
return ( s ? - 1 : 1 ) * m * Math . pow ( 2 , e - ml ) ;
}
2014-05-29 22:30:03 +00:00
var _ _toBuffer , _ _ _toBuffer ;
_ _toBuffer = _ _ _toBuffer = function ( bufs ) {
var x = [ ] ;
for ( var i = 0 ; i != bufs [ 0 ] . length ; ++ i ) { x = x . concat ( bufs [ 0 ] [ i ] ) ; }
return x ;
} ;
2014-02-17 08:44:22 +00:00
if ( typeof Buffer !== "undefined" ) {
Buffer . prototype . hexlify = function ( ) { return this . toString ( 'hex' ) ; } ;
2014-05-29 22:30:03 +00:00
_ _toBuffer = function ( bufs ) { try { return Buffer . concat ( bufs [ 0 ] ) ; } catch ( e ) { return _ _ _toBuffer ( bufs ) ; } } ;
2014-02-17 08:44:22 +00:00
}
var _ _readUInt8 = function ( b , idx ) { return b . readUInt8 ? b . readUInt8 ( idx ) : b [ idx ] ; } ;
var _ _readUInt16LE = function ( b , idx ) { return b . readUInt16LE ? b . readUInt16LE ( idx ) : b [ idx + 1 ] * ( 1 << 8 ) + b [ idx ] ; } ;
var _ _readInt16LE = function ( b , idx ) { var u = _ _readUInt16LE ( b , idx ) ; if ( ! ( u & 0x8000 ) ) return u ; return ( 0xffff - u + 1 ) * - 1 ; } ;
var _ _readUInt32LE = function ( b , idx ) { return b . readUInt32LE ? b . readUInt32LE ( idx ) : b [ idx + 3 ] * ( 1 << 24 ) + b [ idx + 2 ] * ( 1 << 16 ) + b [ idx + 1 ] * ( 1 << 8 ) + b [ idx ] ; } ;
var _ _readInt32LE = function ( b , idx ) { if ( b . readInt32LE ) return b . readInt32LE ( idx ) ; var u = _ _readUInt32LE ( b , idx ) ; if ( ! ( u & 0x80000000 ) ) return u ; return ( 0xffffffff - u + 1 ) * - 1 ; } ;
var _ _readDoubleLE = function ( b , idx ) { return b . readDoubleLE ? b . readDoubleLE ( idx ) : readIEEE754 ( b , idx || 0 ) ; } ;
2014-05-29 22:30:03 +00:00
var _ _hexlify = function ( b , l ) { if ( b . hexlify ) return b . hexlify ( ( b . l || 0 ) , ( b . l || 0 ) + l ) ; return b . slice ( b . l || 0 , ( b . l || 0 ) + 16 ) . map ( function ( x ) { return ( x < 16 ? "0" : "" ) + x . toString ( 16 ) ; } ) . join ( "" ) ; } ;
2014-02-17 08:44:22 +00:00
function ReadShift ( size , t ) {
2014-05-29 22:30:03 +00:00
var o = "" , oo = [ ] , w , vv , i , loc ; t = t || 'u' ;
2014-02-17 08:44:22 +00:00
if ( size === 'ieee754' ) { size = 8 ; t = 'f' ; }
switch ( size ) {
case 1 : o = _ _readUInt8 ( this , this . l ) ; break ;
case 2 : o = ( t === 'u' ? _ _readUInt16LE : _ _readInt16LE ) ( this , this . l ) ; break ;
case 4 : o = _ _readUInt32LE ( this , this . l ) ; break ;
case 8 : if ( t === 'f' ) { o = _ _readDoubleLE ( this , this . l ) ; break ; }
/* falls through */
2014-05-29 22:30:03 +00:00
case 16 : o = _ _hexlify ( this , 16 ) ; break ;
2014-02-17 08:44:22 +00:00
2014-02-26 19:30:32 +00:00
case 'dbcs' : size = 2 * t ; loc = this . l ;
2014-02-17 08:44:22 +00:00
for ( i = 0 ; i != t ; ++ i ) {
2014-02-26 19:30:32 +00:00
oo . push ( _getchar ( _ _readUInt16LE ( this , loc ) ) ) ;
2014-02-17 08:44:22 +00:00
loc += 2 ;
2014-02-26 19:30:32 +00:00
} o = oo . join ( "" ) ; break ;
2014-02-17 08:44:22 +00:00
}
this . l += size ; return o ;
}
2014-05-29 22:30:03 +00:00
function WriteShift ( t , val , f ) {
var size , i ;
if ( t === 'ieee754' ) { f = 'f' ; t = 8 ; }
switch ( t ) {
case 1 : size = 1 ; this . writeUInt8 ( val , this . l ) ; break ;
case 4 : size = 4 ; this . writeUInt32LE ( val , this . l ) ; break ;
case 8 : size = 8 ; if ( f === 'f' ) { this . writeDoubleLE ( val , this . l ) ; break ; }
/* falls through */
case 16 : break ;
case - 4 : size = 4 ; this . writeInt32LE ( val , this . l ) ; break ;
case 'dbcs' :
for ( i = 0 ; i != val . length ; ++ i ) this . writeUInt16LE ( val . charCodeAt ( i ) , this . l + 2 * i ) ;
size = 2 * val . length ;
break ;
}
this . l += size ; return this ;
}
function prep _blob ( blob , pos , w ) {
2014-02-17 08:44:22 +00:00
blob . l = pos || 0 ;
2014-05-29 22:30:03 +00:00
if ( w ) {
var write = WriteShift . bind ( blob ) ;
blob . write _shift = write ;
return [ write ] ;
} else {
var read = ReadShift . bind ( blob ) ;
blob . read _shift = read ;
return [ read ] ;
}
2014-02-17 08:44:22 +00:00
}
function parsenoop ( blob , length ) { blob . l += length ; }
2014-05-29 22:30:03 +00:00
function writenoop ( blob , length ) { blob . l += length ; }
var new _buf = function ( sz ) {
var o = typeof Buffer !== 'undefined' ? new Buffer ( sz ) : new Array ( sz ) ;
prep _blob ( o , 0 , true ) ;
return o ;
} ;
var is _buf = function ( a ) { return ( typeof Buffer !== 'undefined' && a instanceof Buffer ) || Array . isArray ( a ) ; } ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.1.4 Record */
var recordhopper = function ( data , cb , opts ) {
var tmpbyte , cntbyte , length ;
prep _blob ( data , data . l || 0 ) ;
while ( data . l < data . length ) {
var RT = data . read _shift ( 1 ) ;
if ( RT & 0x80 ) RT = ( RT & 0x7F ) + ( ( data . read _shift ( 1 ) & 0x7F ) << 7 ) ;
var R = RecordEnum [ RT ] || RecordEnum [ 0xFFFF ] ;
tmpbyte = data . read _shift ( 1 ) ;
length = tmpbyte & 0x7F ;
for ( cntbyte = 1 ; cntbyte < 4 && ( tmpbyte & 0x80 ) ; ++ cntbyte ) length += ( ( tmpbyte = data . read _shift ( 1 ) ) & 0x7F ) << ( 7 * cntbyte ) ;
var d = R . f ( data , length , opts ) ;
if ( cb ( d , R , RT ) ) return ;
}
} ;
2014-05-16 00:33:34 +00:00
/* control buffer usage for fixed-length buffers */
2014-05-29 22:30:03 +00:00
var buf _array = function ( ) {
var bufs = [ ] , blksz = 2048 ;
var newblk = function ( sz ) {
var o = new _buf ( sz || blksz ) ;
prep _blob ( o , 0 , true ) ;
return o ;
} ;
var curbuf = newblk ( ) ;
var endbuf = function ( ) {
curbuf . length = curbuf . l ;
if ( curbuf . length > 0 ) bufs . push ( curbuf ) ;
curbuf = null ;
} ;
var next = function ( sz ) {
if ( sz < curbuf . length - curbuf . l ) return curbuf ;
endbuf ( ) ;
return ( curbuf = newblk ( Math . max ( sz + 1 , blksz ) ) ) ;
} ;
var end = function ( ) {
endbuf ( ) ;
return _ _toBuffer ( [ bufs ] ) ;
} ;
var push = function ( buf ) { endbuf ( ) ; curbuf = buf ; next ( ) ; } ;
return { next : next , push : push , end : end , _bufs : bufs } ;
} ;
var write _record = function ( ba , type , payload , length ) {
var t = evert _RE [ type ] , l ;
if ( ! length ) length = RecordEnum [ t ] . p || ( payload || [ ] ) . length || 0 ;
l = 1 + ( t >= 0x80 ? 1 : 0 ) + 1 + length ;
if ( length >= 0x80 ) ++ l ; if ( length >= 0x4000 ) ++ l ; if ( length >= 0x200000 ) ++ l ;
var o = ba . next ( l ) ;
if ( t <= 0x7F ) o . write _shift ( 1 , t ) ;
else {
o . write _shift ( 1 , ( t & 0x7F ) + 0x80 ) ;
o . write _shift ( 1 , ( t >> 7 ) ) ;
}
for ( var i = 0 ; i != 4 ; ++ i ) {
if ( length >= 0x80 ) { o . write _shift ( 1 , ( length & 0x7F ) + 0x80 ) ; length >>= 7 ; }
else { o . write _shift ( 1 , length ) ; break ; }
}
if ( length > 0 && is _buf ( payload ) ) ba . push ( payload ) ;
2014-05-16 00:33:34 +00:00
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.5.143 */
var parse _StrRun = function ( data , length ) {
return { ich : data . read _shift ( 2 ) , ifnt : data . read _shift ( 2 ) } ;
} ;
/* [MS-XLSB] 2.1.7.121 */
var parse _RichStr = function ( data , length ) {
var start = data . l ;
var flags = data . read _shift ( 1 ) ;
var fRichStr = flags & 1 , fExtStr = flags & 2 ;
var str = parse _XLWideString ( data ) ;
var rgsStrRun = [ ] ;
var z = {
t : str ,
r : "<t>" + escapexml ( str ) + "</t>" ,
h : str
} ;
if ( fRichStr ) {
/* TODO: formatted string */
var dwSizeStrRun = data . read _shift ( 4 ) ;
for ( var i = 0 ; i != dwSizeStrRun ; ++ i ) rgsStrRun . push ( parse _StrRun ( data ) ) ;
2014-03-29 02:05:50 +00:00
z . r = JSON . stringify ( rgsStrRun ) ;
2014-02-17 08:44:22 +00:00
}
if ( fExtStr ) {
/* TODO: phonetic string */
}
data . l = start + length ;
return z ;
} ;
/* [MS-XLSB] 2.5.9 */
function parse _Cell ( data ) {
var col = data . read _shift ( 4 ) ;
var iStyleRef = data . read _shift ( 2 ) ;
iStyleRef += data . read _shift ( 1 ) << 16 ;
var fPhShow = data . read _shift ( 1 ) ;
return { c : col , iStyleRef : iStyleRef } ;
}
/* [MS-XLSB] 2.5.21 */
var parse _CodeName = function ( data , length ) { return parse _XLWideString ( data , length ) ; } ;
2014-05-29 22:30:03 +00:00
/* [MS-XLSB] 2.5.166 */
var parse _XLNullableWideString = function ( data ) {
var cchCharacters = data . read _shift ( 4 ) ;
return cchCharacters === 0 || cchCharacters === 0xFFFFFFFF ? "" : data . read _shift ( 'dbcs' , cchCharacters ) ;
} ;
var write _XLNullableWideString = function ( data , o ) {
if ( ! o ) o = new _buf ( 127 ) ;
o . write _shift ( 4 , data . length || 0xFFFFFFFF ) ;
if ( data . length > 0 ) o . write _shift ( 'dbcs' , data ) ;
return o ;
} ;
/* [MS-XLSB] 2.5.168 */
var parse _XLWideString = function ( data ) {
var cchCharacters = data . read _shift ( 4 ) ;
return cchCharacters === 0 ? "" : data . read _shift ( 'dbcs' , cchCharacters ) ;
} ;
var write _XLWideString = function ( data , o ) {
if ( ! o ) o = new _buf ( 127 ) ;
o . write _shift ( 4 , data . length ) ;
if ( data . length > 0 ) o . write _shift ( 'dbcs' , data ) ;
return o ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.5.114 */
2014-05-29 22:30:03 +00:00
var parse _RelID = parse _XLNullableWideString ;
var write _RelID = write _XLNullableWideString ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.5.122 */
function parse _RkNumber ( data ) {
var b = data . slice ( data . l , data . l + 4 ) ;
var fX100 = b [ 0 ] & 1 , fInt = b [ 0 ] & 2 ;
data . l += 4 ;
b [ 0 ] &= ~ 3 ;
var RK = fInt === 0 ? _ _readDoubleLE ( [ 0 , 0 , 0 , 0 , b [ 0 ] , b [ 1 ] , b [ 2 ] , b [ 3 ] ] , 0 ) : _ _readInt32LE ( b , 0 ) >> 2 ;
return fX100 ? RK / 100 : RK ;
}
/* [MS-XLSB] 2.5.153 */
var parse _UncheckedRfX = function ( data ) {
var cell = { s : { } , e : { } } ;
cell . s . r = data . read _shift ( 4 ) ;
cell . e . r = data . read _shift ( 4 ) ;
cell . s . c = data . read _shift ( 4 ) ;
cell . e . c = data . read _shift ( 4 ) ;
return cell ;
} ;
2014-05-29 22:30:03 +00:00
var write _UncheckedRfX = function ( r , o ) {
if ( ! o ) o = new _buf ( 16 ) ;
o . write _shift ( 4 , r . s . r ) ;
o . write _shift ( 4 , r . e . r ) ;
o . write _shift ( 4 , r . s . c ) ;
o . write _shift ( 4 , r . e . c ) ;
return o ;
2014-02-17 08:44:22 +00:00
} ;
/* [MS-XLSB] 2.5.171 */
function parse _Xnum ( data , length ) { return data . read _shift ( 'ieee754' ) ; }
2014-05-29 22:30:03 +00:00
function write _Xnum ( data , o ) { return ( o || new _buf ( 8 ) ) . write _shift ( 'ieee754' , data ) ; }
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.5.198.2 */
var BErr = {
0x00 : "#NULL!" ,
0x07 : "#DIV/0!" ,
0x0F : "#VALUE!" ,
0x17 : "#REF!" ,
0x1D : "#NAME?" ,
0x24 : "#NUM!" ,
0x2A : "#N/A" ,
0x2B : "#GETTING_DATA" ,
0xFF : "#WTF?"
} ;
var RBErr = evert ( BErr ) ;
2014-03-29 02:05:50 +00:00
/* [MS-XLSB] 2.4.321 BrtColor */
function parse _BrtColor ( data , length ) {
var read = data . read _shift . bind ( data ) ;
var out = { } ;
var d = read ( 1 ) ;
out . fValidRGB = d & 1 ;
out . xColorType = d >>> 1 ;
2014-03-29 22:53:15 +00:00
out . index = read ( 1 ) ;
2014-03-29 02:05:50 +00:00
out . nTintAndShade = read ( 2 , 'i' ) ;
out . bRed = read ( 1 ) ;
out . bGreen = read ( 1 ) ;
out . bBlue = read ( 1 ) ;
out . bAlpha = read ( 1 ) ;
}
2014-05-29 22:30:03 +00:00
/* [MS-XLSB] 2.5.52 */
2014-03-29 02:05:50 +00:00
function parse _FontFlags ( data , length ) {
var d = data . read _shift ( 1 ) ;
data . l ++ ;
var out = {
fItalic : d & 0x2 ,
fStrikeout : d & 0x8 ,
fOutline : d & 0x10 ,
fShadow : d & 0x20 ,
fCondense : d & 0x40 ,
2014-05-17 18:57:29 +00:00
fExtend : d & 0x80
2014-03-29 02:05:50 +00:00
} ;
return out ;
}
2014-05-16 00:33:34 +00:00
/* Parts enumerated in OPC spec, MS-XLSB and MS-XLSX */
/* 12.3 Part Summary <SpreadsheetML> */
/* 14.2 Part Summary <DrawingML> */
/* [MS-XLSX] 2.1 Part Enumerations */
/* [MS-XLSB] 2.1.7 Part Enumeration */
var ct2type = {
/* Workbook */
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" : "workbooks" ,
2014-04-23 01:37:08 +00:00
2014-05-16 00:33:34 +00:00
/* Worksheet */
"application/vnd.ms-excel.binIndexWs" : "TODO" , /* Binary Index */
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Chartsheet */
"application/vnd.ms-excel.chartsheet" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Dialogsheet */
"application/vnd.ms-excel.dialogsheet" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Macrosheet */
"application/vnd.ms-excel.macrosheet" : "TODO" ,
"application/vnd.ms-excel.macrosheet+xml" : "TODO" ,
"application/vnd.ms-excel.intlmacrosheet" : "TODO" ,
"application/vnd.ms-excel.binIndexMs" : "TODO" , /* Binary Index */
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* File Properties */
"application/vnd.openxmlformats-package.core-properties+xml" : "coreprops" ,
"application/vnd.openxmlformats-officedocument.custom-properties+xml" : "custprops" ,
"application/vnd.openxmlformats-officedocument.extended-properties+xml" : "extprops" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Custom Data Properties */
"application/vnd.openxmlformats-officedocument.customXmlProperties+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Comments */
"application/vnd.ms-excel.comments" : "comments" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml" : "comments" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* PivotTable */
"application/vnd.ms-excel.pivotTable" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Calculation Chain */
"application/vnd.ms-excel.calcChain" : "calcchains" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml" : "calcchains" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Printer Settings */
"application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* ActiveX */
"application/vnd.ms-office.activeX" : "TODO" ,
"application/vnd.ms-office.activeX+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Custom Toolbars */
"application/vnd.ms-excel.attachedToolbars" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* External Data Connections */
"application/vnd.ms-excel.connections" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* External Links */
"application/vnd.ms-excel.externalLink" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Metadata */
"application/vnd.ms-excel.sheetMetadata" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* PivotCache */
"application/vnd.ms-excel.pivotCacheDefinition" : "TODO" ,
"application/vnd.ms-excel.pivotCacheRecords" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml" : "TODO" ,
2014-04-23 01:37:08 +00:00
2014-05-16 00:33:34 +00:00
/* Query Table */
"application/vnd.ms-excel.queryTable" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Shared Workbook */
"application/vnd.ms-excel.userNames" : "TODO" ,
"application/vnd.ms-excel.revisionHeaders" : "TODO" ,
"application/vnd.ms-excel.revisionLog" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Single Cell Table */
"application/vnd.ms-excel.tableSingleCells" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml" : "TODO" ,
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* Slicer */
"application/vnd.ms-excel.slicer" : "TODO" ,
"application/vnd.ms-excel.slicerCache" : "TODO" ,
"application/vnd.ms-excel.slicer+xml" : "TODO" ,
"application/vnd.ms-excel.slicerCache+xml" : "TODO" ,
2014-04-03 22:51:54 +00:00
/* Sort Map */
"application/vnd.ms-excel.wsSortMap" : "TODO" ,
/* Table */
"application/vnd.ms-excel.table" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml" : "TODO" ,
/* Themes */
"application/vnd.openxmlformats-officedocument.theme+xml" : "themes" ,
/* Timeline */
"application/vnd.ms-excel.Timeline+xml" : "TODO" , /* verify */
"application/vnd.ms-excel.TimelineCache+xml" : "TODO" , /* verify */
/* VBA */
"application/vnd.ms-office.vbaProject" : "vba" ,
"application/vnd.ms-office.vbaProjectSignature" : "vba" ,
/* Volatile Dependencies */
"application/vnd.ms-office.volatileDependencies" : "TODO" ,
"application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml" : "TODO" ,
/* Control Properties */
"application/vnd.ms-excel.controlproperties+xml" : "TODO" ,
/* Data Model */
"application/vnd.openxmlformats-officedocument.model+data" : "TODO" ,
/* Survey */
"application/vnd.ms-excel.Survey+xml" : "TODO" ,
/* Drawing */
"application/vnd.openxmlformats-officedocument.drawing+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.chart+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml" : "TODO" ,
"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml" : "TODO" ,
2014-05-16 00:33:34 +00:00
/* VML */
"application/vnd.openxmlformats-officedocument.vmlDrawing" : "TODO" ,
"application/vnd.openxmlformats-package.relationships+xml" : "rels" ,
"application/vnd.openxmlformats-officedocument.oleObject" : "TODO" ,
"sheet" : "js"
} ;
var CT _LIST = ( function ( ) {
var o = {
workbooks : {
xlsx : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" ,
xlsm : "application/vnd.ms-excel.sheet.macroEnabled.main+xml" ,
xlsb : "application/vnd.ms-excel.sheet.binary.macroEnabled.main" ,
xltx : "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
} ,
strs : { /* Shared Strings */
xlsx : "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml" ,
xlsb : "application/vnd.ms-excel.sharedStrings"
} ,
sheets : {
xlsx : "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" ,
xlsb : "application/vnd.ms-excel.worksheet"
} ,
styles : { /* Styles */
xlsx : "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" ,
xlsb : "application/vnd.ms-excel.styles"
}
} ;
keys ( o ) . forEach ( function ( k ) { if ( ! o [ k ] . xlsm ) o [ k ] . xlsm = o [ k ] . xlsx ; } ) ;
keys ( o ) . forEach ( function ( k ) { keys ( o [ k ] ) . forEach ( function ( v ) { ct2type [ o [ k ] [ v ] ] = k ; } ) ; } ) ;
return o ;
} ) ( ) ;
var type2ct = evert ( ct2type , true ) ;
XMLNS . CT = 'http://schemas.openxmlformats.org/package/2006/content-types' ;
function parse _ct ( data , opts ) {
var ctext = { } ;
if ( ! data || ! data . match ) return data ;
var ct = { workbooks : [ ] , sheets : [ ] , calcchains : [ ] , themes : [ ] , styles : [ ] ,
coreprops : [ ] , extprops : [ ] , custprops : [ ] , strs : [ ] , comments : [ ] , vba : [ ] ,
TODO : [ ] , rels : [ ] , xmlns : "" } ;
( data . match ( /<[^>]*>/g ) || [ ] ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
2014-05-22 12:16:51 +00:00
switch ( y [ 0 ] . replace ( /<\w*:/ , "<" ) ) {
2014-05-16 00:33:34 +00:00
case '<?xml' : break ;
2014-05-22 12:16:51 +00:00
case '<Types' : ct . xmlns = y [ 'xmlns' + ( y [ 0 ] . match ( /<(\w+):/ ) || [ "" , "" ] ) [ 1 ] ] ; break ;
2014-05-16 00:33:34 +00:00
case '<Default' : ctext [ y . Extension ] = y . ContentType ; break ;
case '<Override' :
if ( y . ContentType in ct2type ) ct [ ct2type [ y . ContentType ] ] . push ( y . PartName ) ;
else if ( opts . WTF ) console . error ( y ) ;
break ;
}
} ) ;
if ( ct . xmlns !== XMLNS . CT ) throw new Error ( "Unknown Namespace: " + ct . xmlns ) ;
ct . calcchain = ct . calcchains . length > 0 ? ct . calcchains [ 0 ] : "" ;
ct . sst = ct . strs . length > 0 ? ct . strs [ 0 ] : "" ;
ct . style = ct . styles . length > 0 ? ct . styles [ 0 ] : "" ;
ct . defaults = ctext ;
delete ct . calcchains ;
return ct ;
}
var CTYPE _XML _ROOT = writextag ( 'Types' , null , {
'xmlns' : XMLNS . CT ,
'xmlns:xsd' : XMLNS . xsd ,
'xmlns:xsi' : XMLNS . xsi
} ) ;
var CTYPE _DEFAULTS = [
[ 'xml' , 'application/xml' ] ,
2014-05-29 22:30:03 +00:00
[ 'bin' , 'application/vnd.ms-excel.sheet.binary.macroEnabled.main' ] ,
2014-05-16 00:33:34 +00:00
[ 'rels' , type2ct . rels [ 0 ] ]
] . map ( function ( x ) {
return writextag ( 'Default' , null , { 'Extension' : x [ 0 ] , 'ContentType' : x [ 1 ] } ) ;
} ) ;
function write _ct ( ct , opts ) {
var o = [ ] , v ;
o . push ( XML _HEADER ) ;
o . push ( CTYPE _XML _ROOT ) ;
o = o . concat ( CTYPE _DEFAULTS ) ;
var f1 = function ( w ) {
if ( ct [ w ] && ct [ w ] . length > 0 ) {
v = ct [ w ] [ 0 ] ;
o . push ( writextag ( 'Override' , null , {
'PartName' : ( v [ 0 ] == '/' ? "" : "/" ) + v ,
2014-05-16 00:50:55 +00:00
'ContentType' : CT _LIST [ w ] [ opts . bookType || 'xlsx' ]
2014-05-16 00:33:34 +00:00
} ) ) ;
}
} ;
var f2 = function ( w ) {
ct [ w ] . forEach ( function ( v ) {
o . push ( writextag ( 'Override' , null , {
'PartName' : ( v [ 0 ] == '/' ? "" : "/" ) + v ,
2014-05-16 00:50:55 +00:00
'ContentType' : CT _LIST [ w ] [ opts . bookType || 'xlsx' ]
2014-05-16 00:33:34 +00:00
} ) ) ;
} ) ;
} ;
var f3 = function ( t ) {
( ct [ t ] || [ ] ) . forEach ( function ( v ) {
o . push ( writextag ( 'Override' , null , {
'PartName' : ( v [ 0 ] == '/' ? "" : "/" ) + v ,
'ContentType' : type2ct [ t ] [ 0 ]
} ) ) ;
} ) ;
} ;
f1 ( 'workbooks' ) ;
f2 ( 'sheets' ) ;
2014-05-16 00:50:55 +00:00
f3 ( 'themes' ) ;
2014-05-16 00:33:34 +00:00
[ 'strs' , 'styles' ] . forEach ( f1 ) ;
[ 'coreprops' , 'extprops' , 'custprops' ] . forEach ( f3 ) ;
if ( o . length > 2 ) { o . push ( '</Types>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
/* 9.3.2 OPC Relationships Markup */
var RELS = {
WB : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ,
SHEET : "http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
} ;
function parse _rels ( data , currentFilePath ) {
if ( ! data ) return data ;
if ( currentFilePath . charAt ( 0 ) !== '/' ) {
currentFilePath = '/' + currentFilePath ;
}
var rels = { } ;
var hash = { } ;
var resolveRelativePathIntoAbsolute = function ( to ) {
var toksFrom = currentFilePath . split ( '/' ) ;
toksFrom . pop ( ) ; // folder path
var toksTo = to . split ( '/' ) ;
var reversed = [ ] ;
while ( toksTo . length !== 0 ) {
var tokTo = toksTo . shift ( ) ;
if ( tokTo === '..' ) {
toksFrom . pop ( ) ;
} else if ( tokTo !== '.' ) {
toksFrom . push ( tokTo ) ;
}
}
return toksFrom . join ( '/' ) ;
} ;
data . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
/* 9.3.2.2 OPC_Relationships */
if ( y [ 0 ] === '<Relationship' ) {
var rel = { } ; rel . Type = y . Type ; rel . Target = y . Target ; rel . Id = y . Id ; rel . TargetMode = y . TargetMode ;
var canonictarget = y . TargetMode === 'External' ? y . Target : resolveRelativePathIntoAbsolute ( y . Target ) ;
rels [ canonictarget ] = rel ;
hash [ y . Id ] = rel ;
}
} ) ;
rels [ "!id" ] = hash ;
return rels ;
}
XMLNS . RELS = 'http://schemas.openxmlformats.org/package/2006/relationships' ;
var RELS _ROOT = writextag ( 'Relationships' , null , {
//'xmlns:ns0': XMLNS.RELS,
'xmlns' : XMLNS . RELS
} ) ;
/* TODO */
function write _rels ( rels ) {
var o = [ ] ;
o . push ( XML _HEADER ) ;
o . push ( RELS _ROOT ) ;
keys ( rels [ '!id' ] ) . forEach ( function ( rid ) { var rel = rels [ '!id' ] [ rid ] ;
o . push ( writextag ( 'Relationship' , null , rel ) ) ;
} ) ;
if ( o . length > 2 ) { o . push ( '</Relationships>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
/* ECMA-376 Part II 11.1 Core Properties Part */
/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */
var CORE _PROPS = [
[ "cp:category" , "Category" ] ,
[ "cp:contentStatus" , "ContentStatus" ] ,
[ "cp:keywords" , "Keywords" ] ,
[ "cp:lastModifiedBy" , "LastAuthor" ] ,
[ "cp:lastPrinted" , "LastPrinted" ] ,
[ "cp:revision" , "RevNumber" ] ,
[ "cp:version" , "Version" ] ,
[ "dc:creator" , "Author" ] ,
[ "dc:description" , "Comments" ] ,
[ "dc:identifier" , "Identifier" ] ,
[ "dc:language" , "Language" ] ,
[ "dc:subject" , "Subject" ] ,
[ "dc:title" , "Title" ] ,
[ "dcterms:created" , "CreatedDate" , 'date' ] ,
[ "dcterms:modified" , "ModifiedDate" , 'date' ]
] ;
XMLNS . CORE _PROPS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ;
RELS . CORE _PROPS = 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties' ;
function parse _core _props ( data ) {
var p = { } ;
CORE _PROPS . forEach ( function ( f ) {
var g = "(?:" + f [ 0 ] . substr ( 0 , f [ 0 ] . indexOf ( ":" ) ) + ":)" + f [ 0 ] . substr ( f [ 0 ] . indexOf ( ":" ) + 1 ) ;
var cur = data . match ( new RegExp ( "<" + g + "[^>]*>(.*)<\/" + g + ">" ) ) ;
if ( cur && cur . length > 0 ) p [ f [ 1 ] ] = cur [ 1 ] ;
if ( f [ 2 ] === 'date' && p [ f [ 1 ] ] ) p [ f [ 1 ] ] = new Date ( p [ f [ 1 ] ] ) ;
} ) ;
return p ;
}
var CORE _PROPS _XML _ROOT = writextag ( 'cp:coreProperties' , null , {
//'xmlns': XMLNS.CORE_PROPS,
'xmlns:cp' : XMLNS . CORE _PROPS ,
'xmlns:dc' : XMLNS . dc ,
'xmlns:dcterms' : XMLNS . dcterms ,
'xmlns:dcmitype' : XMLNS . dcmitype ,
'xmlns:xsi' : XMLNS . xsi
} ) ;
function write _core _props ( cp , opts ) {
var o = [ ] , p = { } ;
o . push ( XML _HEADER ) ;
o . push ( CORE _PROPS _XML _ROOT ) ;
if ( ! cp ) return o . join ( "" ) ;
var doit = function ( f , g , h ) {
if ( p [ f ] || typeof g === 'undefined' || g === "" ) return ;
if ( typeof g !== 'string' ) g = String ( g ) ; /* TODO: remove */
p [ f ] = g ;
o . push ( h ? writextag ( f , g , h ) : writetag ( f , g ) ) ;
} ;
2014-05-22 12:16:51 +00:00
if ( typeof cp . CreatedDate !== 'undefined' ) doit ( "dcterms:created" , typeof cp . CreatedDate === "string" ? cp . CreatedDate : write _w3cdtf ( cp . CreatedDate , opts . WTF ) , { "xsi:type" : "dcterms:W3CDTF" } ) ;
if ( typeof cp . ModifiedDate !== 'undefined' ) doit ( "dcterms:modified" , typeof cp . ModifiedDate === "string" ? cp . ModifiedDate : write _w3cdtf ( cp . ModifiedDate , opts . WTF ) , { "xsi:type" : "dcterms:W3CDTF" } ) ;
2014-05-16 00:33:34 +00:00
CORE _PROPS . forEach ( function ( f ) { doit ( f [ 0 ] , cp [ f [ 1 ] ] ) ; } ) ;
if ( o . length > 2 ) { o . push ( '</cp:coreProperties>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
/* 15.2.12.3 Extended File Properties Part */
/* [MS-OSHARED] 2.3.3.2.[1-2].1 (PIDSI/PIDDSI) */
var EXT _PROPS = [
[ "Application" , "Application" , "string" ] ,
[ "AppVersion" , "AppVersion" , "string" ] ,
[ "Company" , "Company" , "string" ] ,
[ "DocSecurity" , "DocSecurity" , "string" ] ,
[ "Manager" , "Manager" , "string" ] ,
[ "HyperlinksChanged" , "HyperlinksChanged" , "bool" ] ,
[ "SharedDoc" , "SharedDoc" , "bool" ] ,
[ "LinksUpToDate" , "LinksUpToDate" , "bool" ] ,
[ "ScaleCrop" , "ScaleCrop" , "bool" ] ,
[ "HeadingPairs" , "HeadingPairs" , "raw" ] ,
[ "TitlesOfParts" , "TitlesOfParts" , "raw" ] ,
] ;
2014-04-03 22:51:54 +00:00
2014-05-16 00:33:34 +00:00
XMLNS . EXT _PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" ;
RELS . EXT _PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties' ;
2014-03-29 02:05:50 +00:00
2014-05-16 00:33:34 +00:00
function parse _ext _props ( data , p ) {
var q = { } ; if ( ! p ) p = { } ;
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
EXT _PROPS . forEach ( function ( f ) {
switch ( f [ 2 ] ) {
case "string" : p [ f [ 1 ] ] = ( data . match ( matchtag ( f [ 0 ] ) ) || [ ] ) [ 1 ] ; break ;
case "bool" : p [ f [ 1 ] ] = ( data . match ( matchtag ( f [ 0 ] ) ) || [ ] ) [ 1 ] === "true" ; break ;
case "raw" :
var cur = data . match ( new RegExp ( "<" + f [ 0 ] + "[^>]*>(.*)<\/" + f [ 0 ] + ">" ) ) ;
if ( cur && cur . length > 0 ) q [ f [ 1 ] ] = cur [ 1 ] ;
break ;
}
2014-02-17 08:44:22 +00:00
} ) ;
if ( q . HeadingPairs && q . TitlesOfParts ) {
var v = parseVector ( q . HeadingPairs ) ;
var j = 0 , widx = 0 ;
for ( var i = 0 ; i !== v . length ; ++ i ) {
switch ( v [ i ] . v ) {
case "Worksheets" : widx = j ; p . Worksheets = + ( v [ ++ i ] . v ) ; break ;
case "Named Ranges" : ++ i ; break ; // TODO: Handle Named Ranges
}
}
var parts = parseVector ( q . TitlesOfParts ) . map ( function ( x ) { return utf8read ( x . v ) ; } ) ;
p . SheetNames = parts . slice ( widx , widx + p . Worksheets ) ;
}
return p ;
}
2014-05-16 00:33:34 +00:00
var EXT _PROPS _XML _ROOT = writextag ( 'Properties' , null , {
'xmlns' : XMLNS . EXT _PROPS ,
'xmlns:vt' : XMLNS . vt
} ) ;
function write _ext _props ( cp , opts ) {
var o = [ ] , p = { } , W = writextag ;
2014-05-22 12:16:51 +00:00
if ( ! cp ) cp = { } ;
cp . Application = "SheetJS" ;
2014-05-16 00:33:34 +00:00
o . push ( XML _HEADER ) ;
o . push ( EXT _PROPS _XML _ROOT ) ;
EXT _PROPS . forEach ( function ( f ) {
if ( typeof cp [ f [ 1 ] ] === 'undefined' ) return ;
var v ;
switch ( f [ 2 ] ) {
case 'string' : v = cp [ f [ 1 ] ] ; break ;
case 'bool' : v = cp [ f [ 1 ] ] ? 'true' : 'false' ; break ;
}
if ( typeof v !== 'undefined' ) o . push ( W ( f [ 0 ] , v ) ) ;
} ) ;
/* TODO: HeadingPairs, TitlesOfParts */
o . push ( W ( 'HeadingPairs' , W ( 'vt:vector' , W ( 'vt:variant' , '<vt:lpstr>Worksheets</vt:lpstr>' ) + W ( 'vt:variant' , W ( 'vt:i4' , String ( cp . Worksheets ) ) ) , { size : 2 , baseType : "variant" } ) ) ) ;
o . push ( W ( 'TitlesOfParts' , W ( 'vt:vector' , cp . SheetNames . map ( function ( s ) { return "<vt:lpstr>" + s + "</vt:lpstr>" ; } ) . join ( "" ) , { size : cp . Worksheets , baseType : "lpstr" } ) ) ) ;
if ( o . length > 2 ) { o . push ( '</Properties>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
2014-02-17 08:44:22 +00:00
/* 15.2.12.2 Custom File Properties Part */
2014-05-16 00:33:34 +00:00
XMLNS . CUST _PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" ;
RELS . CUST _PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties' ;
function parse _cust _props ( data , opts ) {
2014-02-17 08:44:22 +00:00
var p = { } , name ;
data . match ( /<[^>]+>([^<]*)/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
2014-05-16 00:33:34 +00:00
case '<?xml' : break ;
case '<Properties' :
if ( y . xmlns !== XMLNS . CUST _PROPS ) throw "unrecognized xmlns " + y . xmlns ;
if ( y . xmlnsvt && y . xmlnsvt !== XMLNS . vt ) throw "unrecognized vt " + y . xmlnsvt ;
break ;
2014-02-17 08:44:22 +00:00
case '<property' : name = y . name ; break ;
case '</property>' : name = null ; break ;
default : if ( x . indexOf ( '<vt:' ) === 0 ) {
var toks = x . split ( '>' ) ;
var type = toks [ 0 ] . substring ( 4 ) , text = toks [ 1 ] ;
/* 22.4.2.32 (CT_Variant). Omit the binary types from 22.4 (Variant Types) */
switch ( type ) {
case 'lpstr' : case 'lpwstr' : case 'bstr' : case 'lpwstr' :
p [ name ] = unescapexml ( text ) ;
break ;
case 'bool' :
p [ name ] = parsexmlbool ( text , '<vt:bool>' ) ;
break ;
case 'i1' : case 'i2' : case 'i4' : case 'i8' : case 'int' : case 'uint' :
p [ name ] = parseInt ( text , 10 ) ;
break ;
case 'r4' : case 'r8' : case 'decimal' :
p [ name ] = parseFloat ( text ) ;
break ;
case 'filetime' : case 'date' :
2014-05-16 00:33:34 +00:00
p [ name ] = new Date ( text ) ;
2014-02-17 08:44:22 +00:00
break ;
case 'cy' : case 'error' :
p [ name ] = unescapexml ( text ) ;
break ;
default :
console . warn ( 'Unexpected' , x , type , toks ) ;
}
2014-05-16 00:33:34 +00:00
} else if ( x . substr ( 0 , 2 ) === "</" ) {
} else if ( opts . WTF ) throw new Error ( x ) ;
2014-02-17 08:44:22 +00:00
}
} ) ;
return p ;
}
2014-05-16 00:33:34 +00:00
var CUST _PROPS _XML _ROOT = writextag ( 'Properties' , null , {
'xmlns' : XMLNS . CUST _PROPS ,
'xmlns:vt' : XMLNS . vt
} ) ;
function write _cust _props ( cp , opts ) {
var o = [ ] , p = { } ;
o . push ( XML _HEADER ) ;
o . push ( CUST _PROPS _XML _ROOT ) ;
if ( ! cp ) return o . join ( "" ) ;
var pid = 1 ;
2014-05-16 00:50:55 +00:00
keys ( cp ) . forEach ( function ( k ) { ++ pid ;
2014-05-16 00:33:34 +00:00
o . push ( writextag ( 'property' , write _vt ( cp [ k ] ) , {
'fmtid' : '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' ,
'pid' : pid ,
'name' : k
} ) ) ;
} ) ;
if ( o . length > 2 ) { o . push ( '</Properties>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
/* 18.4.1 charset to codepage mapping */
var CS2CP = {
0 : 1252 , /* ANSI */
1 : 65001 , /* DEFAULT */
2 : 65001 , /* SYMBOL */
77 : 10000 , /* MAC */
128 : 932 , /* SHIFTJIS */
129 : 949 , /* HANGUL */
130 : 1361 , /* JOHAB */
134 : 936 , /* GB2312 */
136 : 950 , /* CHINESEBIG5 */
161 : 1253 , /* GREEK */
162 : 1254 , /* TURKISH */
163 : 1258 , /* VIETNAMESE */
177 : 1255 , /* HEBREW */
178 : 1256 , /* ARABIC */
186 : 1257 , /* BALTIC */
204 : 1251 , /* RUSSIAN */
222 : 874 , /* THAI */
238 : 1250 , /* EASTEUROPE */
255 : 1252 , /* OEM */
69 : 6969 /* MISC */
} ;
/* Parse a list of <r> tags */
var parse _rs = ( function ( ) {
var tregex = matchtag ( "t" ) , rpregex = matchtag ( "rPr" ) ;
/* 18.4.7 rPr CT_RPrElt */
var parse _rpr = function ( rpr , intro , outro ) {
var font = { } , cp = 65001 ;
( rpr . match ( /<[^>]*>/g ) || [ ] ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
/* 18.8.12 condense CT_BooleanProperty */
/* ** not required . */
case '<condense' : break ;
/* 18.8.17 extend CT_BooleanProperty */
/* ** not required . */
case '<extend' : break ;
/* 18.8.36 shadow CT_BooleanProperty */
/* ** not required . */
case '<shadow' :
/* falls through */
case '<shadow/>' : break ;
/* 18.4.1 charset CT_IntProperty TODO */
case '<charset' :
if ( y . val == '1' ) break ;
cp = CS2CP [ parseInt ( y . val , 10 ) ] ;
break ;
/* 18.4.2 outline CT_BooleanProperty TODO */
case '<outline' :
/* falls through */
case '<outline/>' : break ;
/* 18.4.5 rFont CT_FontName */
case '<rFont' : font . name = y . val ; break ;
/* 18.4.11 sz CT_FontSize */
case '<sz' : font . sz = y . val ; break ;
/* 18.4.10 strike CT_BooleanProperty */
case '<strike' :
if ( ! y . val ) break ;
/* falls through */
case '<strike/>' : font . strike = 1 ; break ;
case '</strike>' : break ;
/* 18.4.13 u CT_UnderlineProperty */
case '<u' :
if ( ! y . val ) break ;
/* falls through */
case '<u/>' : font . u = 1 ; break ;
case '</u>' : break ;
/* 18.8.2 b */
case '<b' :
if ( ! y . val ) break ;
/* falls through */
case '<b/>' : font . b = 1 ; break ;
case '</b>' : break ;
/* 18.8.26 i */
case '<i' :
if ( ! y . val ) break ;
/* falls through */
case '<i/>' : font . i = 1 ; break ;
case '</i>' : break ;
/* 18.3.1.15 color CT_Color TODO: tint, theme, auto, indexed */
case '<color' :
if ( y . rgb ) font . color = y . rgb . substr ( 2 , 6 ) ;
break ;
/* 18.8.18 family ST_FontFamily */
case '<family' : font . family = y . val ; break ;
/* 18.4.14 vertAlign CT_VerticalAlignFontProperty TODO */
case '<vertAlign' : break ;
/* 18.8.35 scheme CT_FontScheme TODO */
case '<scheme' : break ;
default :
if ( y [ 0 ] [ 2 ] !== '/' ) throw 'Unrecognized rich format ' + y [ 0 ] ;
}
} ) ;
/* TODO: These should be generated styles, not inline */
var style = [ ] ;
if ( font . b ) style . push ( "font-weight: bold;" ) ;
if ( font . i ) style . push ( "font-style: italic;" ) ;
intro . push ( '<span style="' + style . join ( "" ) + '">' ) ;
outro . push ( "</span>" ) ;
return cp ;
} ;
/* 18.4.4 r CT_RElt */
function parse _r ( r ) {
var terms = [ [ ] , "" , [ ] ] ;
/* 18.4.12 t ST_Xstring */
var t = r . match ( tregex ) , cp = 65001 ;
if ( ! isval ( t ) ) return "" ;
terms [ 1 ] = t [ 1 ] ;
var rpr = r . match ( rpregex ) ;
if ( isval ( rpr ) ) cp = parse _rpr ( rpr [ 1 ] , terms [ 0 ] , terms [ 2 ] ) ;
return terms [ 0 ] . join ( "" ) + terms [ 1 ] . replace ( /\r\n/g , '<br/>' ) + terms [ 2 ] . join ( "" ) ;
}
return function ( rs ) {
return rs . replace ( /<r>/g , "" ) . split ( /<\/r>/ ) . map ( parse _r ) . join ( "" ) ;
} ;
} ) ( ) ;
/* 18.4.8 si CT_Rst */
var parse _si = function ( x , opts ) {
var html = opts ? opts . cellHTML : true ;
var z = { } ;
if ( ! x ) return null ;
var y ;
/* 18.4.12 t ST_Xstring (Plaintext String) */
if ( x [ 1 ] === 't' ) {
z . t = utf8read ( unescapexml ( x . substr ( x . indexOf ( ">" ) + 1 ) . split ( /<\/t>/ ) [ 0 ] ) ) ;
z . r = x ;
if ( html ) z . h = z . t ;
}
/* 18.4.4 r CT_RElt (Rich Text Run) */
else if ( ( y = x . match ( /<r>/ ) ) ) {
z . r = x ;
/* TODO: properly parse (note: no other valid child can have body text) */
z . t = utf8read ( unescapexml ( x . replace ( /<[^>]*>/gm , "" ) ) ) ;
if ( html ) z . h = parse _rs ( x ) ;
}
/* 18.4.3 phoneticPr CT_PhoneticPr (TODO: needed for Asian support) */
/* 18.4.6 rPh CT_PhoneticRun (TODO: needed for Asian support) */
return z ;
} ;
/* 18.4 Shared String Table */
var parse _sst _xml = function ( data , opts ) {
var s = [ ] ;
/* 18.4.9 sst CT_Sst */
var sst = data . match ( new RegExp ( "<sst([^>]*)>([\\s\\S]*)<\/sst>" , "m" ) ) ;
if ( isval ( sst ) ) {
s = sst [ 2 ] . replace ( /<(?:si|sstItem)>/g , "" ) . split ( /<\/(?:si|sstItem)>/ ) . map ( function ( x ) { return parse _si ( x , opts ) ; } ) . filter ( function ( x ) { return x ; } ) ;
sst = parsexmltag ( sst [ 1 ] ) ; s . Count = sst . count ; s . Unique = sst . uniqueCount ;
}
return s ;
} ;
RELS . SST = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" ;
var write _sst _xml = function ( sst , opts ) {
if ( ! opts . bookSST ) return "" ;
var o = [ ] ;
o . push ( XML _HEADER ) ;
o . push ( writextag ( 'sst' , null , {
xmlns : XMLNS . main [ 0 ] ,
count : sst . Count ,
uniqueCount : sst . Unique
} ) ) ;
2014-05-22 12:16:51 +00:00
sst . forEach ( function ( s ) {
var sitag = "<si>" ;
if ( s . r ) sitag += s . r ;
else {
sitag += "<t" ;
if ( s . t . match ( /^\s|\s$|[\t\n\r]/ ) ) sitag += ' xml:space="preserve"' ;
sitag += ">" ;
sitag += escapexml ( s . t ) ;
sitag += "</t>" ;
}
sitag += "</si>" ;
o . push ( sitag ) ;
} ) ;
2014-05-16 00:33:34 +00:00
if ( o . length > 2 ) { o . push ( '</sst>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
} ;
/* [MS-XLSB] 2.4.219 BrtBeginSst */
var parse _BrtBeginSst = function ( data , length ) {
return [ data . read _shift ( 4 ) , data . read _shift ( 4 ) ] ;
} ;
/* [MS-XLSB] 2.1.7.45 Shared Strings */
var parse _sst _bin = function ( data , opts ) {
var s = [ ] ;
var pass = false ;
recordhopper ( data , function ( val , R , RT ) {
switch ( R . n ) {
case 'BrtBeginSst' : s . Count = val [ 0 ] ; s . Unique = val [ 1 ] ; break ;
case 'BrtSSTItem' : s . push ( val ) ; break ;
case 'BrtEndSst' : return true ;
/* TODO: produce a test case with a future record */
case 'BrtFRTBegin' : pass = true ; break ;
case 'BrtFRTEnd' : pass = false ; break ;
default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + RT + " " + R . n ) ;
}
} ) ;
return s ;
} ;
var write _sst _bin = function ( sst , opts ) { } ;
var styles = { } ; // shared styles
2014-05-29 22:30:03 +00:00
var themes = { } ; // shared themes
/* 18.8.21 fills CT_Fills */
function parse _fills ( t , opts ) {
styles . Fills = [ ] ;
var fill = { } ;
t [ 0 ] . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
case '<fills' : case '<fills>' : case '</fills>' : break ;
/* 18.8.20 fill CT_Fill */
case '<fill>' : break ;
case '</fill>' : styles . Fills . push ( fill ) ; fill = { } ; break ;
/* 18.8.32 patternFill CT_PatternFill */
case '<patternFill' :
if ( y . patternType ) fill . patternType = y . patternType ;
break ;
case '<patternFill/>' : case '</patternFill>' : break ;
/* 18.8.3 bgColor CT_Color */
case '<bgColor' :
if ( ! fill . bgColor ) fill . bgColor = { } ;
if ( y . indexed ) fill . bgColor . indexed = parseInt ( y . indexed ) ;
if ( y . theme ) fill . bgColor . theme = parseInt ( y . theme ) ;
if ( y . tint ) fill . bgColor . tint = Number ( y . tint ) ;
/* Excel uses ARGB strings */
if ( y . rgb ) fill . bgColor . rgb = y . rgb . substring ( y . rgb . length - 6 ) ;
break ;
case '</bgColor>' : break ;
/* 18.8.19 fgColor CT_Color */
case '<fgColor' :
if ( ! fill . fgColor ) fill . fgColor = { } ;
if ( y . theme ) fill . fgColor . theme = parseInt ( y . theme ) ;
if ( y . tint ) fill . fgColor . tint = Number ( y . tint ) ;
/* Excel uses ARGB strings */
if ( y . rgb ) fill . fgColor . rgb = y . rgb . substring ( y . rgb . length - 6 ) ;
break ;
case '</fgColor>' : break ;
default : if ( opts . WTF ) throw 'unrecognized ' + y [ 0 ] + ' in fills' ;
}
} ) ;
}
2014-05-16 00:33:34 +00:00
/* 18.8.31 numFmts CT_NumFmts */
function parse _numFmts ( t , opts ) {
styles . NumberFmt = [ ] ;
for ( var y in SSF . _table ) styles . NumberFmt [ y ] = SSF . _table [ y ] ;
t [ 0 ] . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
2014-02-17 08:44:22 +00:00
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
2014-05-22 12:16:51 +00:00
case '<numFmts' : case '</numFmts>' : case '<numFmts/>' : case '<numFmts>' : break ;
2014-05-16 00:33:34 +00:00
case '<numFmt' : {
2014-05-22 12:16:51 +00:00
var f = unescapexml ( y . formatCode ) , i = parseInt ( y . numFmtId , 10 ) ;
2014-05-16 00:33:34 +00:00
styles . NumberFmt [ i ] = f ; if ( i > 0 ) SSF . load ( f , i ) ;
} break ;
default : if ( opts . WTF ) throw 'unrecognized ' + y [ 0 ] + ' in numFmts' ;
}
} ) ;
}
function write _numFmts ( NF , opts ) {
var o = [ ] ;
o . push ( "<numFmts>" ) ;
[ [ 5 , 8 ] , [ 23 , 26 ] , [ 41 , 44 ] , [ 63 , 66 ] , [ 164 , 392 ] ] . forEach ( function ( r ) {
2014-05-16 00:50:55 +00:00
for ( var i = r [ 0 ] ; i <= r [ 1 ] ; ++ i ) if ( NF [ i ] ) o . push ( writextag ( 'numFmt' , null , { numFmtId : i , formatCode : escapexml ( NF [ i ] ) } ) ) ;
2014-05-16 00:33:34 +00:00
} ) ;
o . push ( "</numFmts>" ) ;
if ( o . length === 2 ) return "" ;
o [ 0 ] = writextag ( 'numFmts' , null , { count : o . length - 2 } ) . replace ( "/>" , ">" ) ;
return o . join ( "" ) ;
}
/* 18.8.10 cellXfs CT_CellXfs */
function parse _cellXfs ( t , opts ) {
styles . CellXf = [ ] ;
t [ 0 ] . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
2014-05-22 12:16:51 +00:00
case '<cellXfs' : case '<cellXfs>' : case '<cellXfs/>' : case '</cellXfs>' : break ;
2014-05-16 00:33:34 +00:00
/* 18.8.45 xf CT_Xf */
case '<xf' : delete y [ 0 ] ;
if ( y . numFmtId ) y . numFmtId = parseInt ( y . numFmtId , 10 ) ;
2014-05-29 22:30:03 +00:00
if ( y . fillId ) y . fillId = parseInt ( y . fillId , 10 ) ;
2014-05-16 00:33:34 +00:00
styles . CellXf . push ( y ) ; break ;
case '</xf>' : break ;
/* 18.8.1 alignment CT_CellAlignment */
case '<alignment' : case '<alignment/>' : break ;
/* 18.8.33 protection CT_CellProtection */
case '<protection' : case '</protection>' : case '<protection/>' : break ;
case '<extLst' : case '</extLst>' : break ;
case '<ext' : break ;
default : if ( opts . WTF ) throw 'unrecognized ' + y [ 0 ] + ' in cellXfs' ;
2014-02-17 08:44:22 +00:00
}
} ) ;
}
2014-05-16 00:33:34 +00:00
function write _cellXfs ( cellXfs ) {
var o = [ ] ;
o . push ( writextag ( 'cellXfs' , null ) ) ;
cellXfs . forEach ( function ( c ) { o . push ( writextag ( 'xf' , null , c ) ) ; } ) ;
o . push ( "</cellXfs>" ) ;
if ( o . length === 2 ) return "" ;
o [ 0 ] = writextag ( 'cellXfs' , null , { count : o . length - 2 } ) . replace ( "/>" , ">" ) ;
return o . join ( "" ) ;
}
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* 18.8 Styles CT_Stylesheet*/
function parse _sty _xml ( data , opts ) {
/* 18.8.39 styleSheet CT_Stylesheet */
var t ;
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* numFmts CT_NumFmts ? */
if ( ( t = data . match ( /<numFmts([^>]*)>.*<\/numFmts>/ ) ) ) parse _numFmts ( t , opts ) ;
2014-02-17 08:44:22 +00:00
2014-05-16 00:33:34 +00:00
/* fonts CT_Fonts ? */
2014-05-29 22:30:03 +00:00
/* fills CT_Fills */
if ( ( t = data . match ( /<fills([^>]*)>.*<\/fills>/ ) ) ) parse _fills ( t , opts ) ;
2014-05-16 00:33:34 +00:00
/* borders CT_Borders ? */
/* cellStyleXfs CT_CellStyleXfs ? */
/* cellXfs CT_CellXfs ? */
if ( ( t = data . match ( /<cellXfs([^>]*)>.*<\/cellXfs>/ ) ) ) parse _cellXfs ( t , opts ) ;
/* dxfs CT_Dxfs ? */
/* tableStyles CT_TableStyles ? */
/* colors CT_Colors ? */
/* extLst CT_ExtensionList ? */
return styles ;
}
var STYLES _XML _ROOT = writextag ( 'styleSheet' , null , {
'xmlns' : XMLNS . main [ 0 ] ,
'xmlns:vt' : XMLNS . vt
} ) ;
RELS . STY = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" ;
function write _sty _xml ( wb , opts ) {
var o = [ ] , p = { } , W = writextag , w ;
o . push ( XML _HEADER ) ;
o . push ( STYLES _XML _ROOT ) ;
if ( ( w = write _numFmts ( wb . SSF ) ) ) o . push ( w ) ;
2014-05-29 22:30:03 +00:00
o . push ( '<fonts count="1"><font><sz val="12"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font></fonts>' ) ;
o . push ( '<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>' ) ;
2014-05-16 00:33:34 +00:00
o . push ( '<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>' ) ;
o . push ( '<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>' ) ;
if ( ( w = write _cellXfs ( opts . cellXfs ) ) ) o . push ( w ) ;
o . push ( '<cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>' ) ;
o . push ( '<dxfs count="0"/>' ) ;
o . push ( '<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4"/>' ) ;
if ( o . length > 2 ) { o . push ( '</styleSheet>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
}
/* [MS-XLSB] 2.4.651 BrtFmt */
function parse _BrtFmt ( data , length ) {
var ifmt = data . read _shift ( 2 ) ;
var stFmtCode = parse _XLWideString ( data , length - 2 ) ;
return [ ifmt , stFmtCode ] ;
}
/* [MS-XLSB] 2.4.653 BrtFont TODO */
function parse _BrtFont ( data , length ) {
var read = data . read _shift . bind ( data ) ;
var out = { flags : { } } ;
out . dyHeight = read ( 2 ) ;
out . grbit = parse _FontFlags ( data , 2 ) ;
out . bls = read ( 2 ) ;
out . sss = read ( 2 ) ;
out . uls = read ( 1 ) ;
out . bFamily = read ( 1 ) ;
out . bCharSet = read ( 1 ) ;
data . l ++ ;
out . brtColor = parse _BrtColor ( data , 8 ) ;
out . bFontScheme = read ( 1 ) ;
out . name = parse _XLWideString ( data , length - 21 ) ;
out . flags . Bold = out . bls === 0x02BC ;
out . flags . Italic = out . grbit . fItalic ;
out . flags . Strikeout = out . grbit . fStrikeout ;
out . flags . Outline = out . grbit . fOutline ;
out . flags . Shadow = out . grbit . fShadow ;
out . flags . Condense = out . grbit . fCondense ;
out . flags . Extend = out . grbit . fExtend ;
out . flags . Sub = out . sss & 0x2 ;
out . flags . Sup = out . sss & 0x1 ;
return out ;
}
/* [MS-XLSB] 2.4.816 BrtXF */
function parse _BrtXF ( data , length ) {
var ixfeParent = data . read _shift ( 2 ) ;
var ifmt = data . read _shift ( 2 ) ;
parsenoop ( data , length - 4 ) ;
return { ixfe : ixfeParent , ifmt : ifmt } ;
}
/* [MS-XLSB] 2.1.7.50 Styles */
function parse _sty _bin ( data , opts ) {
styles . NumberFmt = [ ] ;
for ( var y in SSF . _table ) styles . NumberFmt [ y ] = SSF . _table [ y ] ;
styles . CellXf = [ ] ;
var state = "" ; /* TODO: this should be a stack */
var pass = false ;
recordhopper ( data , function ( val , R , RT ) {
switch ( R . n ) {
case 'BrtFmt' :
styles . NumberFmt [ val [ 0 ] ] = val [ 1 ] ; SSF . load ( val [ 1 ] , val [ 0 ] ) ;
break ;
case 'BrtFont' : break ; /* TODO */
case 'BrtKnownFonts' : break ; /* TODO */
case 'BrtFill' : break ; /* TODO */
case 'BrtBorder' : break ; /* TODO */
case 'BrtXF' :
if ( state === "CELLXFS" ) {
styles . CellXf . push ( val ) ;
}
break ; /* TODO */
case 'BrtStyle' : break ; /* TODO */
case 'BrtDXF' : break ; /* TODO */
case 'BrtMRUColor' : break ; /* TODO */
case 'BrtIndexedColor' : break ; /* TODO */
case 'BrtBeginStyleSheet' : break ;
case 'BrtEndStyleSheet' : break ;
case 'BrtBeginTableStyle' : break ;
case 'BrtTableStyleElement' : break ;
case 'BrtEndTableStyle' : break ;
case 'BrtBeginFmts' : state = "FMTS" ; break ;
case 'BrtEndFmts' : state = "" ; break ;
case 'BrtBeginFonts' : state = "FONTS" ; break ;
case 'BrtEndFonts' : state = "" ; break ;
case 'BrtACBegin' : state = "ACFONTS" ; break ;
case 'BrtACEnd' : state = "" ; break ;
case 'BrtBeginFills' : state = "FILLS" ; break ;
case 'BrtEndFills' : state = "" ; break ;
case 'BrtBeginBorders' : state = "BORDERS" ; break ;
case 'BrtEndBorders' : state = "" ; break ;
case 'BrtBeginCellStyleXFs' : state = "CELLSTYLEXFS" ; break ;
case 'BrtEndCellStyleXFs' : state = "" ; break ;
case 'BrtBeginCellXFs' : state = "CELLXFS" ; break ;
case 'BrtEndCellXFs' : state = "" ; break ;
case 'BrtBeginStyles' : state = "STYLES" ; break ;
case 'BrtEndStyles' : state = "" ; break ;
case 'BrtBeginDXFs' : state = "DXFS" ; break ;
case 'BrtEndDXFs' : state = "" ; break ;
case 'BrtBeginTableStyles' : state = "TABLESTYLES" ; break ;
case 'BrtEndTableStyles' : state = "" ; break ;
case 'BrtBeginColorPalette' : state = "COLORPALETTE" ; break ;
case 'BrtEndColorPalette' : state = "" ; break ;
case 'BrtBeginIndexedColors' : state = "INDEXEDCOLORS" ; break ;
case 'BrtEndIndexedColors' : state = "" ; break ;
case 'BrtBeginMRUColors' : state = "MRUCOLORS" ; break ;
case 'BrtEndMRUColors' : state = "" ; break ;
case 'BrtFRTBegin' : pass = true ; break ;
case 'BrtFRTEnd' : pass = false ; break ;
case 'BrtBeginStyleSheetExt14' : break ;
case 'BrtBeginSlicerStyles' : break ;
case 'BrtEndSlicerStyles' : break ;
case 'BrtBeginTimelineStylesheetExt15' : break ;
case 'BrtEndTimelineStylesheetExt15' : break ;
case 'BrtBeginTimelineStyles' : break ;
case 'BrtEndTimelineStyles' : break ;
case 'BrtEndStyleSheetExt14' : break ;
default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + RT + " " + R . n ) ;
2014-02-17 08:44:22 +00:00
}
} ) ;
2014-05-16 00:33:34 +00:00
return styles ;
2014-02-17 08:44:22 +00:00
}
2014-05-29 22:30:03 +00:00
function write _sty _bin ( data , opts ) { }
2014-05-16 00:33:34 +00:00
RELS . THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ;
2014-02-17 08:44:22 +00:00
2014-05-29 22:30:03 +00:00
/* Various RGB/HSL utility functions - might want to put these elsewhere. */
/* From http://www.javascripter.net/faq/hextorgb.htm, usage: var X = hexToX('FFFFFF') */
function cutHex ( h ) { return ( h . charAt ( 0 ) == "#" ) ? h . substring ( 1 , 7 ) : h }
function hexToR ( h ) { return parseInt ( ( cutHex ( h ) ) . substring ( 0 , 2 ) , 16 ) }
function hexToG ( h ) { return parseInt ( ( cutHex ( h ) ) . substring ( 2 , 4 ) , 16 ) }
function hexToB ( h ) { return parseInt ( ( cutHex ( h ) ) . substring ( 4 , 6 ) , 16 ) }
/* From http://www.javascripter.net/faq/rgbtohex.htm, usage: var RGB = rgbToHex(R, G, B) */
function toHex ( n ) {
n = parseInt ( n , 10 ) ;
if ( isNaN ( n ) ) return "00" ;
n = Math . max ( 0 , Math . min ( n , 255 ) ) ;
return "0123456789ABCDEF" . charAt ( ( n - n % 16 ) / 16 )
+ "0123456789ABCDEF" . charAt ( n % 16 ) ;
}
function rgbToHex ( R , G , B ) { return toHex ( R ) + toHex ( G ) + toHex ( B ) }
/* From the specification. */
var HLSMAX = 255 ;
/* From https://gist.github.com/mjackson/5311256 via http://stackoverflow.com/a/9493060 */
/ * *
* Converts an RGB color value to HSL . Conversion formula
* adapted from http : //en.wikipedia.org/wiki/HSL_color_space.
* Assumes r , g , and b are contained in the set [ 0 , 255 ] and
* returns h , s , and l in the set [ 0 , 1 ] .
*
* @ param Number r The red color value
* @ param Number g The green color value
* @ param Number b The blue color value
* @ return Array The HSL representation
* /
function rgbToHsl ( r , g , b ) {
r /= 255 , g /= 255 , b /= 255 ;
var max = Math . max ( r , g , b ) , min = Math . min ( r , g , b ) ;
var h , s , l = ( max + min ) / 2 ;
if ( max == min ) {
h = s = 0 ; // achromatic
} else {
var d = max - min ;
s = l > 0.5 ? d / ( 2 - max - min ) : d / ( max + min ) ;
switch ( max ) {
case r : h = ( g - b ) / d + ( g < b ? 6 : 0 ) ; break ;
case g : h = ( b - r ) / d + 2 ; break ;
case b : h = ( r - g ) / d + 4 ; break ;
}
h /= 6 ;
}
return [ h , s , l ] ;
}
/ * *
* Converts an HSL color value to RGB . Conversion formula
* adapted from http : //en.wikipedia.org/wiki/HSL_color_space.
* Assumes h , s , and l are contained in the set [ 0 , 1 ] and
* returns r , g , and b in the set [ 0 , 255 ] .
*
* @ param Number h The hue
* @ param Number s The saturation
* @ param Number l The lightness
* @ return Array The RGB representation
* /
function hslToRgb ( h , s , l ) {
var r , g , b ;
if ( s == 0 ) {
r = g = b = l ; // achromatic
} else {
function hue2rgb ( p , q , t ) {
if ( t < 0 ) t += 1 ;
if ( t > 1 ) t -= 1 ;
if ( t < 1 / 6 ) return p + ( q - p ) * 6 * t ;
if ( t < 1 / 2 ) return q ;
if ( t < 2 / 3 ) return p + ( q - p ) * ( 2 / 3 - t ) * 6 ;
return p ;
}
var q = l < 0.5 ? l * ( 1 + s ) : l + s - l * s ;
var p = 2 * l - q ;
r = hue2rgb ( p , q , h + 1 / 3 ) ;
g = hue2rgb ( p , q , h ) ;
b = hue2rgb ( p , q , h - 1 / 3 ) ;
}
return [ Math . round ( r * 255 ) , Math . round ( g * 255 ) , Math . round ( b * 255 ) ] ;
}
/* Utility function to apply tint to an RGB color. */
function rgb _tint ( rgb , tint ) {
var r = hexToR ( rgb ) ,
g = hexToG ( rgb ) ,
b = hexToB ( rgb ) ,
hsl = rgbToHsl ( r , g , b ) ;
/* Apply tint as described in pages 1757-1758 of the ECMA Office Open XML specification. */
/* NOTE: This is totally messed up... see http://social.msdn.microsoft.com/Forums/en-US/e9d8c136-6d62-4098-9b1b-dac786149f43/excel-color-tint-algorithm-incorrect */
if ( tint < 0 ) {
hsl [ 2 ] = hsl [ 2 ] * ( 1.0 + tint ) ;
} else if ( tint > 0 ) {
hsl [ 2 ] = hsl [ 2 ] * ( 1.0 + tint ) ;
// XXX This doesn't work...
//hsl[2] = hsl[2] * (1.0 - tint) + (HLSMAX - HLSMAX * (1.0 - tint));
}
rgb = hslToRgb ( hsl [ 0 ] , hsl [ 1 ] , hsl [ 2 ] ) ;
return rgbToHex ( rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ;
}
function parse _clrScheme ( t , opts ) {
themes . themeElements . clrScheme = [ ] ;
var color = { } ;
t [ 0 ] . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
case '<a:clrScheme' : case '</a:clrScheme>' : break ;
/* 20.1.2.3.32 srgbClr CT_SRgbColor */
case '<a:srgbClr' : color . rgb = y . val ; break ;
/* 20.1.2.3.33 sysClr CT_SystemColor */
case '<a:sysClr' : color . rgb = y . lastClr ; break ;
/* 20.1.4.1.9 dk1 (Dark 1) */
case '<a:dk1>' :
case '</a:dk1>' :
/* 20.1.4.1.10 dk2 (Dark 2) */
case '<a:dk2>' :
case '</a:dk2>' :
/* 20.1.4.1.22 lt1 (Light 1) */
case '<a:lt1>' :
case '</a:lt1>' :
/* 20.1.4.1.23 lt2 (Light 2) */
case '<a:lt2>' :
case '</a:lt2>' :
/* 20.1.4.1.1 accent1 (Accent 1) */
case '<a:accent1>' :
case '</a:accent1>' :
/* 20.1.4.1.2 accent2 (Accent 2) */
case '<a:accent2>' :
case '</a:accent2>' :
/* 20.1.4.1.3 accent3 (Accent 3) */
case '<a:accent3>' :
case '</a:accent3>' :
/* 20.1.4.1.4 accent4 (Accent 4) */
case '<a:accent4>' :
case '</a:accent4>' :
/* 20.1.4.1.5 accent5 (Accent 5) */
case '<a:accent5>' :
case '</a:accent5>' :
/* 20.1.4.1.6 accent6 (Accent 6) */
case '<a:accent6>' :
case '</a:accent6>' :
/* 20.1.4.1.19 hlink (Hyperlink) */
case '<a:hlink>' :
case '</a:hlink>' :
/* 20.1.4.1.15 folHlink (Followed Hyperlink) */
case '<a:folHlink>' :
case '</a:folHlink>' :
if ( y [ 0 ] [ 1 ] === '/' ) {
themes . themeElements . clrScheme . push ( color ) ;
color = { } ;
} else {
color . name = y [ 0 ] . substring ( 3 , y [ 0 ] . length - 1 ) ;
}
break ;
default : if ( opts . WTF ) throw 'unrecognized ' + y [ 0 ] + ' in clrScheme' ;
}
} ) ;
}
/* 14.2.7 Theme Part */
function parse _theme _xml ( data , opts ) {
themes . themeElements = { } ;
var t ;
/* clrScheme */
if ( ( t = data . match ( /<a:clrScheme([^>]*)>.*<\/a:clrScheme>/ ) ) ) parse _clrScheme ( t , opts ) ;
return themes ;
}
2014-05-16 00:33:34 +00:00
function write _theme ( ) { return ' < ? xml version = "1.0" encoding = "UTF-8" standalone = "yes" ? > \ n < a : theme xmlns : a = "http://schemas.openxmlformats.org/drawingml/2006/main" name = "Office Theme" > < a : themeElements > < a : clrScheme name = "Office" > < a : dk1 > < a : sysClr val = "windowText" lastClr = "000000" / > < /a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/ > < /a:lt1><a:dk2><a:srgbClr val="1F497D"/ > < /a:dk2><a:lt2><a:srgbClr val="EEECE1"/ > < /a:lt2><a:accent1><a:srgbClr val="4F81BD"/ > < /a:accent1><a:accent2><a:srgbClr val="C0504D"/ > < /a:accent2><a:accent3><a:srgbClr val="9BBB59"/ > < /a:accent3><a:accent4><a:srgbClr val="8064A2"/ > < /a:accent4><a:accent5><a:srgbClr val="4BACC6"/ > < /a:accent5><a:accent6><a:srgbClr val="F79646"/ > < /a:accent6><a:hlink><a:srgbClr val="0000FF"/ > < /a:hlink><a:folHlink><a:srgbClr val="800080"/ > < / a : f o l H l i n k > < / a : c l r S c h e m e > < a : f o n t S c h e m e n a m e = " O f f i c e " > < a : m a j o r F o n t > < a : l a t i n t y p e f a c e = " C a m b r i a " / > < a : e a t y p e f a c e = " " / > < a : c s t y p e f a c e = " " / > < a : f o n t s c r i p t = " J p a n " t y p e f a c e = " M S P ゴ シ ッ ク " / > < a : f o n t s c r i p t = " H a n g " t y p e f a c e = " 맑 은 고 딕 " / > < a : f o n t s c r i p t = " H a n s " t y p e f a c e = " 宋 体 " / > < a : f o n t s c r i p t = " H a n t " t y p e f a c e = " 新 細 明 體 " / > < a : f o n t s c r i p t = " A r a b " t y p e f a c e = " T i m e s N e w R o m a n " / > < a : f o n t s c r i p t = " H e b r " t y p e f a c e = " T i m e s N e w R o m a n " / > < a : f o n t s c r i p t = " T h a i " t y p e f a c e = " T a h o m a " / > < a : f o n t s c r i p t = " E t h i " t y p e f a c e = " N y a l a " / > < a : f o n t s c r i p t = " B e n g " t y p e f a c e = " V r i n d a " / > < a : f o n t s c r i p t = " G u j r " t y p e f a c e = " S h r u t i " / > < a : f o n t s c r i p t = " K h m r " t y p e f a c e = " M o o l B o r a n " / > < a : f o n t s c r i p t = " K n d a " t y p e f a c e = " T u n g a " / > < a : f o n t s c r i p t = " G u r u " t y p e f a c e = " R a a v i " / > < a : f o n t s c r i p t = " C a n s " t y p e f a c e = " E u p h e m i a " / > < a : f o n t s c r i p t = " C h e r " t y p e f a c e = " P l a n t a g e n e t C h e r o k e e " / > < a : f o n t s c r i p t = " Y i i i " t y p e f a c e = " M i c r o s o f t Y i B a i t i " / > < a : f o n t s c r i p t = " T i b t " t y p e f a c e = " M i c r o s o f t H i m a l a y a " / > < a : f o n t s c r i p t = " T h a a " t y p e f a c e = " M V B o l i " / > < a : f o n t s c r i p t = " D e v a " t y p e f a c e = " M a n g a l " / > < a : f o n t s c r i p t = " T e l u " t y p e f a c e = " G a u t a m i " / > < a : f o n t s c r i p t = " T a m l " t y p e f a c e = " L a t h a " / > < a : f o n t s c r i p t = " S y r c " t y p e f a c e = " E s t r a n g e l o E d e s s a " / > < a : f o n t s c r i p t = " O r y a " t y p e f a c e = " K a l i n g a " / > < a : f o n t s c r i p t = " M l y m " t y p e f a c e = " K a r t i k a " / > < a : f o n t s c r i p t = " L a o o " t y p e f a c e = " D o k C h a m p a " / > < a : f o n t s c r i p t = " S i n h " t y p e f a c e = " I s k o o l a P o t a " / > < a : f o n t s c r i p t = " M o n g " t y p e f a c e = " M o n g o l i a n B a i t i " / > < a : f o n t s c r i p t = " V i e t " t y p e f a c e = " T i m e s N e w R o m a n " / > < a : f o n t s c r i p t = " U i g h " t y p e f a c e = " M i c r o s o f t U i g h u r " / > < a : f o n t s c r i p t = " G e o r " t y p e f a c e = " S y l f a e n " / > < / a : m a j o r F o n t > < a : m i n o r F o n t > < a : l a t i n t y p e f a c e = " C a l i b r i " / > < a : e a t y p e f a c e = " " / > < a : c s t y p e f a c e = " " / > < a : f o n t s c r i p t = " J p a n " t y p e f a c e = " M S P ゴ シ ッ ク " / > < a : f o n t s c r i p t = " H a n g " t y p e f a c e = " 맑 은 고 딕 " / > < a : f o n t s c r i p t = " H a n s " t y p e f a c e = " 宋 体 " / > < a : f o n t s c r i p t = " H a n t " t y p e f a c e = " 新 細 明 體 " / > < a : f o n t s c r i p t = " A r a b " t y p e f a c e = " A r i a l " / > < a : f o n t s c r i p t = " H e b r " t y p e f a c e = " A r i a l " / > < a : f o n t s c r i p t = " T h a i " t y p e f a c e = " T a h o m a " / > < a : f o n t s c r i p t = " E t h i " t y p e f a c e = " N y a l a " / > < a : f o n t s c r i p t = " B e n g " t y p e f a c e = " V r i n d a " / > < a : f o n t s c r i p t = " G u j r " t y p e f a c e = " S h r u t i " / > < a : f o n t s c r i p t = " K h m r " t y p e f a c e = " D a u n P e n h " / > < a : f o n t s c r i p t = " K n d a " t y p e f a c e = " T u n g a " / > < a : f o n t s c r i p t = " G u r u " t y p e f a c e = " R a a v i " / > < a : f o n t s c r i p t = " C a n s " t y p e f a c e = " E u p h e m i a " / > < a : f o n t s c r i p t = " C h e r " t y p e f a c e = " P l a n t a g e n e t C h e r o k e e " / > < a : f o n t s c r i p t = " Y i i i " t y p e f a c e = " M i c r o s o f t Y i B a i t i " / > < a : f o n t s c r i p t = " T i b t " t y p e f a c e = " M i c r o s o f t H i m a l a y a " / > < a : f o n t s c r i p t = " T h a a " t y p e f a c e = " M V B o l i " / > < a : f o n t s c r i p t = " D e v a " t y p e f a c e = " M a n g a l " / > < a : f o n t s c r i p t = " T e l u " t y p e f a c e = " G a u t a m i " / > < a : f o n t s c r i p t = " T a m l " t y p e f a c e = " L a t h a " / > < a : f o n t s c r i p t = " S y r c " t y p e f a c e = " E s t r a n g e l o E d e s s a " / > < a : f o n t s c r i p t = " O r y a " t y p e f a c e = " K a l i n g a " / > < a : f o n t s c r i p t = " M l y m " t y p e f a c e = " K a r t i k a " / > < a : f o n t s c r i p t = " L a o o " t y p e f a c e = " D o k C h a m p a " / > < a : f o n t s c r i p t = " S i n h " t y p e f a c e = " I s k o o l a P o t a " / > < a : f o n t s c r i p t = " M o n g " t y p e f a c e = " M o n g o l i a n B a i t i " / > < a : f o n t s c r i p t = " V i e t " t y p e f a c e = " A r i a l " / > < a : f o n t s c r i p t = " U i g h " t y p e f a c e = " M i c r o s o f t U i g h u r " / > < a : f o n t s c r i p t = " G e o r " t y p e f a c e = " S y l f a e n " / > < / a : m i n o r F o n t > < / a : f o n t S c h e m e > < a : f m t S c h e m e n a m e = " O f f i c e " > < a : f i l l S t y l e L s t > < a : s o l i d F i l l > < a : s c h e m e C l r v a l = " p h C l r " / > < / a : s o l i d F i l l > < a : g r a d F i l l r o t W i t h S h a p e = " 1 " > < a : g s L s t > < a : g s p o s = " 0 " > < a : s c h e m e C l r v a l = " p h C l r " > < a : t i n t v a l = " 5 0 0 0 0 " / > < a : s a t M o d v a l = " 3 0 0 0 0 0 " / > < / a : s c h e m e C l r > < / a : g s > < a : g s p o s = " 3 5 0 0 0 " > < a : s c h e m e C l r v a l = " p h C l r " > < a : t i n t v a l = " 3 7 0 0 0 " / > < a : s a t M o d v a l = " 3 0 0 0 0 0 " / > < / a : s c h e m e C
2014-03-29 22:53:15 +00:00
/* 18.6 Calculation Chain */
function parse _cc _xml ( data , opts ) {
var d = [ ] ;
var l = 0 , i = 1 ;
( data . match ( /<[^>]*>/g ) || [ ] ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
switch ( y [ 0 ] ) {
case '<?xml' : break ;
/* 18.6.2 calcChain CT_CalcChain 1 */
case '<calcChain' : case '<calcChain>' : case '</calcChain>' : break ;
/* 18.6.1 c CT_CalcCell 1 */
case '<c' : delete y [ 0 ] ; if ( y . i ) i = y . i ; else y . i = i ; d . push ( y ) ; break ;
}
} ) ;
return d ;
}
2014-05-29 22:30:03 +00:00
function write _cc _xml ( data , opts ) { }
2014-03-29 22:53:15 +00:00
/* [MS-XLSB] 2.6.4.1 */
var parse _BrtCalcChainItem$ = function ( data , length ) {
var out = { } ;
out . i = data . read _shift ( 4 ) ;
var cell = { } ;
cell . r = data . read _shift ( 4 ) ;
cell . c = data . read _shift ( 4 ) ;
out . r = encode _cell ( cell ) ;
var flags = data . read _shift ( 1 ) ;
if ( flags & 0x2 ) out . l = '1' ;
if ( flags & 0x8 ) out . a = '1' ;
return out ;
} ;
/* 18.6 Calculation Chain */
function parse _cc _bin ( data , opts ) {
var out = [ ] ;
var pass = false ;
recordhopper ( data , function ( val , R , RT ) {
switch ( R . n ) {
case 'BrtCalcChainItem$' : out . push ( val ) ; break ;
case 'BrtBeginCalcChain$' : break ;
case 'BrtEndCalcChain$' : break ;
default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + RT + " " + R . n ) ;
}
} ) ;
return out ;
}
2014-05-29 22:30:03 +00:00
function write _cc _bin ( data , opts ) { }
2014-02-17 08:44:22 +00:00
/* 18.7.3 CT_Comment */
function parse _comments _xml ( data , opts ) {
2014-04-03 22:51:54 +00:00
if ( data . match ( /<(?:\w+:)?comments *\/>/ ) ) return [ ] ;
2014-02-17 08:44:22 +00:00
var authors = [ ] ;
var commentList = [ ] ;
2014-04-03 22:51:54 +00:00
data . match ( /<(?:\w+:)?authors>([^\u2603]*)<\/(?:\w+:)?authors>/m ) [ 1 ] . split ( /<\/(?:\w+:)?author>/ ) . forEach ( function ( x ) {
2014-02-17 08:44:22 +00:00
if ( x === "" || x . trim ( ) === "" ) return ;
2014-04-03 22:51:54 +00:00
authors . push ( x . match ( /<(?:\w+:)?author[^>]*>(.*)/ ) [ 1 ] ) ;
2014-02-17 08:44:22 +00:00
} ) ;
2014-04-03 22:51:54 +00:00
( data . match ( /<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/m ) || [ "" , "" ] ) [ 1 ] . split ( /<\/(?:\w+:)?comment>/ ) . forEach ( function ( x , index ) {
2014-02-17 08:44:22 +00:00
if ( x === "" || x . trim ( ) === "" ) return ;
2014-04-03 22:51:54 +00:00
var y = parsexmltag ( x . match ( /<(?:\w+:)?comment[^>]*>/ ) [ 0 ] ) ;
2014-02-17 08:44:22 +00:00
var comment = { author : y . authorId && authors [ y . authorId ] ? authors [ y . authorId ] : undefined , ref : y . ref , guid : y . guid } ;
2014-02-19 03:11:39 +00:00
var cell = decode _cell ( y . ref ) ;
if ( opts . sheetRows && opts . sheetRows <= cell . r ) return ;
2014-02-17 08:44:22 +00:00
var textMatch = x . match ( /<text>([^\u2603]*)<\/text>/m ) ;
if ( ! textMatch || ! textMatch [ 1 ] ) return ; // a comment may contain an empty text tag.
var rt = parse _si ( textMatch [ 1 ] ) ;
comment . r = rt . r ;
comment . t = rt . t ;
if ( opts . cellHTML ) comment . h = rt . h ;
commentList . push ( comment ) ;
} ) ;
return commentList ;
}
2014-05-29 22:30:03 +00:00
function write _comments _xml ( data , opts ) { }
2014-03-29 02:05:50 +00:00
/* [MS-XLSB] 2.4.28 BrtBeginComment */
var parse _BrtBeginComment = function ( data , length ) {
var out = { } ;
out . iauthor = data . read _shift ( 4 ) ;
var rfx = parse _UncheckedRfX ( data , 16 ) ;
out . rfx = rfx . s ;
out . ref = encode _cell ( rfx . s ) ;
data . l += 16 ; /*var guid = parse_GUID(data); */
return out ;
} ;
/* [MS-XLSB] 2.4.324 BrtCommentAuthor */
var parse _BrtCommentAuthor = parse _XLWideString ;
/* [MS-XLSB] 2.4.325 BrtCommentText */
var parse _BrtCommentText = parse _RichStr ;
/* [MS-XLSB] 2.1.7.8 Comments */
function parse _comments _bin ( data , opts ) {
var out = [ ] ;
var authors = [ ] ;
var c = { } ;
var pass = false ;
recordhopper ( data , function ( val , R , RT ) {
switch ( R . n ) {
case 'BrtCommentAuthor' : authors . push ( val ) ; break ;
case 'BrtBeginComment' : c = val ; break ;
case 'BrtCommentText' : c . t = val . t ; c . h = val . h ; c . r = val . r ; break ;
case 'BrtEndComment' :
c . author = authors [ c . iauthor ] ;
delete c . iauthor ;
if ( opts . sheetRows && opts . sheetRows <= c . rfx . r ) break ;
delete c . rfx ; out . push ( c ) ; break ;
case 'BrtBeginComments' : break ;
case 'BrtEndComments' : break ;
case 'BrtBeginCommentAuthors' : break ;
case 'BrtEndCommentAuthors' : break ;
case 'BrtBeginCommentList' : break ;
case 'BrtEndCommentList' : break ;
default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + RT + " " + R . n ) ;
}
} ) ;
return out ;
}
2014-02-17 08:44:22 +00:00
2014-05-29 22:30:03 +00:00
function write _comments _bin ( data , opts ) { }
2014-02-17 08:44:22 +00:00
function parse _comments ( zip , dirComments , sheets , sheetRels , opts ) {
for ( var i = 0 ; i != dirComments . length ; ++ i ) {
var canonicalpath = dirComments [ i ] ;
2014-03-29 02:05:50 +00:00
var comments = parse _cmnt ( getzipdata ( zip , canonicalpath . replace ( /^\// , '' ) , true ) , canonicalpath , opts ) ;
2014-02-19 03:11:39 +00:00
if ( ! comments || ! comments . length ) continue ;
2014-02-17 08:44:22 +00:00
// find the sheets targeted by these comments
2014-05-16 00:33:34 +00:00
var sheetNames = keys ( sheets ) ;
2014-02-17 08:44:22 +00:00
for ( var j = 0 ; j != sheetNames . length ; ++ j ) {
var sheetName = sheetNames [ j ] ;
var rels = sheetRels [ sheetName ] ;
if ( rels ) {
var rel = rels [ canonicalpath ] ;
if ( rel ) insertCommentsIntoSheet ( sheetName , sheets [ sheetName ] , comments ) ;
}
}
}
}
function insertCommentsIntoSheet ( sheetName , sheet , comments ) {
comments . forEach ( function ( comment ) {
var cell = sheet [ comment . ref ] ;
if ( ! cell ) {
cell = { } ;
sheet [ comment . ref ] = cell ;
2014-03-29 22:53:15 +00:00
var range = decode _range ( sheet [ "!ref" ] || "BDWGO1000001:A1" ) ;
2014-02-17 08:44:22 +00:00
var thisCell = decode _cell ( comment . ref ) ;
if ( range . s . r > thisCell . r ) range . s . r = thisCell . r ;
if ( range . e . r < thisCell . r ) range . e . r = thisCell . r ;
if ( range . s . c > thisCell . c ) range . s . c = thisCell . c ;
if ( range . e . c < thisCell . c ) range . e . c = thisCell . c ;
var encoded = encode _range ( range ) ;
if ( encoded !== sheet [ "!ref" ] ) sheet [ "!ref" ] = encoded ;
}
if ( ! cell . c ) cell . c = [ ] ;
var o = { a : comment . author , t : comment . t , r : comment . r } ;
if ( comment . h ) o . h = comment . h ;
cell . c . push ( o ) ;
} ) ;
}
/* [MS-XLSB] 2.5.97.4 CellParsedFormula TODO: use similar logic to js-xls */
var parse _CellParsedFormula = function ( data , length ) {
var cce = data . read _shift ( 4 ) ;
return parsenoop ( data , length - 4 ) ;
} ;
var strs = { } ; // shared strings
var _ssfopts = { } ; // spreadsheet formatting options
2014-05-16 00:33:34 +00:00
RELS . WS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" ;
function get _sst _id ( sst , str ) {
for ( var i = 0 ; i != sst . length ; ++ i ) if ( sst [ i ] . t === str ) { sst . Count ++ ; return i ; }
sst [ sst . length ] = { t : str } ; sst . Count ++ ; sst . Unique ++ ; return sst . length - 1 ;
}
function get _cell _style ( styles , cell , opts ) {
2014-05-22 12:16:51 +00:00
var z = opts . revssf [ cell . z || "General" ] ;
2014-05-16 00:33:34 +00:00
for ( var i = 0 ; i != styles . length ; ++ i ) if ( styles [ i ] . numFmtId === z ) return i ;
styles [ styles . length ] = {
numFmtId : z ,
fontId : 0 ,
fillId : 0 ,
borderId : 0 ,
xfId : 0 ,
applyNumberFormat : 1
} ;
return styles . length - 1 ;
}
2014-02-17 08:44:22 +00:00
/* 18.3 Worksheets */
2014-04-15 09:04:03 +00:00
function parse _ws _xml ( data , opts , rels ) {
2014-02-17 08:44:22 +00:00
if ( ! data ) return data ;
/* 18.3.1.99 worksheet CT_Worksheet */
2014-05-22 12:16:51 +00:00
var s = { } , mtch ;
2014-02-17 08:44:22 +00:00
/* 18.3.1.35 dimension CT_SheetDimension ? */
var ref = data . match ( /<dimension ref="([^"]*)"\s*\/>/ ) ;
if ( ref && ref . length == 2 && ref [ 1 ] . indexOf ( ":" ) !== - 1 ) s [ "!ref" ] = ref [ 1 ] ;
2014-03-23 21:30:00 +00:00
/* 18.3.1.55 mergeCells CT_MergeCells */
var mergecells = [ ] ;
if ( data . match ( /<\/mergeCells>/ ) ) {
var merges = data . match ( /<mergeCell ref="([A-Z0-9:]+)"\s*\/>/g ) ;
2014-05-16 00:33:34 +00:00
mergecells = merges . map ( function ( range ) {
2014-03-23 21:30:00 +00:00
return decode _range ( /<mergeCell ref="([A-Z0-9:]+)"\s*\/>/ . exec ( range ) [ 1 ] ) ;
} ) ;
}
2014-02-17 08:44:22 +00:00
var refguess = { s : { r : 1000000 , c : 1000000 } , e : { r : 0 , c : 0 } } ;
var sidx = 0 ;
2014-03-23 21:30:00 +00:00
2014-05-31 15:44:56 +00:00
var match _v = matchtag ( "v" ) , match _f = matchtag ( "f" ) ;
2014-02-17 08:44:22 +00:00
/* 18.3.1.80 sheetData CT_SheetData ? */
2014-05-31 15:44:56 +00:00
mtch = data . match ( /<(?:\w+:)?sheetData>([^\u2603]*)<\/(?:\w+:)?sheetData>/m ) ;
if ( mtch ) for ( var marr = mtch [ 1 ] . split ( /<\/(?:\w+:)?row>/ ) , mt = 0 ; mt != marr . length ; ++ mt ) {
x = marr [ mt ] ;
if ( x === "" || x . trim ( ) === "" ) continue ;
2014-02-17 08:44:22 +00:00
/* 18.3.1.73 row CT_Row */
2014-04-03 22:51:54 +00:00
var row = parsexmltag ( x . match ( /<(?:\w+:)?row[^>]*>/ ) [ 0 ] ) ;
2014-05-31 15:44:56 +00:00
if ( opts . sheetRows && opts . sheetRows < + row . r ) continue ;
2014-02-17 08:44:22 +00:00
if ( refguess . s . r > row . r - 1 ) refguess . s . r = row . r - 1 ;
if ( refguess . e . r < row . r - 1 ) refguess . e . r = row . r - 1 ;
/* 18.3.1.4 c CT_Cell */
2014-04-03 22:51:54 +00:00
var cells = x . substr ( x . indexOf ( '>' ) + 1 ) . split ( /<(?:\w+:)?c / ) ;
2014-05-31 15:44:56 +00:00
for ( var ix = 0 , c = cells [ 0 ] ; ix != cells . length ; ++ ix , c = cells [ ix ] ) {
if ( c === "" || c . trim ( ) === "" ) continue ;
var cref = c . match ( /r=["']([^"']*)["']/ ) , idx = ix ;
2014-02-17 08:44:22 +00:00
c = "<c " + c ;
2014-02-26 19:30:32 +00:00
if ( cref && cref . length == 2 ) idx = decode _cell ( cref [ 1 ] ) . c ;
2014-02-17 08:44:22 +00:00
var cell = parsexmltag ( ( c . match ( /<c[^>]*>/ ) || [ c ] ) [ 0 ] ) ; delete cell [ 0 ] ;
var d = c . substr ( c . indexOf ( '>' ) + 1 ) ;
var p = { } ;
2014-05-31 15:44:56 +00:00
var x = d . match ( match _v ) ; if ( x ) p . v = unescapexml ( x [ 1 ] ) ;
if ( opts . cellFormula ) { x = d . match ( match _f ) ; if ( x ) p . f = unescapexml ( x [ 1 ] ) ; }
2014-02-17 08:44:22 +00:00
/* SCHEMA IS ACTUALLY INCORRECT HERE. IF A CELL HAS NO T, EMIT "" */
if ( cell . t === undefined && p . v === undefined ) {
2014-05-31 15:44:56 +00:00
if ( ! opts . sheetStubs ) continue ;
2014-02-17 08:44:22 +00:00
p . t = "str" ; p . v = undefined ;
}
else p . t = ( cell . t ? cell . t : "n" ) ; // default is "n" in schema
if ( refguess . s . c > idx ) refguess . s . c = idx ;
if ( refguess . e . c < idx ) refguess . e . c = idx ;
/* 18.18.11 t ST_CellType */
switch ( p . t ) {
case 'n' : p . v = parseFloat ( p . v ) ; break ;
case 's' : {
sidx = parseInt ( p . v , 10 ) ;
p . v = strs [ sidx ] . t ;
p . r = strs [ sidx ] . r ;
if ( opts . cellHTML ) p . h = strs [ sidx ] . h ;
} break ;
case 'str' : if ( p . v ) p . v = utf8read ( p . v ) ; break ;
case 'inlineStr' :
var is = d . match ( /<is>(.*)<\/is>/ ) ;
is = is ? parse _si ( is [ 1 ] ) : { t : "" , r : "" } ;
p . t = 'str' ; p . v = is . t ;
break ; // inline string
case 'b' : if ( typeof p . v !== 'boolean' ) p . v = parsexmlbool ( p . v ) ; break ;
2014-05-22 12:16:51 +00:00
case 'd' :
p . v = datenum ( p . v ) ;
2014-02-17 08:44:22 +00:00
p . t = 'n' ;
break ;
/* in case of error, stick value in .raw */
case 'e' : p . raw = RBErr [ p . v ] ; break ;
}
/* formatting */
2014-05-29 22:30:03 +00:00
var fmtid = 0 , fillid = 0 ;
2014-02-17 08:44:22 +00:00
if ( cell . s && styles . CellXf ) {
var cf = styles . CellXf [ cell . s ] ;
if ( cf && cf . numFmtId ) fmtid = cf . numFmtId ;
2014-05-29 22:30:03 +00:00
if ( opts . cellStyles && cf && cf . fillId ) fillid = cf . fillId ;
2014-02-17 08:44:22 +00:00
}
try {
p . w = SSF . format ( fmtid , p . v , _ssfopts ) ;
if ( opts . cellNF ) p . z = SSF . _table [ fmtid ] ;
2014-05-29 22:30:03 +00:00
if ( fillid ) {
p . s = styles . Fills [ fillid ] ;
if ( p . s . fgColor && p . s . fgColor . theme ) {
p . s . fgColor . rgb = rgb _tint ( themes . themeElements . clrScheme [ p . s . fgColor . theme ] . rgb , p . s . fgColor . tint || 0 ) ;
}
if ( p . s . bgColor && p . s . bgColor . theme ) {
p . s . bgColor . rgb = rgb _tint ( themes . themeElements . clrScheme [ p . s . bgColor . theme ] . rgb , p . s . bgColor . tint || 0 ) ;
}
}
2014-02-17 08:44:22 +00:00
} catch ( e ) { if ( opts . WTF ) throw e ; }
s [ cell . r ] = p ;
2014-05-31 15:44:56 +00:00
} ;
}
2014-04-15 09:04:03 +00:00
/* 18.3.1.48 hyperlinks CT_Hyperlinks */
if ( data . match ( /<\/hyperlinks>/ ) ) data . match ( /<hyperlink[^>]*\/>/g ) . forEach ( function ( h ) {
var val = parsexmltag ( h ) ; delete val [ 0 ] ;
if ( ! val . ref ) return ;
var rel = rels [ '!id' ] [ val . id ] ;
if ( rel ) {
val . Target = rel . Target ;
if ( val . location ) val . Target += "#" + val . location ;
val . Rel = rel ;
}
var rng = decode _range ( val . ref ) ;
for ( var R = rng . s . r ; R <= rng . e . r ; ++ R ) for ( var C = rng . s . c ; C <= rng . e . c ; ++ C ) {
var addr = encode _cell ( { c : C , r : R } ) ;
if ( ! s [ addr ] ) s [ addr ] = { t : "str" , v : undefined } ;
s [ addr ] . l = val ;
}
} ) ;
2014-03-29 22:53:15 +00:00
if ( ! s [ "!ref" ] && refguess . e . c >= refguess . s . c && refguess . e . r >= refguess . s . r ) s [ "!ref" ] = encode _range ( refguess ) ;
if ( opts . sheetRows && s [ "!ref" ] ) {
2014-02-19 03:11:39 +00:00
var tmpref = decode _range ( s [ "!ref" ] ) ;
if ( opts . sheetRows < + tmpref . e . r ) {
tmpref . e . r = opts . sheetRows - 1 ;
if ( tmpref . e . r > refguess . e . r ) tmpref . e . r = refguess . e . r ;
if ( tmpref . e . r < tmpref . s . r ) tmpref . s . r = tmpref . e . r ;
if ( tmpref . e . c > refguess . e . c ) tmpref . e . c = refguess . e . c ;
if ( tmpref . e . c < tmpref . s . c ) tmpref . s . c = tmpref . e . c ;
s [ "!fullref" ] = s [ "!ref" ] ;
s [ "!ref" ] = encode _range ( tmpref ) ;
}
}
2014-03-23 21:30:00 +00:00
if ( mergecells . length > 0 ) s [ "!merges" ] = mergecells ;
2014-02-17 08:44:22 +00:00
return s ;
}
2014-05-16 00:33:34 +00:00
var WS _XML _ROOT = writextag ( 'worksheet' , null , {
'xmlns' : XMLNS . main [ 0 ] ,
'xmlns:r' : XMLNS . r
} ) ;
var write _ws _xml _cell = function ( cell , ref , ws , opts , idx , wb ) {
2014-05-22 12:16:51 +00:00
var vv = cell . v ; if ( cell . t == 'b' ) vv = cell . v ? "1" : "0" ;
var v = writextag ( 'v' , escapexml ( String ( vv ) ) ) , o = { r : ref } ;
o . s = get _cell _style ( opts . cellXfs , cell , opts ) ;
if ( o . s === 0 || o . s === "0" ) delete o . s ;
2014-05-16 00:33:34 +00:00
/* TODO: cell style */
if ( typeof cell . v === 'undefined' ) return "" ;
switch ( cell . t ) {
case 's' : case 'str' : {
if ( opts . bookSST ) {
v = writextag ( 'v' , String ( get _sst _id ( opts . Strings , cell . v ) ) ) ;
o . t = "s" ; return writextag ( 'c' , v , o ) ;
} else { o . t = "str" ; return writextag ( 'c' , v , o ) ; }
} break ;
2014-05-22 12:16:51 +00:00
case 'n' : delete o . t ; return writextag ( 'c' , v , o ) ;
2014-05-16 00:33:34 +00:00
case 'b' : o . t = "b" ; return writextag ( 'c' , v , o ) ;
2014-05-16 00:50:55 +00:00
case 'e' : o . t = "e" ; return writextag ( 'c' , v , o ) ;
2014-05-16 00:33:34 +00:00
}
} ;
var write _ws _xml _data = function ( ws , opts , idx , wb ) {
var o = [ ] , r = [ ] , range = utils . decode _range ( ws [ '!ref' ] ) , cell , ref ;
for ( var R = range . s . r ; R <= range . e . r ; ++ R ) {
r = [ ] ;
for ( var C = range . s . c ; C <= range . e . c ; ++ C ) {
ref = utils . encode _cell ( { c : C , r : R } ) ;
if ( ! ws [ ref ] ) continue ;
if ( ( cell = write _ws _xml _cell ( ws [ ref ] , ref , ws , opts , idx , wb ) ) ) r . push ( cell ) ;
}
if ( r . length ) o . push ( writextag ( 'row' , r . join ( "" ) , { r : encode _row ( R ) } ) ) ;
}
return o . join ( "" ) ;
} ;
var write _ws _xml = function ( idx , opts , wb ) {
var o = [ ] , s = wb . SheetNames [ idx ] , ws = wb . Sheets [ s ] || { } , sidx = 0 , rdata = "" ;
o . push ( XML _HEADER ) ;
o . push ( WS _XML _ROOT ) ;
o . push ( writextag ( 'dimension' , null , { 'ref' : ws [ '!ref' ] || 'A1' } ) ) ;
sidx = o . length ;
o . push ( writextag ( 'sheetData' , null ) ) ;
if ( ws [ '!ref' ] ) rdata = write _ws _xml _data ( ws , opts , idx , wb ) ;
if ( rdata . length ) o . push ( rdata ) ;
if ( o . length > sidx + 1 ) { o . push ( '</sheetData>' ) ; o [ sidx ] = o [ sidx ] . replace ( "/>" , ">" ) ; }
if ( o . length > 2 ) { o . push ( '</worksheet>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.4.718 BrtRowHdr */
var parse _BrtRowHdr = function ( data , length ) {
var z = { } ;
z . r = data . read _shift ( 4 ) ;
data . l += length - 4 ;
return z ;
} ;
/* [MS-XLSB] 2.4.812 BrtWsDim */
var parse _BrtWsDim = parse _UncheckedRfX ;
2014-05-29 22:30:03 +00:00
var write _BrtWsDim = write _UncheckedRfX ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.4.815 BrtWsProp */
var parse _BrtWsProp = function ( data , length ) {
var z = { } ;
/* TODO: pull flags */
data . l += 19 ;
z . name = parse _CodeName ( data , length - 19 ) ;
return z ;
} ;
/* [MS-XLSB] 2.4.303 BrtCellBlank */
2014-03-29 22:53:15 +00:00
var parse _BrtCellBlank = function ( data , length ) {
var cell = parse _Cell ( data ) ;
return [ cell ] ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.4.304 BrtCellBool */
var parse _BrtCellBool = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var fBool = data . read _shift ( 1 ) ;
return [ cell , fBool , 'b' ] ;
} ;
/* [MS-XLSB] 2.4.305 BrtCellError */
var parse _BrtCellError = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var fBool = data . read _shift ( 1 ) ;
return [ cell , fBool , 'e' ] ;
} ;
/* [MS-XLSB] 2.4.308 BrtCellIsst */
var parse _BrtCellIsst = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var isst = data . read _shift ( 4 ) ;
return [ cell , isst , 's' ] ;
} ;
/* [MS-XLSB] 2.4.310 BrtCellReal */
var parse _BrtCellReal = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var value = parse _Xnum ( data ) ;
return [ cell , value , 'n' ] ;
} ;
/* [MS-XLSB] 2.4.311 BrtCellRk */
var parse _BrtCellRk = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var value = parse _RkNumber ( data ) ;
return [ cell , value , 'n' ] ;
} ;
/* [MS-XLSB] 2.4.314 BrtCellSt */
var parse _BrtCellSt = function ( data , length ) {
var cell = parse _Cell ( data ) ;
var value = parse _XLWideString ( data ) ;
return [ cell , value , 'str' ] ;
} ;
/* [MS-XLSB] 2.4.647 BrtFmlaBool */
var parse _BrtFmlaBool = function ( data , length , opts ) {
var cell = parse _Cell ( data ) ;
var value = data . read _shift ( 1 ) ;
var o = [ cell , value , 'b' ] ;
if ( opts . cellFormula ) {
var formula = parse _CellParsedFormula ( data , length - 9 ) ;
o [ 3 ] = "" ; /* TODO */
}
else data . l += length - 9 ;
return o ;
} ;
/* [MS-XLSB] 2.4.648 BrtFmlaError */
var parse _BrtFmlaError = function ( data , length , opts ) {
var cell = parse _Cell ( data ) ;
var value = data . read _shift ( 1 ) ;
var o = [ cell , value , 'e' ] ;
if ( opts . cellFormula ) {
var formula = parse _CellParsedFormula ( data , length - 9 ) ;
o [ 3 ] = "" ; /* TODO */
}
else data . l += length - 9 ;
return o ;
} ;
/* [MS-XLSB] 2.4.649 BrtFmlaNum */
var parse _BrtFmlaNum = function ( data , length , opts ) {
var cell = parse _Cell ( data ) ;
var value = parse _Xnum ( data ) ;
var o = [ cell , value , 'n' ] ;
if ( opts . cellFormula ) {
var formula = parse _CellParsedFormula ( data , length - 16 ) ;
o [ 3 ] = "" ; /* TODO */
}
else data . l += length - 16 ;
return o ;
} ;
/* [MS-XLSB] 2.4.650 BrtFmlaString */
var parse _BrtFmlaString = function ( data , length , opts ) {
var start = data . l ;
var cell = parse _Cell ( data ) ;
var value = parse _XLWideString ( data ) ;
var o = [ cell , value , 'str' ] ;
if ( opts . cellFormula ) {
var formula = parse _CellParsedFormula ( data , start + length - data . l ) ;
o [ 3 ] = "" ; /* TODO */
}
else data . l = start + length ;
return o ;
} ;
2014-03-23 21:30:00 +00:00
/* [MS-XLSB] 2.4.676 BrtMergeCell */
var parse _BrtMergeCell = parse _UncheckedRfX ;
2014-04-15 09:04:03 +00:00
/* [MS-XLSB] 2.4.656 BrtHLink */
var parse _BrtHLink = function ( data , length , opts ) {
var end = data . l + length ;
var rfx = parse _UncheckedRfX ( data , 16 ) ;
var relId = parse _XLNullableWideString ( data ) ;
var loc = parse _XLWideString ( data ) ;
var tooltip = parse _XLWideString ( data ) ;
var display = parse _XLWideString ( data ) ;
data . l = end ;
return { rfx : rfx , relId : relId , loc : loc , tooltip : tooltip , display : display } ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.1.7.61 Worksheet */
2014-04-15 09:04:03 +00:00
var parse _ws _bin = function ( data , opts , rels ) {
2014-02-17 08:44:22 +00:00
if ( ! data ) return data ;
2014-04-15 09:04:03 +00:00
if ( ! rels ) rels = { '!id' : { } } ;
2014-02-17 08:44:22 +00:00
var s = { } ;
var ref ;
2014-02-19 03:11:39 +00:00
var refguess = { s : { r : 1000000 , c : 1000000 } , e : { r : 0 , c : 0 } } ;
2014-02-17 08:44:22 +00:00
2014-02-19 03:11:39 +00:00
var pass = false , end = false ;
2014-04-15 09:04:03 +00:00
var row , p , cf , R , C , addr ;
2014-03-23 21:30:00 +00:00
var mergecells = [ ] ;
2014-02-17 08:44:22 +00:00
recordhopper ( data , function ( val , R ) {
2014-02-19 03:11:39 +00:00
if ( end ) return ;
2014-02-17 08:44:22 +00:00
switch ( R . n ) {
case 'BrtWsDim' : ref = val ; break ;
2014-02-19 03:11:39 +00:00
case 'BrtRowHdr' :
row = val ;
if ( opts . sheetRows && opts . sheetRows <= row . r ) end = true ;
break ;
2014-02-17 08:44:22 +00:00
case 'BrtFmlaBool' :
case 'BrtFmlaError' :
case 'BrtFmlaNum' :
case 'BrtFmlaString' :
case 'BrtCellBool' :
case 'BrtCellError' :
case 'BrtCellIsst' :
case 'BrtCellReal' :
case 'BrtCellRk' :
2014-03-19 17:53:20 +00:00
case 'BrtCellSt' :
2014-02-17 08:44:22 +00:00
p = { t : val [ 2 ] } ;
switch ( val [ 2 ] ) {
case 'n' : p . v = val [ 1 ] ; break ;
case 's' : p . v = strs [ val [ 1 ] ] . t ; p . r = strs [ val [ 1 ] ] . r ; break ;
case 'b' : p . v = val [ 1 ] ? true : false ; break ;
case 'e' : p . raw = val [ 1 ] ; p . v = BErr [ p . raw ] ; break ;
case 'str' : p . v = utf8read ( val [ 1 ] ) ; break ;
}
if ( opts . cellFormula && val . length > 3 ) p . f = val [ 3 ] ;
if ( ( cf = styles . CellXf [ val [ 0 ] . iStyleRef ] ) ) try {
p . w = SSF . format ( cf . ifmt , p . v , _ssfopts ) ;
if ( opts . cellNF ) p . z = SSF . _table [ cf . ifmt ] ;
} catch ( e ) { if ( opts . WTF ) throw e ; }
s [ encode _cell ( { c : val [ 0 ] . c , r : row . r } ) ] = p ;
2014-02-19 03:11:39 +00:00
if ( refguess . s . r > row . r ) refguess . s . r = row . r ;
if ( refguess . s . c > val [ 0 ] . c ) refguess . s . c = val [ 0 ] . c ;
if ( refguess . e . r < row . r ) refguess . e . r = row . r ;
if ( refguess . e . c < val [ 0 ] . c ) refguess . e . c = val [ 0 ] . c ;
break ;
2014-02-17 08:44:22 +00:00
2014-03-29 22:53:15 +00:00
case 'BrtCellBlank' : if ( ! opts . sheetStubs ) break ;
p = { t : 'str' , v : undefined } ;
s [ encode _cell ( { c : val [ 0 ] . c , r : row . r } ) ] = p ;
if ( refguess . s . r > row . r ) refguess . s . r = row . r ;
if ( refguess . s . c > val [ 0 ] . c ) refguess . s . c = val [ 0 ] . c ;
if ( refguess . e . r < row . r ) refguess . e . r = row . r ;
if ( refguess . e . c < val [ 0 ] . c ) refguess . e . c = val [ 0 ] . c ;
break ;
2014-02-17 08:44:22 +00:00
2014-03-23 21:30:00 +00:00
/* Merge Cells */
case 'BrtBeginMergeCells' : break ;
case 'BrtEndMergeCells' : break ;
case 'BrtMergeCell' : mergecells . push ( val ) ; break ;
2014-04-15 09:04:03 +00:00
case 'BrtHLink' :
var rel = rels [ '!id' ] [ val . relId ] ;
if ( rel ) {
val . Target = rel . Target ;
if ( val . loc ) val . Target += "#" + val . loc ;
val . Rel = rel ;
}
for ( R = val . rfx . s . r ; R <= val . rfx . e . r ; ++ R ) for ( C = val . rfx . s . c ; C <= val . rfx . e . c ; ++ C ) {
addr = encode _cell ( { c : C , r : R } ) ;
if ( ! s [ addr ] ) s [ addr ] = { t : "str" , v : undefined } ;
s [ addr ] . l = val ;
}
break ;
2014-02-17 08:44:22 +00:00
case 'BrtArrFmla' : break ; // TODO
case 'BrtShrFmla' : break ; // TODO
case 'BrtBeginSheet' : break ;
case 'BrtWsProp' : break ; // TODO
case 'BrtSheetCalcProp' : break ; // TODO
case 'BrtBeginWsViews' : break ; // TODO
case 'BrtBeginWsView' : break ; // TODO
2014-03-19 17:53:20 +00:00
case 'BrtPane' : break ; // TODO
case 'BrtSel' : break ; // TODO
2014-02-17 08:44:22 +00:00
case 'BrtEndWsView' : break ; // TODO
case 'BrtEndWsViews' : break ; // TODO
case 'BrtACBegin' : break ; // TODO
2014-03-19 17:53:20 +00:00
case 'BrtRwDescent' : break ; // TODO
2014-02-17 08:44:22 +00:00
case 'BrtACEnd' : break ; // TODO
case 'BrtWsFmtInfoEx14' : break ; // TODO
case 'BrtWsFmtInfo' : break ; // TODO
case 'BrtBeginColInfos' : break ; // TODO
case 'BrtColInfo' : break ; // TODO
case 'BrtEndColInfos' : break ; // TODO
case 'BrtBeginSheetData' : break ; // TODO
case 'BrtEndSheetData' : break ; // TODO
case 'BrtSheetProtection' : break ; // TODO
case 'BrtPrintOptions' : break ; // TODO
case 'BrtMargins' : break ; // TODO
case 'BrtPageSetup' : break ; // TODO
case 'BrtFRTBegin' : pass = true ; break ;
case 'BrtFRTEnd' : pass = false ; break ;
case 'BrtEndSheet' : break ; // TODO
2014-03-19 17:53:20 +00:00
case 'BrtDrawing' : break ; // TODO
2014-02-17 08:44:22 +00:00
case 'BrtLegacyDrawing' : break ; // TODO
2014-03-29 02:05:50 +00:00
case 'BrtLegacyDrawingHF' : break ; // TODO
2014-03-19 17:53:20 +00:00
case 'BrtPhoneticInfo' : break ; // TODO
case 'BrtBeginHeaderFooter' : break ; // TODO
case 'BrtEndHeaderFooter' : break ; // TODO
case 'BrtBrk' : break ; // TODO
case 'BrtBeginRwBrk' : break ; // TODO
case 'BrtEndRwBrk' : break ; // TODO
case 'BrtBeginColBrk' : break ; // TODO
case 'BrtEndColBrk' : break ; // TODO
case 'BrtBeginUserShViews' : break ; // TODO
case 'BrtBeginUserShView' : break ; // TODO
case 'BrtEndUserShView' : break ; // TODO
case 'BrtEndUserShViews' : break ; // TODO
case 'BrtBkHim' : break ; // TODO
case 'BrtBeginOleObjects' : break ; // TODO
case 'BrtOleObject' : break ; // TODO
case 'BrtEndOleObjects' : break ; // TODO
case 'BrtBeginListParts' : break ; // TODO
case 'BrtListPart' : break ; // TODO
case 'BrtEndListParts' : break ; // TODO
case 'BrtBeginSortState' : break ; // TODO
case 'BrtBeginSortCond' : break ; // TODO
case 'BrtEndSortCond' : break ; // TODO
case 'BrtEndSortState' : break ; // TODO
case 'BrtBeginConditionalFormatting' : break ; // TODO
case 'BrtEndConditionalFormatting' : break ; // TODO
case 'BrtBeginCFRule' : break ; // TODO
case 'BrtEndCFRule' : break ; // TODO
case 'BrtBeginDVals' : break ; // TODO
case 'BrtDVal' : break ; // TODO
case 'BrtEndDVals' : break ; // TODO
case 'BrtRangeProtection' : break ; // TODO
2014-03-29 02:05:50 +00:00
case 'BrtBeginDCon' : break ; // TODO
case 'BrtEndDCon' : break ; // TODO
case 'BrtBeginDRefs' : break ;
case 'BrtDRef' : break ;
case 'BrtEndDRefs' : break ;
2014-03-21 02:44:27 +00:00
/* ActiveX */
case 'BrtBeginActiveXControls' : break ;
case 'BrtActiveX' : break ;
case 'BrtEndActiveXControls' : break ;
/* AutoFilter */
case 'BrtBeginAFilter' : break ;
case 'BrtEndAFilter' : break ;
case 'BrtBeginFilterColumn' : break ;
case 'BrtBeginFilters' : break ;
2014-04-15 09:04:03 +00:00
case 'BrtFilter' : break ;
2014-03-21 02:44:27 +00:00
case 'BrtEndFilters' : break ;
case 'BrtEndFilterColumn' : break ;
case 'BrtDynamicFilter' : break ;
case 'BrtTop10Filter' : break ;
case 'BrtBeginCustomFilters' : break ;
case 'BrtCustomFilter' : break ;
case 'BrtEndCustomFilters' : break ;
2014-03-29 02:05:50 +00:00
/* Cell Watch */
case 'BrtBeginCellWatches' : break ;
case 'BrtCellWatch' : break ;
case 'BrtEndCellWatches' : break ;
/* Table */
case 'BrtTable' : break ;
/* Ignore Cell Errors */
case 'BrtBeginCellIgnoreECs' : break ;
case 'BrtCellIgnoreEC' : break ;
case 'BrtEndCellIgnoreECs' : break ;
2014-03-23 21:30:00 +00:00
default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + R . n ) ;
2014-02-17 08:44:22 +00:00
}
} , opts ) ;
2014-05-16 00:33:34 +00:00
if ( ! s [ "!ref" ] && ( refguess . s . r < 1000000 || ref . e . r > 0 || ref . e . c > 0 || ref . s . r > 0 || ref . s . c > 0 ) ) s [ "!ref" ] = encode _range ( ref ) ;
2014-03-29 22:53:15 +00:00
if ( opts . sheetRows && s [ "!ref" ] ) {
2014-02-19 03:11:39 +00:00
var tmpref = decode _range ( s [ "!ref" ] ) ;
if ( opts . sheetRows < + tmpref . e . r ) {
tmpref . e . r = opts . sheetRows - 1 ;
if ( tmpref . e . r > refguess . e . r ) tmpref . e . r = refguess . e . r ;
if ( tmpref . e . r < tmpref . s . r ) tmpref . s . r = tmpref . e . r ;
if ( tmpref . e . c > refguess . e . c ) tmpref . e . c = refguess . e . c ;
if ( tmpref . e . c < tmpref . s . c ) tmpref . s . c = tmpref . e . c ;
s [ "!fullref" ] = s [ "!ref" ] ;
s [ "!ref" ] = encode _range ( tmpref ) ;
}
}
2014-03-23 21:30:00 +00:00
if ( mergecells . length > 0 ) s [ "!merges" ] = mergecells ;
2014-02-17 08:44:22 +00:00
return s ;
} ;
2014-05-29 22:30:03 +00:00
function write _CELLTABLE ( ba , ws , idx , opts , wb ) {
var r = decode _range ( ws [ '!ref' ] || "A1" ) ;
write _record ( ba , 'BrtBeginSheetData' ) ;
for ( var i = r . s . r ; i <= r . e . r ; ++ i ) {
/* [ACCELLTABLE] */
/* BrtRowHdr */
/* *16384CELL */
}
write _record ( ba , 'BrtEndSheetData' ) ;
}
var write _ws _bin = function ( idx , opts , wb ) {
var ba = buf _array ( ) ;
var s = wb . SheetNames [ idx ] , ws = wb . Sheets [ s ] || { } ;
var r = decode _range ( ws [ '!ref' ] || "A1" ) ;
write _record ( ba , "BrtBeginSheet" ) ;
/* [BrtWsProp] */
write _record ( ba , "BrtWsDim" , write _BrtWsDim ( r ) ) ;
/* [WSVIEWS2] */
/* [WSFMTINFO] */
/* *COLINFOS */
write _CELLTABLE ( ba , ws , idx , opts , wb ) ;
/* [BrtSheetCalcProp] */
/* [[BrtSheetProtectionIso] BrtSheetProtection] */
/* *([BrtRangeProtectionIso] BrtRangeProtection) */
/* [SCENMAN] */
/* [AUTOFILTER] */
/* [SORTSTATE] */
/* [DCON] */
/* [USERSHVIEWS] */
/* [MERGECELLS] */
/* [BrtPhoneticInfo] */
/* *CONDITIONALFORMATTING */
/* [DVALS] */
/* *BrtHLink */
/* [BrtPrintOptions] */
/* [BrtMargins] */
/* [BrtPageSetup] */
/* [HEADERFOOTER] */
/* [RWBRK] */
/* [COLBRK] */
/* *BrtBigName */
/* [CELLWATCHES] */
/* [IGNOREECS] */
/* [SMARTTAGS] */
/* [BrtDrawing] */
/* [BrtLegacyDrawing] */
/* [BrtLegacyDrawingHF] */
/* [BrtBkHim] */
/* [OLEOBJECTS] */
/* [ACTIVEXCONTROLS] */
/* [WEBPUBITEMS] */
/* [LISTPARTS] */
/* FRTWORKSHEET */
write _record ( ba , "BrtEndSheet" ) ;
return ba . end ( ) ;
} ;
2014-02-17 08:44:22 +00:00
/* 18.2.28 (CT_WorkbookProtection) Defaults */
var WBPropsDef = {
allowRefreshQuery : '0' ,
autoCompressPictures : '1' ,
backupFile : '0' ,
checkCompatibility : '0' ,
codeName : '' ,
date1904 : '0' ,
dateCompatibility : '1' ,
//defaultThemeVersion: '0',
filterPrivacy : '0' ,
hidePivotFieldList : '0' ,
promptedSolutions : '0' ,
publishItems : '0' ,
refreshAllConnections : false ,
saveExternalLinkValues : '1' ,
showBorderUnselectedTables : '1' ,
showInkAnnotation : '1' ,
showObjects : 'all' ,
showPivotChartFilter : '0'
//updateLinks: 'userSet'
} ;
/* 18.2.30 (CT_BookView) Defaults */
var WBViewDef = {
activeTab : '0' ,
autoFilterDateGrouping : '1' ,
firstSheet : '0' ,
minimized : '0' ,
showHorizontalScroll : '1' ,
showSheetTabs : '1' ,
showVerticalScroll : '1' ,
tabRatio : '600' ,
visibility : 'visible'
//window{Height,Width}, {x,y}Window
} ;
/* 18.2.19 (CT_Sheet) Defaults */
var SheetDef = {
state : 'visible'
} ;
/* 18.2.2 (CT_CalcPr) Defaults */
var CalcPrDef = {
calcCompleted : 'true' ,
calcMode : 'auto' ,
calcOnSave : 'true' ,
concurrentCalc : 'true' ,
fullCalcOnLoad : 'false' ,
fullPrecision : 'true' ,
iterate : 'false' ,
iterateCount : '100' ,
iterateDelta : '0.001' ,
refMode : 'A1'
} ;
/* 18.2.3 (CT_CustomWorkbookView) Defaults */
var CustomWBViewDef = {
autoUpdate : 'false' ,
changesSavedWin : 'false' ,
includeHiddenRowCol : 'true' ,
includePrintSettings : 'true' ,
maximized : 'false' ,
minimized : 'false' ,
onlySync : 'false' ,
personalView : 'false' ,
showComments : 'commIndicator' ,
showFormulaBar : 'true' ,
showHorizontalScroll : 'true' ,
showObjects : 'all' ,
showSheetTabs : 'true' ,
showStatusbar : 'true' ,
showVerticalScroll : 'true' ,
tabRatio : '600' ,
xWindow : '0' ,
yWindow : '0'
} ;
/* 18.2 Workbook */
function parse _wb _xml ( data ) {
var wb = { AppVersion : { } , WBProps : { } , WBView : [ ] , Sheets : [ ] , CalcPr : { } , xmlns : "" } ;
2014-04-03 22:51:54 +00:00
var pass = false , xmlns = "xmlns" ;
2014-02-17 08:44:22 +00:00
data . match ( /<[^>]*>/g ) . forEach ( function ( x ) {
var y = parsexmltag ( x ) ;
2014-04-03 22:51:54 +00:00
switch ( y [ 0 ] . replace ( /<\w+:/ , "<" ) ) {
2014-02-17 08:44:22 +00:00
case '<?xml' : break ;
/* 18.2.27 workbook CT_Workbook 1 */
2014-04-03 22:51:54 +00:00
case '<workbook' :
if ( x . match ( /<\w+:workbook/ ) ) xmlns = "xmlns" + x . match ( /<(\w+):/ ) [ 1 ] ;
wb . xmlns = y [ xmlns ] ;
break ;
2014-02-17 08:44:22 +00:00
case '</workbook>' : break ;
/* 18.2.13 fileVersion CT_FileVersion ? */
case '<fileVersion' : delete y [ 0 ] ; wb . AppVersion = y ; break ;
case '<fileVersion/>' : break ;
/* 18.2.12 fileSharing CT_FileSharing ? */
case '<fileSharing' : case '<fileSharing/>' : break ;
/* 18.2.28 workbookPr CT_WorkbookPr ? */
case '<workbookPr' : delete y [ 0 ] ; wb . WBProps = y ; break ;
case '<workbookPr/>' : delete y [ 0 ] ; wb . WBProps = y ; break ;
/* 18.2.29 workbookProtection CT_WorkbookProtection ? */
case '<workbookProtection/>' : break ;
/* 18.2.1 bookViews CT_BookViews ? */
case '<bookViews>' : case '</bookViews>' : break ;
/* 18.2.30 workbookView CT_BookView + */
case '<workbookView' : delete y [ 0 ] ; wb . WBView . push ( y ) ; break ;
/* 18.2.20 sheets CT_Sheets 1 */
case '<sheets>' : case '</sheets>' : break ; // aggregate sheet
/* 18.2.19 sheet CT_Sheet + */
case '<sheet' : delete y [ 0 ] ; y . name = utf8read ( y . name ) ; wb . Sheets . push ( y ) ; break ;
/* 18.2.15 functionGroups CT_FunctionGroups ? */
case '<functionGroups' : case '<functionGroups/>' : break ;
/* 18.2.14 functionGroup CT_FunctionGroup + */
case '<functionGroup' : break ;
/* 18.2.9 externalReferences CT_ExternalReferences ? */
case '<externalReferences' : case '</externalReferences>' : break ;
/* 18.2.8 externalReference CT_ExternalReference + */
case '<externalReference' : break ;
/* 18.2.6 definedNames CT_DefinedNames ? */
case '<definedNames/>' : break ;
case '<definedNames>' : pass = true ; break ;
case '</definedNames>' : pass = false ; break ;
/* 18.2.5 definedName CT_DefinedName + */
case '<definedName' : case '<definedName/>' : case '</definedName>' : break ;
/* 18.2.2 calcPr CT_CalcPr ? */
case '<calcPr' : delete y [ 0 ] ; wb . CalcPr = y ; break ;
case '<calcPr/>' : delete y [ 0 ] ; wb . CalcPr = y ; break ;
/* 18.2.16 oleSize CT_OleSize ? (ref required) */
case '<oleSize' : break ;
/* 18.2.4 customWorkbookViews CT_CustomWorkbookViews ? */
case '<customWorkbookViews>' : case '</customWorkbookViews>' : case '<customWorkbookViews' : break ;
/* 18.2.3 customWorkbookView CT_CustomWorkbookView + */
case '<customWorkbookView' : case '</customWorkbookView>' : break ;
/* 18.2.18 pivotCaches CT_PivotCaches ? */
case '<pivotCaches>' : case '</pivotCaches>' : case '<pivotCaches' : break ;
/* 18.2.17 pivotCache CT_PivotCache ? */
case '<pivotCache' : break ;
/* 18.2.21 smartTagPr CT_SmartTagPr ? */
case '<smartTagPr' : case '<smartTagPr/>' : break ;
/* 18.2.23 smartTagTypes CT_SmartTagTypes ? */
case '<smartTagTypes' : case '<smartTagTypes>' : case '</smartTagTypes>' : break ;
/* 18.2.22 smartTagType CT_SmartTagType ? */
case '<smartTagType' : break ;
/* 18.2.24 webPublishing CT_WebPublishing ? */
case '<webPublishing' : case '<webPublishing/>' : break ;
/* 18.2.11 fileRecoveryPr CT_FileRecoveryPr ? */
case '<fileRecoveryPr' : case '<fileRecoveryPr/>' : break ;
/* 18.2.26 webPublishObjects CT_WebPublishObjects ? */
case '<webPublishObjects>' : case '<webPublishObjects' : case '</webPublishObjects>' : break ;
/* 18.2.25 webPublishObject CT_WebPublishObject ? */
case '<webPublishObject' : break ;
/* 18.2.10 extLst CT_ExtensionList ? */
case '<extLst>' : case '</extLst>' : case '<extLst/>' : break ;
/* 18.2.7 ext CT_Extension + */
case '<ext' : pass = true ; break ; //TODO: check with versions of excel
case '</ext>' : pass = false ; break ;
/* Others */
case '<mx:ArchID' : break ;
case '<mc:AlternateContent' : pass = true ; break ;
case '</mc:AlternateContent>' : pass = false ; break ;
}
} ) ;
2014-05-16 00:33:34 +00:00
if ( XMLNS . main . indexOf ( wb . xmlns ) === - 1 ) throw new Error ( "Unknown Namespace: " + wb . xmlns ) ;
2014-02-17 08:44:22 +00:00
var z ;
/* defaults */
for ( z in WBPropsDef ) if ( typeof wb . WBProps [ z ] === 'undefined' ) wb . WBProps [ z ] = WBPropsDef [ z ] ;
for ( z in CalcPrDef ) if ( typeof wb . CalcPr [ z ] === 'undefined' ) wb . CalcPr [ z ] = CalcPrDef [ z ] ;
wb . WBView . forEach ( function ( w ) { for ( var z in WBViewDef ) if ( typeof w [ z ] === 'undefined' ) w [ z ] = WBViewDef [ z ] ; } ) ;
wb . Sheets . forEach ( function ( w ) { for ( var z in SheetDef ) if ( typeof w [ z ] === 'undefined' ) w [ z ] = SheetDef [ z ] ; } ) ;
_ssfopts . date1904 = parsexmlbool ( wb . WBProps . date1904 , 'date1904' ) ;
return wb ;
}
2014-05-16 00:33:34 +00:00
var WB _XML _ROOT = writextag ( 'workbook' , null , {
'xmlns' : XMLNS . main [ 0 ] ,
//'xmlns:mx': XMLNS.mx,
//'xmlns:s': XMLNS.main[0],
'xmlns:r' : XMLNS . r
} ) ;
var write _wb _xml = function ( wb , opts ) {
var o = [ ] ;
o . push ( XML _HEADER ) ;
o . push ( WB _XML _ROOT ) ;
/* TODO: put this somewhere else */
var date1904 = "false" ;
try { date1904 = parsexmlbool ( wb . Workbook . WBProps . date1904 ) ? "true" : "false" ; } catch ( e ) { date1904 = "false" ; }
o . push ( writextag ( 'workbookPr' , null , { date1904 : date1904 } ) ) ;
o . push ( "<sheets>" ) ;
var i = 1 ;
wb . SheetNames . forEach ( function ( s ) {
2014-05-31 15:44:56 +00:00
o . push ( writextag ( 'sheet' , null , { name : s . substr ( 0 , 31 ) , sheetId : String ( i ) , "r:id" : "rId" + i } ) ) ;
2014-05-16 00:33:34 +00:00
++ i ;
} ) ;
o . push ( "</sheets>" ) ;
if ( o . length > 2 ) { o . push ( '</workbook>' ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) ; }
return o . join ( "" ) ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.4.301 BrtBundleSh */
var parse _BrtBundleSh = function ( data , length ) {
var z = { } ;
z . hsState = data . read _shift ( 4 ) ; //ST_SheetState
z . iTabID = data . read _shift ( 4 ) ;
z . strRelID = parse _RelID ( data , length - 8 ) ;
z . name = parse _XLWideString ( data ) ;
return z ;
} ;
2014-05-29 22:30:03 +00:00
var write _BrtBundleSh = function ( data , o ) {
if ( ! o ) o = new _buf ( 127 ) ;
o . write _shift ( 4 , data . hsState ) ;
o . write _shift ( 4 , data . iTabID ) ;
write _RelID ( data . strRelID , o ) ;
2014-05-31 15:44:56 +00:00
write _XLWideString ( data . name . substr ( 0 , 31 ) , o ) ;
2014-05-29 22:30:03 +00:00
return o ;
} ;
/* [MS-XLSB] 2.4.807 BrtWbProp */
var parse _BrtWbProp = function ( data , length ) {
data . read _shift ( 4 ) ;
var dwThemeVersion = data . read _shift ( 4 ) ;
var strName = ( length > 8 ) ? parse _XLWideString ( data ) : "" ;
return [ dwThemeVersion , strName ] ;
} ;
var write _BrtWbProp = function ( data , o ) {
if ( ! o ) o = new _buf ( 8 ) ;
o . write _shift ( 4 , 0 ) ;
o . write _shift ( 4 , 0 ) ;
return o ;
} ;
var parse _BrtFRTArchID$ = function ( data , length ) {
var o = { } ;
data . read _shift ( 4 ) ;
o . ArchID = data . read _shift ( 4 ) ;
data . l += length - 8 ;
return o ;
} ;
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.1.7.60 Workbook */
2014-03-23 21:30:00 +00:00
var parse _wb _bin = function ( data , opts ) {
2014-02-17 08:44:22 +00:00
var wb = { AppVersion : { } , WBProps : { } , WBView : [ ] , Sheets : [ ] , CalcPr : { } , xmlns : "" } ;
var pass = false , z ;
recordhopper ( data , function ( val , R ) {
switch ( R . n ) {
case 'BrtBundleSh' : wb . Sheets . push ( val ) ; break ;
case 'BrtBeginBook' : break ;
case 'BrtFileVersion' : break ;
case 'BrtWbProp' : break ;
case 'BrtACBegin' : break ;
case 'BrtAbsPath15' : break ;
case 'BrtACEnd' : break ;
/*case 'BrtBookProtectionIso': break;*/
case 'BrtBookProtection' : break ;
case 'BrtBeginBookViews' : break ;
case 'BrtBookView' : break ;
case 'BrtEndBookViews' : break ;
case 'BrtBeginBundleShs' : break ;
case 'BrtEndBundleShs' : break ;
case 'BrtBeginFnGroup' : break ;
case 'BrtEndFnGroup' : break ;
case 'BrtBeginExternals' : break ;
case 'BrtSupSelf' : break ;
case 'BrtSupBookSrc' : break ;
case 'BrtExternSheet' : break ;
case 'BrtEndExternals' : break ;
case 'BrtName' : break ;
case 'BrtCalcProp' : break ;
case 'BrtUserBookView' : break ;
case 'BrtBeginPivotCacheIDs' : break ;
case 'BrtBeginPivotCacheID' : break ;
case 'BrtEndPivotCacheID' : break ;
case 'BrtEndPivotCacheIDs' : break ;
case 'BrtWebOpt' : break ;
case 'BrtFileRecover' : break ;
2014-03-29 02:05:50 +00:00
case 'BrtFileSharing' : break ;
2014-02-17 08:44:22 +00:00
/ * c a s e ' B r t B e g i n W e b P u b I t e m s ' : b r e a k ;
case 'BrtBeginWebPubItem' : break ;
case 'BrtEndWebPubItem' : break ;
case 'BrtEndWebPubItems' : break ; * /
case 'BrtFRTBegin' : pass = true ; break ;
2014-05-29 22:30:03 +00:00
case 'BrtFRTArchID$' : break ;
2014-02-17 08:44:22 +00:00
case 'BrtFRTEnd' : pass = false ; break ;
case 'BrtEndBook' : break ;
2014-03-19 17:53:20 +00:00
default : if ( ! pass ) throw new Error ( "Unexpected record " + R . n ) ;
2014-02-17 08:44:22 +00:00
}
} ) ;
/* defaults */
for ( z in WBPropsDef ) if ( typeof wb . WBProps [ z ] === 'undefined' ) wb . WBProps [ z ] = WBPropsDef [ z ] ;
for ( z in CalcPrDef ) if ( typeof wb . CalcPr [ z ] === 'undefined' ) wb . CalcPr [ z ] = CalcPrDef [ z ] ;
wb . WBView . forEach ( function ( w ) { for ( var z in WBViewDef ) if ( typeof w [ z ] === 'undefined' ) w [ z ] = WBViewDef [ z ] ; } ) ;
wb . Sheets . forEach ( function ( w ) { for ( var z in SheetDef ) if ( typeof w [ z ] === 'undefined' ) w [ z ] = SheetDef [ z ] ; } ) ;
_ssfopts . date1904 = parsexmlbool ( wb . WBProps . date1904 , 'date1904' ) ;
return wb ;
} ;
2014-05-16 00:33:34 +00:00
2014-05-29 22:30:03 +00:00
/* [MS-XLSB] 2.1.7.60 Workbook */
function write _BUNDLESHS ( ba , wb , opts ) {
write _record ( ba , "BrtBeginBundleShs" ) ;
wb . SheetNames . forEach ( function ( s , idx ) {
var d = { hsState : 0 , iTabID : idx + 1 , strRelID : 'rId' + ( idx + 1 ) , name : s } ;
write _record ( ba , "BrtBundleSh" , write _BrtBundleSh ( d ) ) ;
} ) ;
write _record ( ba , "BrtEndBundleShs" ) ;
}
2014-05-16 00:33:34 +00:00
2014-05-29 22:30:03 +00:00
/* [MS-XLSB] 2.4.643 BrtFileVersion */
function write _BrtFileVersion ( data , o ) {
if ( ! o ) o = new _buf ( 127 ) ;
for ( var i = 0 ; i != 4 ; ++ i ) o . write _shift ( 4 , 0 ) ;
write _XLWideString ( "SheetJS" , o ) ;
write _XLWideString ( XLSX . version , o ) ;
write _XLWideString ( XLSX . version , o ) ;
write _XLWideString ( "7262" , o ) ;
o . length = o . l ;
return o ;
}
/* [MS-XLSB] 2.1.7.60 Workbook */
function write _BOOKVIEWS ( ba , wb , opts ) {
write _record ( ba , "BrtBeginBookViews" ) ;
/* 1*(BrtBookView *FRT) */
write _record ( ba , "BrtEndBookViews" ) ;
}
/* [MS-XLSB] 2.4.302 BrtCalcProp */
function write _BrtCalcProp ( data , o ) {
if ( ! o ) o = new _buf ( 26 ) ;
o . write _shift ( 4 , 0 ) ; /* force recalc */
o . write _shift ( 4 , 1 ) ;
o . write _shift ( 4 , 0 ) ;
write _Xnum ( 0 , o ) ;
o . write _shift ( - 4 , 1023 ) ;
o . write _shift ( 1 , 0x33 ) ;
o . write _shift ( 1 , 0x00 ) ;
return o ;
}
function write _BrtFileRecover ( data , o ) {
if ( ! o ) o = new _buf ( 1 ) ;
o . write _shift ( 1 , 0 ) ;
return o ;
}
/* [MS-XLSB] 2.1.7.60 Workbook */
var write _wb _bin = function ( wb , opts ) {
var ba = buf _array ( ) ;
write _record ( ba , "BrtBeginBook" ) ;
write _record ( ba , "BrtFileVersion" , write _BrtFileVersion ( ) ) ;
/* [[BrtFileSharingIso] BrtFileSharing] */
write _record ( ba , "BrtWbProp" , write _BrtWbProp ( ) ) ;
/* [ACABSPATH] */
/* [[BrtBookProtectionIso] BrtBookProtection] */
write _BOOKVIEWS ( ba , wb , opts ) ;
write _BUNDLESHS ( ba , wb , opts ) ;
/* [FNGROUP] */
/* [EXTERNALS] */
/* *BrtName */
write _record ( ba , "BrtCalcProp" , write _BrtCalcProp ( ) ) ;
/* [BrtOleSize] */
/* *(BrtUserBookView *FRT) */
/* [PIVOTCACHEIDS] */
/* [BrtWbFactoid] */
/* [SMARTTAGTYPES] */
/* [BrtWebOpt] */
write _record ( ba , "BrtFileRecover" , write _BrtFileRecover ( ) ) ;
/* [WEBPUBITEMS] */
/* [CRERRS] */
/* FRTWORKBOOK */
write _record ( ba , "BrtEndBook" ) ;
return ba . end ( ) ;
2014-05-16 00:33:34 +00:00
} ;
2014-02-17 08:44:22 +00:00
function parse _wb ( data , name , opts ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _wb _bin : parse _wb _xml ) ( data , opts ) ;
2014-02-17 08:44:22 +00:00
}
2014-04-15 09:04:03 +00:00
function parse _ws ( data , name , opts , rels ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _ws _bin : parse _ws _xml ) ( data , opts , rels ) ;
2014-02-17 08:44:22 +00:00
}
function parse _sty ( data , name , opts ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _sty _bin : parse _sty _xml ) ( data , opts ) ;
2014-02-17 08:44:22 +00:00
}
2014-05-29 22:30:03 +00:00
function parse _theme ( data , name , opts ) {
return parse _theme _xml ( data , opts ) ;
}
2014-02-17 08:44:22 +00:00
function parse _sst ( data , name , opts ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _sst _bin : parse _sst _xml ) ( data , opts ) ;
2014-02-17 08:44:22 +00:00
}
2014-03-29 02:05:50 +00:00
function parse _cmnt ( data , name , opts ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _comments _bin : parse _comments _xml ) ( data , opts ) ;
2014-03-29 02:05:50 +00:00
}
2014-03-29 22:53:15 +00:00
function parse _cc ( data , name , opts ) {
2014-05-16 00:33:34 +00:00
return ( name . substr ( - 4 ) === ".bin" ? parse _cc _bin : parse _cc _xml ) ( data , opts ) ;
2014-03-29 22:53:15 +00:00
}
2014-05-16 00:33:34 +00:00
function write _wb ( wb , name , opts ) {
return ( name . substr ( - 4 ) === ".bin" ? write _wb _bin : write _wb _xml ) ( wb , opts ) ;
}
function write _ws ( data , name , opts , wb ) {
return ( name . substr ( - 4 ) === ".bin" ? write _ws _bin : write _ws _xml ) ( data , opts , wb ) ;
}
function write _sty ( data , name , opts ) {
return ( name . substr ( - 4 ) === ".bin" ? write _sty _bin : write _sty _xml ) ( data , opts ) ;
}
function write _sst ( data , name , opts ) {
return ( name . substr ( - 4 ) === ".bin" ? write _sst _bin : write _sst _xml ) ( data , opts ) ;
}
/ *
function write _cmnt ( data , name , opts ) {
return ( name . substr ( - 4 ) === ".bin" ? write _comments _bin : write _comments _xml ) ( data , opts ) ;
}
function write _cc ( data , name , opts ) {
return ( name . substr ( - 4 ) === ".bin" ? write _cc _bin : write _cc _xml ) ( data , opts ) ;
}
* /
2014-02-17 08:44:22 +00:00
/* [MS-XLSB] 2.3 Record Enumeration */
var RecordEnum = {
0x0000 : { n : "BrtRowHdr" , f : parse _BrtRowHdr } ,
0x0001 : { n : "BrtCellBlank" , f : parse _BrtCellBlank } ,
0x0002 : { n : "BrtCellRk" , f : parse _BrtCellRk } ,
0x0003 : { n : "BrtCellError" , f : parse _BrtCellError } ,
0x0004 : { n : "BrtCellBool" , f : parse _BrtCellBool } ,
0x0005 : { n : "BrtCellReal" , f : parse _BrtCellReal } ,
0x0006 : { n : "BrtCellSt" , f : parse _BrtCellSt } ,
0x0007 : { n : "BrtCellIsst" , f : parse _BrtCellIsst } ,
0x0008 : { n : "BrtFmlaString" , f : parse _BrtFmlaString } ,
0x0009 : { n : "BrtFmlaNum" , f : parse _BrtFmlaNum } ,
0x000A : { n : "BrtFmlaBool" , f : parse _BrtFmlaBool } ,
0x000B : { n : "BrtFmlaError" , f : parse _BrtFmlaError } ,
2014-05-29 22:30:03 +00:00
0x0010 : { n : "BrtFRTArchID$" , f : parse _BrtFRTArchID$ } ,
2014-02-17 08:44:22 +00:00
0x0013 : { n : "BrtSSTItem" , f : parse _RichStr } ,
0x0014 : { n : "BrtPCDIMissing" , f : parsenoop } ,
0x0015 : { n : "BrtPCDINumber" , f : parsenoop } ,
0x0016 : { n : "BrtPCDIBoolean" , f : parsenoop } ,
0x0017 : { n : "BrtPCDIError" , f : parsenoop } ,
0x0018 : { n : "BrtPCDIString" , f : parsenoop } ,
0x0019 : { n : "BrtPCDIDatetime" , f : parsenoop } ,
0x001A : { n : "BrtPCDIIndex" , f : parsenoop } ,
0x001B : { n : "BrtPCDIAMissing" , f : parsenoop } ,
0x001C : { n : "BrtPCDIANumber" , f : parsenoop } ,
0x001D : { n : "BrtPCDIABoolean" , f : parsenoop } ,
0x001E : { n : "BrtPCDIAError" , f : parsenoop } ,
0x001F : { n : "BrtPCDIAString" , f : parsenoop } ,
0x0020 : { n : "BrtPCDIADatetime" , f : parsenoop } ,
0x0021 : { n : "BrtPCRRecord" , f : parsenoop } ,
0x0022 : { n : "BrtPCRRecordDt" , f : parsenoop } ,
0x0023 : { n : "BrtFRTBegin" , f : parsenoop } ,
0x0024 : { n : "BrtFRTEnd" , f : parsenoop } ,
0x0025 : { n : "BrtACBegin" , f : parsenoop } ,
0x0026 : { n : "BrtACEnd" , f : parsenoop } ,
0x0027 : { n : "BrtName" , f : parsenoop } ,
0x0028 : { n : "BrtIndexRowBlock" , f : parsenoop } ,
0x002A : { n : "BrtIndexBlock" , f : parsenoop } ,
2014-03-29 02:05:50 +00:00
0x002B : { n : "BrtFont" , f : parse _BrtFont } ,
2014-02-17 08:44:22 +00:00
0x002C : { n : "BrtFmt" , f : parse _BrtFmt } ,
0x002D : { n : "BrtFill" , f : parsenoop } ,
0x002E : { n : "BrtBorder" , f : parsenoop } ,
0x002F : { n : "BrtXF" , f : parse _BrtXF } ,
0x0030 : { n : "BrtStyle" , f : parsenoop } ,
0x0031 : { n : "BrtCellMeta" , f : parsenoop } ,
0x0032 : { n : "BrtValueMeta" , f : parsenoop } ,
0x0033 : { n : "BrtMdb" , f : parsenoop } ,
0x0034 : { n : "BrtBeginFmd" , f : parsenoop } ,
0x0035 : { n : "BrtEndFmd" , f : parsenoop } ,
0x0036 : { n : "BrtBeginMdx" , f : parsenoop } ,
0x0037 : { n : "BrtEndMdx" , f : parsenoop } ,
0x0038 : { n : "BrtBeginMdxTuple" , f : parsenoop } ,
0x0039 : { n : "BrtEndMdxTuple" , f : parsenoop } ,
0x003A : { n : "BrtMdxMbrIstr" , f : parsenoop } ,
0x003B : { n : "BrtStr" , f : parsenoop } ,
0x003C : { n : "BrtColInfo" , f : parsenoop } ,
0x003E : { n : "BrtCellRString" , f : parsenoop } ,
2014-03-29 22:53:15 +00:00
0x003F : { n : "BrtCalcChainItem$" , f : parse _BrtCalcChainItem$ } ,
2014-02-17 08:44:22 +00:00
0x0040 : { n : "BrtDVal" , f : parsenoop } ,
0x0041 : { n : "BrtSxvcellNum" , f : parsenoop } ,
0x0042 : { n : "BrtSxvcellStr" , f : parsenoop } ,
0x0043 : { n : "BrtSxvcellBool" , f : parsenoop } ,
0x0044 : { n : "BrtSxvcellErr" , f : parsenoop } ,
0x0045 : { n : "BrtSxvcellDate" , f : parsenoop } ,
0x0046 : { n : "BrtSxvcellNil" , f : parsenoop } ,
0x0080 : { n : "BrtFileVersion" , f : parsenoop } ,
0x0081 : { n : "BrtBeginSheet" , f : parsenoop } ,
0x0082 : { n : "BrtEndSheet" , f : parsenoop } ,
2014-05-29 22:30:03 +00:00
0x0083 : { n : "BrtBeginBook" , f : parsenoop , p : 0 } ,
2014-02-17 08:44:22 +00:00
0x0084 : { n : "BrtEndBook" , f : parsenoop } ,
0x0085 : { n : "BrtBeginWsViews" , f : parsenoop } ,
0x0086 : { n : "BrtEndWsViews" , f : parsenoop } ,
0x0087 : { n : "BrtBeginBookViews" , f : parsenoop } ,
0x0088 : { n : "BrtEndBookViews" , f : parsenoop } ,
0x0089 : { n : "BrtBeginWsView" , f : parsenoop } ,
0x008A : { n : "BrtEndWsView" , f : parsenoop } ,
0x008B : { n : "BrtBeginCsViews" , f : parsenoop } ,
0x008C : { n : "BrtEndCsViews" , f : parsenoop } ,
0x008D : { n : "BrtBeginCsView" , f : parsenoop } ,
0x008E : { n : "BrtEndCsView" , f : parsenoop } ,
0x008F : { n : "BrtBeginBundleShs" , f : parsenoop } ,
0x0090 : { n : "BrtEndBundleShs" , f : parsenoop } ,
0x0091 : { n : "BrtBeginSheetData" , f : parsenoop } ,
0x0092 : { n : "BrtEndSheetData" , f : parsenoop } ,
0x0093 : { n : "BrtWsProp" , f : parse _BrtWsProp } ,
2014-05-29 22:30:03 +00:00
0x0094 : { n : "BrtWsDim" , f : parse _BrtWsDim , p : 16 } ,
2014-02-17 08:44:22 +00:00
0x0097 : { n : "BrtPane" , f : parsenoop } ,
0x0098 : { n : "BrtSel" , f : parsenoop } ,
2014-05-29 22:30:03 +00:00
0x0099 : { n : "BrtWbProp" , f : parse _BrtWbProp } ,
2014-02-17 08:44:22 +00:00
0x009A : { n : "BrtWbFactoid" , f : parsenoop } ,
0x009B : { n : "BrtFileRecover" , f : parsenoop } ,
0x009C : { n : "BrtBundleSh" , f : parse _BrtBundleSh } ,
0x009D : { n : "BrtCalcProp" , f : parsenoop } ,
0x009E : { n : "BrtBookView" , f : parsenoop } ,
0x009F : { n : "BrtBeginSst" , f : parse _BrtBeginSst } ,
0x00A0 : { n : "BrtEndSst" , f : parsenoop } ,
0x00A1 : { n : "BrtBeginAFilter" , f : parsenoop } ,
0x00A2 : { n : "BrtEndAFilter" , f : parsenoop } ,
0x00A3 : { n : "BrtBeginFilterColumn" , f : parsenoop } ,
0x00A4 : { n : "BrtEndFilterColumn" , f : parsenoop } ,
0x00A5 : { n : "BrtBeginFilters" , f : parsenoop } ,
0x00A6 : { n : "BrtEndFilters" , f : parsenoop } ,
0x00A7 : { n : "BrtFilter" , f : parsenoop } ,
0x00A8 : { n : "BrtColorFilter" , f : parsenoop } ,
0x00A9 : { n : "BrtIconFilter" , f : parsenoop } ,
0x00AA : { n : "BrtTop10Filter" , f : parsenoop } ,
0x00AB : { n : "BrtDynamicFilter" , f : parsenoop } ,
0x00AC : { n : "BrtBeginCustomFilters" , f : parsenoop } ,
0x00AD : { n : "BrtEndCustomFilters" , f : parsenoop } ,
0x00AE : { n : "BrtCustomFilter" , f : parsenoop } ,
0x00AF : { n : "BrtAFilterDateGroupItem" , f : parsenoop } ,
2014-03-23 21:30:00 +00:00
0x00B0 : { n : "BrtMergeCell" , f : parse _BrtMergeCell } ,
2014-02-17 08:44:22 +00:00
0x00B1 : { n : "BrtBeginMergeCells" , f : parsenoop } ,
0x00B2 : { n : "BrtEndMergeCells" , f : parsenoop } ,
0x00B3 : { n : "BrtBeginPivotCacheDef" , f : parsenoop } ,
0x00B4 : { n : "BrtEndPivotCacheDef" , f : parsenoop } ,
0x00B5 : { n : "BrtBeginPCDFields" , f : parsenoop } ,
0x00B6 : { n : "BrtEndPCDFields" , f : parsenoop } ,
0x00B7 : { n : "BrtBeginPCDField" , f : parsenoop } ,
0x00B8 : { n : "BrtEndPCDField" , f : parsenoop } ,
0x00B9 : { n : "BrtBeginPCDSource" , f : parsenoop } ,
0x00BA : { n : "BrtEndPCDSource" , f : parsenoop } ,
0x00BB : { n : "BrtBeginPCDSRange" , f : parsenoop } ,
0x00BC : { n : "BrtEndPCDSRange" , f : parsenoop } ,
0x00BD : { n : "BrtBeginPCDFAtbl" , f : parsenoop } ,
0x00BE : { n : "BrtEndPCDFAtbl" , f : parsenoop } ,
0x00BF : { n : "BrtBeginPCDIRun" , f : parsenoop } ,
0x00C0 : { n : "BrtEndPCDIRun" , f : parsenoop } ,
0x00C1 : { n : "BrtBeginPivotCacheRecords" , f : parsenoop } ,
0x00C2 : { n : "BrtEndPivotCacheRecords" , f : parsenoop } ,
0x00C3 : { n : "BrtBeginPCDHierarchies" , f : parsenoop } ,
0x00C4 : { n : "BrtEndPCDHierarchies" , f : parsenoop } ,
0x00C5 : { n : "BrtBeginPCDHierarchy" , f : parsenoop } ,
0x00C6 : { n : "BrtEndPCDHierarchy" , f : parsenoop } ,
0x00C7 : { n : "BrtBeginPCDHFieldsUsage" , f : parsenoop } ,
0x00C8 : { n : "BrtEndPCDHFieldsUsage" , f : parsenoop } ,
0x00C9 : { n : "BrtBeginExtConnection" , f : parsenoop } ,
0x00CA : { n : "BrtEndExtConnection" , f : parsenoop } ,
0x00CB : { n : "BrtBeginECDbProps" , f : parsenoop } ,
0x00CC : { n : "BrtEndECDbProps" , f : parsenoop } ,
0x00CD : { n : "BrtBeginECOlapProps" , f : parsenoop } ,
0x00CE : { n : "BrtEndECOlapProps" , f : parsenoop } ,
0x00CF : { n : "BrtBeginPCDSConsol" , f : parsenoop } ,
0x00D0 : { n : "BrtEndPCDSConsol" , f : parsenoop } ,
0x00D1 : { n : "BrtBeginPCDSCPages" , f : parsenoop } ,
0x00D2 : { n : "BrtEndPCDSCPages" , f : parsenoop } ,
0x00D3 : { n : "BrtBeginPCDSCPage" , f : parsenoop } ,
0x00D4 : { n : "BrtEndPCDSCPage" , f : parsenoop } ,
0x00D5 : { n : "BrtBeginPCDSCPItem" , f : parsenoop } ,
0x00D6 : { n : "BrtEndPCDSCPItem" , f : parsenoop } ,
0x00D7 : { n : "BrtBeginPCDSCSets" , f : parsenoop } ,
0x00D8 : { n : "BrtEndPCDSCSets" , f : parsenoop } ,
0x00D9 : { n : "BrtBeginPCDSCSet" , f : parsenoop } ,
0x00DA : { n : "BrtEndPCDSCSet" , f : parsenoop } ,
0x00DB : { n : "BrtBeginPCDFGroup" , f : parsenoop } ,
0x00DC : { n : "BrtEndPCDFGroup" , f : parsenoop } ,
0x00DD : { n : "BrtBeginPCDFGItems" , f : parsenoop } ,
0x00DE : { n : "BrtEndPCDFGItems" , f : parsenoop } ,
0x00DF : { n : "BrtBeginPCDFGRange" , f : parsenoop } ,
0x00E0 : { n : "BrtEndPCDFGRange" , f : parsenoop } ,
0x00E1 : { n : "BrtBeginPCDFGDiscrete" , f : parsenoop } ,
0x00E2 : { n : "BrtEndPCDFGDiscrete" , f : parsenoop } ,
0x00E3 : { n : "BrtBeginPCDSDTupleCache" , f : parsenoop } ,
0x00E4 : { n : "BrtEndPCDSDTupleCache" , f : parsenoop } ,
0x00E5 : { n : "BrtBeginPCDSDTCEntries" , f : parsenoop } ,
0x00E6 : { n : "BrtEndPCDSDTCEntries" , f : parsenoop } ,
0x00E7 : { n : "BrtBeginPCDSDTCEMembers" , f : parsenoop } ,
0x00E8 : { n : "BrtEndPCDSDTCEMembers" , f : parsenoop } ,
0x00E9 : { n : "BrtBeginPCDSDTCEMember" , f : parsenoop } ,
0x00EA : { n : "BrtEndPCDSDTCEMember" , f : parsenoop } ,
0x00EB : { n : "BrtBeginPCDSDTCQueries" , f : parsenoop } ,
0x00EC : { n : "BrtEndPCDSDTCQueries" , f : parsenoop } ,
0x00ED : { n : "BrtBeginPCDSDTCQuery" , f : parsenoop } ,
0x00EE : { n : "BrtEndPCDSDTCQuery" , f : parsenoop } ,
0x00EF : { n : "BrtBeginPCDSDTCSets" , f : parsenoop } ,
0x00F0 : { n : "BrtEndPCDSDTCSets" , f : parsenoop } ,
0x00F1 : { n : "BrtBeginPCDSDTCSet" , f : parsenoop } ,
0x00F2 : { n : "BrtEndPCDSDTCSet" , f : parsenoop } ,
0x00F3 : { n : "BrtBeginPCDCalcItems" , f : parsenoop } ,
0x00F4 : { n : "BrtEndPCDCalcItems" , f : parsenoop } ,
0x00F5 : { n : "BrtBeginPCDCalcItem" , f : parsenoop } ,
0x00F6 : { n : "BrtEndPCDCalcItem" , f : parsenoop } ,
0x00F7 : { n : "BrtBeginPRule" , f : parsenoop } ,
0x00F8 : { n : "BrtEndPRule" , f : parsenoop } ,
0x00F9 : { n : "BrtBeginPRFilters" , f : parsenoop } ,
0x00FA : { n : "BrtEndPRFilters" , f : parsenoop } ,
0x00FB : { n : "BrtBeginPRFilter" , f : parsenoop } ,
0x00FC : { n : "BrtEndPRFilter" , f : parsenoop } ,
0x00FD : { n : "BrtBeginPNames" , f : parsenoop } ,
0x00FE : { n : "BrtEndPNames" , f : parsenoop } ,
0x00FF : { n : "BrtBeginPName" , f : parsenoop } ,
0x0100 : { n : "BrtEndPName" , f : parsenoop } ,
0x0101 : { n : "BrtBeginPNPairs" , f : parsenoop } ,
0x0102 : { n : "BrtEndPNPairs" , f : parsenoop } ,
0x0103 : { n : "BrtBeginPNPair" , f : parsenoop } ,
0x0104 : { n : "BrtEndPNPair" , f : parsenoop } ,
0x0105 : { n : "BrtBeginECWebProps" , f : parsenoop } ,
0x0106 : { n : "BrtEndECWebProps" , f : parsenoop } ,
0x0107 : { n : "BrtBeginEcWpTables" , f : parsenoop } ,
0x0108 : { n : "BrtEndECWPTables" , f : parsenoop } ,
0x0109 : { n : "BrtBeginECParams" , f : parsenoop } ,
0x010A : { n : "BrtEndECParams" , f : parsenoop } ,
0x010B : { n : "BrtBeginECParam" , f : parsenoop } ,
0x010C : { n : "BrtEndECParam" , f : parsenoop } ,
0x010D : { n : "BrtBeginPCDKPIs" , f : parsenoop } ,
0x010E : { n : "BrtEndPCDKPIs" , f : parsenoop } ,
0x010F : { n : "BrtBeginPCDKPI" , f : parsenoop } ,
0x0110 : { n : "BrtEndPCDKPI" , f : parsenoop } ,
0x0111 : { n : "BrtBeginDims" , f : parsenoop } ,
0x0112 : { n : "BrtEndDims" , f : parsenoop } ,
0x0113 : { n : "BrtBeginDim" , f : parsenoop } ,
0x0114 : { n : "BrtEndDim" , f : parsenoop } ,
0x0115 : { n : "BrtIndexPartEnd" , f : parsenoop } ,
0x0116 : { n : "BrtBeginStyleSheet" , f : parsenoop } ,
0x0117 : { n : "BrtEndStyleSheet" , f : parsenoop } ,
0x0118 : { n : "BrtBeginSXView" , f : parsenoop } ,
0x0119 : { n : "BrtEndSXVI" , f : parsenoop } ,
0x011A : { n : "BrtBeginSXVI" , f : parsenoop } ,
0x011B : { n : "BrtBeginSXVIs" , f : parsenoop } ,
0x011C : { n : "BrtEndSXVIs" , f : parsenoop } ,
0x011D : { n : "BrtBeginSXVD" , f : parsenoop } ,
0x011E : { n : "BrtEndSXVD" , f : parsenoop } ,
0x011F : { n : "BrtBeginSXVDs" , f : parsenoop } ,
0x0120 : { n : "BrtEndSXVDs" , f : parsenoop } ,
0x0121 : { n : "BrtBeginSXPI" , f : parsenoop } ,
0x0122 : { n : "BrtEndSXPI" , f : parsenoop } ,
0x0123 : { n : "BrtBeginSXPIs" , f : parsenoop } ,
0x0124 : { n : "BrtEndSXPIs" , f : parsenoop } ,
0x0125 : { n : "BrtBeginSXDI" , f : parsenoop } ,
0x0126 : { n : "BrtEndSXDI" , f : parsenoop } ,
0x0127 : { n : "BrtBeginSXDIs" , f : parsenoop } ,
0x0128 : { n : "BrtEndSXDIs" , f : parsenoop } ,
0x0129 : { n : "BrtBeginSXLI" , f : parsenoop } ,
0x012A : { n : "BrtEndSXLI" , f : parsenoop } ,
0x012B : { n : "BrtBeginSXLIRws" , f : parsenoop } ,
0x012C : { n : "BrtEndSXLIRws" , f : parsenoop } ,
0x012D : { n : "BrtBeginSXLICols" , f : parsenoop } ,
0x012E : { n : "BrtEndSXLICols" , f : parsenoop } ,
0x012F : { n : "BrtBeginSXFormat" , f : parsenoop } ,
0x0130 : { n : "BrtEndSXFormat" , f : parsenoop } ,
0x0131 : { n : "BrtBeginSXFormats" , f : parsenoop } ,
0x0132 : { n : "BrtEndSxFormats" , f : parsenoop } ,
0x0133 : { n : "BrtBeginSxSelect" , f : parsenoop } ,
0x0134 : { n : "BrtEndSxSelect" , f : parsenoop } ,
0x0135 : { n : "BrtBeginISXVDRws" , f : parsenoop } ,
0x0136 : { n : "BrtEndISXVDRws" , f : parsenoop } ,
0x0137 : { n : "BrtBeginISXVDCols" , f : parsenoop } ,
0x0138 : { n : "BrtEndISXVDCols" , f : parsenoop } ,
0x0139 : { n : "BrtEndSXLocation" , f : parsenoop } ,
0x013A : { n : "BrtBeginSXLocation" , f : parsenoop } ,
0x013B : { n : "BrtEndSXView" , f : parsenoop } ,
0x013C : { n : "BrtBeginSXTHs" , f : parsenoop } ,
0x013D : { n : "BrtEndSXTHs" , f : parsenoop } ,
0x013E : { n : "BrtBeginSXTH" , f : parsenoop } ,
0x013F : { n : "BrtEndSXTH" , f : parsenoop } ,
0x0140 : { n : "BrtBeginISXTHRws" , f : parsenoop } ,
0x0141 : { n : "BrtEndISXTHRws" , f : parsenoop } ,
0x0142 : { n : "BrtBeginISXTHCols" , f : parsenoop } ,
0x0143 : { n : "BrtEndISXTHCols" , f : parsenoop } ,
0x0144 : { n : "BrtBeginSXTDMPS" , f : parsenoop } ,
0x0145 : { n : "BrtEndSXTDMPs" , f : parsenoop } ,
0x0146 : { n : "BrtBeginSXTDMP" , f : parsenoop } ,
0x0147 : { n : "BrtEndSXTDMP" , f : parsenoop } ,
0x0148 : { n : "BrtBeginSXTHItems" , f : parsenoop } ,
0x0149 : { n : "BrtEndSXTHItems" , f : parsenoop } ,
0x014A : { n : "BrtBeginSXTHItem" , f : parsenoop } ,
0x014B : { n : "BrtEndSXTHItem" , f : parsenoop } ,
0x014C : { n : "BrtBeginMetadata" , f : parsenoop } ,
0x014D : { n : "BrtEndMetadata" , f : parsenoop } ,
0x014E : { n : "BrtBeginEsmdtinfo" , f : parsenoop } ,
0x014F : { n : "BrtMdtinfo" , f : parsenoop } ,
0x0150 : { n : "BrtEndEsmdtinfo" , f : parsenoop } ,
0x0151 : { n : "BrtBeginEsmdb" , f : parsenoop } ,
0x0152 : { n : "BrtEndEsmdb" , f : parsenoop } ,
0x0153 : { n : "BrtBeginEsfmd" , f : parsenoop } ,
0x0154 : { n : "BrtEndEsfmd" , f : parsenoop } ,
0x0155 : { n : "BrtBeginSingleCells" , f : parsenoop } ,
0x0156 : { n : "BrtEndSingleCells" , f : parsenoop } ,
0x0157 : { n : "BrtBeginList" , f : parsenoop } ,
0x0158 : { n : "BrtEndList" , f : parsenoop } ,
0x0159 : { n : "BrtBeginListCols" , f : parsenoop } ,
0x015A : { n : "BrtEndListCols" , f : parsenoop } ,
0x015B : { n : "BrtBeginListCol" , f : parsenoop } ,
0x015C : { n : "BrtEndListCol" , f : parsenoop } ,
0x015D : { n : "BrtBeginListXmlCPr" , f : parsenoop } ,
0x015E : { n : "BrtEndListXmlCPr" , f : parsenoop } ,
0x015F : { n : "BrtListCCFmla" , f : parsenoop } ,
0x0160 : { n : "BrtListTrFmla" , f : parsenoop } ,
0x0161 : { n : "BrtBeginExternals" , f : parsenoop } ,
0x0162 : { n : "BrtEndExternals" , f : parsenoop } ,
0x0163 : { n : "BrtSupBookSrc" , f : parsenoop } ,
0x0165 : { n : "BrtSupSelf" , f : parsenoop } ,
0x0166 : { n : "BrtSupSame" , f : parsenoop } ,
0x0167 : { n : "BrtSupTabs" , f : parsenoop } ,
0x0168 : { n : "BrtBeginSupBook" , f : parsenoop } ,
0x0169 : { n : "BrtPlaceholderName" , f : parsenoop } ,
0x016A : { n : "BrtExternSheet" , f : parsenoop } ,
0x016B : { n : "BrtExternTableStart" , f : parsenoop } ,
0x016C : { n : "BrtExternTableEnd" , f : parsenoop } ,
0x016E : { n : "BrtExternRowHdr" , f : parsenoop } ,
0x016F : { n : "BrtExternCellBlank" , f : parsenoop } ,
0x0170 : { n : "BrtExternCellReal" , f : parsenoop } ,
0x0171 : { n : "BrtExternCellBool" , f : parsenoop } ,
0x0172 : { n : "BrtExternCellError" , f : parsenoop } ,
0x0173 : { n : "BrtExternCellString" , f : parsenoop } ,
0x0174 : { n : "BrtBeginEsmdx" , f : parsenoop } ,
0x0175 : { n : "BrtEndEsmdx" , f : parsenoop } ,
0x0176 : { n : "BrtBeginMdxSet" , f : parsenoop } ,
0x0177 : { n : "BrtEndMdxSet" , f : parsenoop } ,
0x0178 : { n : "BrtBeginMdxMbrProp" , f : parsenoop } ,
0x0179 : { n : "BrtEndMdxMbrProp" , f : parsenoop } ,
0x017A : { n : "BrtBeginMdxKPI" , f : parsenoop } ,
0x017B : { n : "BrtEndMdxKPI" , f : parsenoop } ,
0x017C : { n : "BrtBeginEsstr" , f : parsenoop } ,
0x017D : { n : "BrtEndEsstr" , f : parsenoop } ,
0x017E : { n : "BrtBeginPRFItem" , f : parsenoop } ,
0x017F : { n : "BrtEndPRFItem" , f : parsenoop } ,
0x0180 : { n : "BrtBeginPivotCacheIDs" , f : parsenoop } ,
0x0181 : { n : "BrtEndPivotCacheIDs" , f : parsenoop } ,
0x0182 : { n : "BrtBeginPivotCacheID" , f : parsenoop } ,
0x0183 : { n : "BrtEndPivotCacheID" , f : parsenoop } ,
0x0184 : { n : "BrtBeginISXVIs" , f : parsenoop } ,
0x0185 : { n : "BrtEndISXVIs" , f : parsenoop } ,
0x0186 : { n : "BrtBeginColInfos" , f : parsenoop } ,
0x0187 : { n : "BrtEndColInfos" , f : parsenoop } ,
0x0188 : { n : "BrtBeginRwBrk" , f : parsenoop } ,
0x0189 : { n : "BrtEndRwBrk" , f : parsenoop } ,
0x018A : { n : "BrtBeginColBrk" , f : parsenoop } ,
0x018B : { n : "BrtEndColBrk" , f : parsenoop } ,
0x018C : { n : "BrtBrk" , f : parsenoop } ,
0x018D : { n : "BrtUserBookView" , f : parsenoop } ,
0x018E : { n : "BrtInfo" , f : parsenoop } ,
0x018F : { n : "BrtCUsr" , f : parsenoop } ,
0x0190 : { n : "BrtUsr" , f : parsenoop } ,
0x0191 : { n : "BrtBeginUsers" , f : parsenoop } ,
0x0193 : { n : "BrtEOF" , f : parsenoop } ,
0x0194 : { n : "BrtUCR" , f : parsenoop } ,
0x0195 : { n : "BrtRRInsDel" , f : parsenoop } ,
0x0196 : { n : "BrtRREndInsDel" , f : parsenoop } ,
0x0197 : { n : "BrtRRMove" , f : parsenoop } ,
0x0198 : { n : "BrtRREndMove" , f : parsenoop } ,
0x0199 : { n : "BrtRRChgCell" , f : parsenoop } ,
0x019A : { n : "BrtRREndChgCell" , f : parsenoop } ,
0x019B : { n : "BrtRRHeader" , f : parsenoop } ,
0x019C : { n : "BrtRRUserView" , f : parsenoop } ,
0x019D : { n : "BrtRRRenSheet" , f : parsenoop } ,
0x019E : { n : "BrtRRInsertSh" , f : parsenoop } ,
0x019F : { n : "BrtRRDefName" , f : parsenoop } ,
0x01A0 : { n : "BrtRRNote" , f : parsenoop } ,
0x01A1 : { n : "BrtRRConflict" , f : parsenoop } ,
0x01A2 : { n : "BrtRRTQSIF" , f : parsenoop } ,
0x01A3 : { n : "BrtRRFormat" , f : parsenoop } ,
0x01A4 : { n : "BrtRREndFormat" , f : parsenoop } ,
0x01A5 : { n : "BrtRRAutoFmt" , f : parsenoop } ,
0x01A6 : { n : "BrtBeginUserShViews" , f : parsenoop } ,
0x01A7 : { n : "BrtBeginUserShView" , f : parsenoop } ,
0x01A8 : { n : "BrtEndUserShView" , f : parsenoop } ,
0x01A9 : { n : "BrtEndUserShViews" , f : parsenoop } ,
0x01AA : { n : "BrtArrFmla" , f : parsenoop } ,
0x01AB : { n : "BrtShrFmla" , f : parsenoop } ,
0x01AC : { n : "BrtTable" , f : parsenoop } ,
0x01AD : { n : "BrtBeginExtConnections" , f : parsenoop } ,
0x01AE : { n : "BrtEndExtConnections" , f : parsenoop } ,
0x01AF : { n : "BrtBeginPCDCalcMems" , f : parsenoop } ,
0x01B0 : { n : "BrtEndPCDCalcMems" , f : parsenoop } ,
0x01B1 : { n : "BrtBeginPCDCalcMem" , f : parsenoop } ,
0x01B2 : { n : "BrtEndPCDCalcMem" , f : parsenoop } ,
0x01B3 : { n : "BrtBeginPCDHGLevels" , f : parsenoop } ,
0x01B4 : { n : "BrtEndPCDHGLevels" , f : parsenoop } ,
0x01B5 : { n : "BrtBeginPCDHGLevel" , f : parsenoop } ,
0x01B6 : { n : "BrtEndPCDHGLevel" , f : parsenoop } ,
0x01B7 : { n : "BrtBeginPCDHGLGroups" , f : parsenoop } ,
0x01B8 : { n : "BrtEndPCDHGLGroups" , f : parsenoop } ,
0x01B9 : { n : "BrtBeginPCDHGLGroup" , f : parsenoop } ,
0x01BA : { n : "BrtEndPCDHGLGroup" , f : parsenoop } ,
0x01BB : { n : "BrtBeginPCDHGLGMembers" , f : parsenoop } ,
0x01BC : { n : "BrtEndPCDHGLGMembers" , f : parsenoop } ,
0x01BD : { n : "BrtBeginPCDHGLGMember" , f : parsenoop } ,
0x01BE : { n : "BrtEndPCDHGLGMember" , f : parsenoop } ,
0x01BF : { n : "BrtBeginQSI" , f : parsenoop } ,
0x01C0 : { n : "BrtEndQSI" , f : parsenoop } ,
0x01C1 : { n : "BrtBeginQSIR" , f : parsenoop } ,
0x01C2 : { n : "BrtEndQSIR" , f : parsenoop } ,
0x01C3 : { n : "BrtBeginDeletedNames" , f : parsenoop } ,
0x01C4 : { n : "BrtEndDeletedNames" , f : parsenoop } ,
0x01C5 : { n : "BrtBeginDeletedName" , f : parsenoop } ,
0x01C6 : { n : "BrtEndDeletedName" , f : parsenoop } ,
0x01C7 : { n : "BrtBeginQSIFs" , f : parsenoop } ,
0x01C8 : { n : "BrtEndQSIFs" , f : parsenoop } ,
0x01C9 : { n : "BrtBeginQSIF" , f : parsenoop } ,
0x01CA : { n : "BrtEndQSIF" , f : parsenoop } ,
0x01CB : { n : "BrtBeginAutoSortScope" , f : parsenoop } ,
0x01CC : { n : "BrtEndAutoSortScope" , f : parsenoop } ,
0x01CD : { n : "BrtBeginConditionalFormatting" , f : parsenoop } ,
0x01CE : { n : "BrtEndConditionalFormatting" , f : parsenoop } ,
0x01CF : { n : "BrtBeginCFRule" , f : parsenoop } ,
0x01D0 : { n : "BrtEndCFRule" , f : parsenoop } ,
0x01D1 : { n : "BrtBeginIconSet" , f : parsenoop } ,
0x01D2 : { n : "BrtEndIconSet" , f : parsenoop } ,
0x01D3 : { n : "BrtBeginDatabar" , f : parsenoop } ,
0x01D4 : { n : "BrtEndDatabar" , f : parsenoop } ,
0x01D5 : { n : "BrtBeginColorScale" , f : parsenoop } ,
0x01D6 : { n : "BrtEndColorScale" , f : parsenoop } ,
0x01D7 : { n : "BrtCFVO" , f : parsenoop } ,
0x01D8 : { n : "BrtExternValueMeta" , f : parsenoop } ,
0x01D9 : { n : "BrtBeginColorPalette" , f : parsenoop } ,
0x01DA : { n : "BrtEndColorPalette" , f : parsenoop } ,
0x01DB : { n : "BrtIndexedColor" , f : parsenoop } ,
0x01DC : { n : "BrtMargins" , f : parsenoop } ,
0x01DD : { n : "BrtPrintOptions" , f : parsenoop } ,
0x01DE : { n : "BrtPageSetup" , f : parsenoop } ,
0x01DF : { n : "BrtBeginHeaderFooter" , f : parsenoop } ,
0x01E0 : { n : "BrtEndHeaderFooter" , f : parsenoop } ,
0x01E1 : { n : "BrtBeginSXCrtFormat" , f : parsenoop } ,
0x01E2 : { n : "BrtEndSXCrtFormat" , f : parsenoop } ,
0x01E3 : { n : "BrtBeginSXCrtFormats" , f : parsenoop } ,
0x01E4 : { n : "BrtEndSXCrtFormats" , f : parsenoop } ,
0x01E5 : { n : "BrtWsFmtInfo" , f : parsenoop } ,
0x01E6 : { n : "BrtBeginMgs" , f : parsenoop } ,
0x01E7 : { n : "BrtEndMGs" , f : parsenoop } ,
0x01E8 : { n : "BrtBeginMGMaps" , f : parsenoop } ,
0x01E9 : { n : "BrtEndMGMaps" , f : parsenoop } ,
0x01EA : { n : "BrtBeginMG" , f : parsenoop } ,
0x01EB : { n : "BrtEndMG" , f : parsenoop } ,
0x01EC : { n : "BrtBeginMap" , f : parsenoop } ,
0x01ED : { n : "BrtEndMap" , f : parsenoop } ,
2014-04-15 09:04:03 +00:00
0x01EE : { n : "BrtHLink" , f : parse _BrtHLink } ,
2014-02-17 08:44:22 +00:00
0x01EF : { n : "BrtBeginDCon" , f : parsenoop } ,
0x01F0 : { n : "BrtEndDCon" , f : parsenoop } ,
0x01F1 : { n : "BrtBeginDRefs" , f : parsenoop } ,
0x01F2 : { n : "BrtEndDRefs" , f : parsenoop } ,
0x01F3 : { n : "BrtDRef" , f : parsenoop } ,
0x01F4 : { n : "BrtBeginScenMan" , f : parsenoop } ,
0x01F5 : { n : "BrtEndScenMan" , f : parsenoop } ,
0x01F6 : { n : "BrtBeginSct" , f : parsenoop } ,
0x01F7 : { n : "BrtEndSct" , f : parsenoop } ,
0x01F8 : { n : "BrtSlc" , f : parsenoop } ,
0x01F9 : { n : "BrtBeginDXFs" , f : parsenoop } ,
0x01FA : { n : "BrtEndDXFs" , f : parsenoop } ,
0x01FB : { n : "BrtDXF" , f : parsenoop } ,
0x01FC : { n : "BrtBeginTableStyles" , f : parsenoop } ,
0x01FD : { n : "BrtEndTableStyles" , f : parsenoop } ,
0x01FE : { n : "BrtBeginTableStyle" , f : parsenoop } ,
0x01FF : { n : "BrtEndTableStyle" , f : parsenoop } ,
0x0200 : { n : "BrtTableStyleElement" , f : parsenoop } ,
0x0201 : { n : "BrtTableStyleClient" , f : parsenoop } ,
0x0202 : { n : "BrtBeginVolDeps" , f : parsenoop } ,
0x0203 : { n : "BrtEndVolDeps" , f : parsenoop } ,
0x0204 : { n : "BrtBeginVolType" , f : parsenoop } ,
0x0205 : { n : "BrtEndVolType" , f : parsenoop } ,
0x0206 : { n : "BrtBeginVolMain" , f : parsenoop } ,
0x0207 : { n : "BrtEndVolMain" , f : parsenoop } ,
0x0208 : { n : "BrtBeginVolTopic" , f : parsenoop } ,
0x0209 : { n : "BrtEndVolTopic" , f : parsenoop } ,
0x020A : { n : "BrtVolSubtopic" , f : parsenoop } ,
0x020B : { n : "BrtVolRef" , f : parsenoop } ,
0x020C : { n : "BrtVolNum" , f : parsenoop } ,
0x020D : { n : "BrtVolErr" , f : parsenoop } ,
0x020E : { n : "BrtVolStr" , f : parsenoop } ,
0x020F : { n : "BrtVolBool" , f : parsenoop } ,
2014-03-29 22:53:15 +00:00
0x0210 : { n : "BrtBeginCalcChain$" , f : parsenoop } ,
0x0211 : { n : "BrtEndCalcChain$" , f : parsenoop } ,
2014-02-17 08:44:22 +00:00
0x0212 : { n : "BrtBeginSortState" , f : parsenoop } ,
0x0213 : { n : "BrtEndSortState" , f : parsenoop } ,
0x0214 : { n : "BrtBeginSortCond" , f : parsenoop } ,
0x0215 : { n : "BrtEndSortCond" , f : parsenoop } ,
0x0216 : { n : "BrtBookProtection" , f : parsenoop } ,
0x0217 : { n : "BrtSheetProtection" , f : parsenoop } ,
0x0218 : { n : "BrtRangeProtection" , f : parsenoop } ,
0x0219 : { n : "BrtPhoneticInfo" , f : parsenoop } ,
0x021A : { n : "BrtBeginECTxtWiz" , f : parsenoop } ,
0x021B : { n : "BrtEndECTxtWiz" , f : parsenoop } ,
0x021C : { n : "BrtBeginECTWFldInfoLst" , f : parsenoop } ,
0x021D : { n : "BrtEndECTWFldInfoLst" , f : parsenoop } ,
0x021E : { n : "BrtBeginECTwFldInfo" , f : parsenoop } ,
0x0224 : { n : "BrtFileSharing" , f : parsenoop } ,
0x0225 : { n : "BrtOleSize" , f : parsenoop } ,
0x0226 : { n : "BrtDrawing" , f : parsenoop } ,
0x0227 : { n : "BrtLegacyDrawing" , f : parsenoop } ,
0x0228 : { n : "BrtLegacyDrawingHF" , f : parsenoop } ,
0x0229 : { n : "BrtWebOpt" , f : parsenoop } ,
0x022A : { n : "BrtBeginWebPubItems" , f : parsenoop } ,
0x022B : { n : "BrtEndWebPubItems" , f : parsenoop } ,
0x022C : { n : "BrtBeginWebPubItem" , f : parsenoop } ,
0x022D : { n : "BrtEndWebPubItem" , f : parsenoop } ,
0x022E : { n : "BrtBeginSXCondFmt" , f : parsenoop } ,
0x022F : { n : "BrtEndSXCondFmt" , f : parsenoop } ,
0x0230 : { n : "BrtBeginSXCondFmts" , f : parsenoop } ,
0x0231 : { n : "BrtEndSXCondFmts" , f : parsenoop } ,
0x0232 : { n : "BrtBkHim" , f : parsenoop } ,
0x0234 : { n : "BrtColor" , f : parsenoop } ,
0x0235 : { n : "BrtBeginIndexedColors" , f : parsenoop } ,
0x0236 : { n : "BrtEndIndexedColors" , f : parsenoop } ,
0x0239 : { n : "BrtBeginMRUColors" , f : parsenoop } ,
0x023A : { n : "BrtEndMRUColors" , f : parsenoop } ,
0x023C : { n : "BrtMRUColor" , f : parsenoop } ,
0x023D : { n : "BrtBeginDVals" , f : parsenoop } ,
0x023E : { n : "BrtEndDVals" , f : parsenoop } ,
0x0241 : { n : "BrtSupNameStart" , f : parsenoop } ,
0x0242 : { n : "BrtSupNameValueStart" , f : parsenoop } ,
0x0243 : { n : "BrtSupNameValueEnd" , f : parsenoop } ,
0x0244 : { n : "BrtSupNameNum" , f : parsenoop } ,
0x0245 : { n : "BrtSupNameErr" , f : parsenoop } ,
0x0246 : { n : "BrtSupNameSt" , f : parsenoop } ,
0x0247 : { n : "BrtSupNameNil" , f : parsenoop } ,
0x0248 : { n : "BrtSupNameBool" , f : parsenoop } ,
0x0249 : { n : "BrtSupNameFmla" , f : parsenoop } ,
0x024A : { n : "BrtSupNameBits" , f : parsenoop } ,
0x024B : { n : "BrtSupNameEnd" , f : parsenoop } ,
0x024C : { n : "BrtEndSupBook" , f : parsenoop } ,
0x024D : { n : "BrtCellSmartTagProperty" , f : parsenoop } ,
0x024E : { n : "BrtBeginCellSmartTag" , f : parsenoop } ,
0x024F : { n : "BrtEndCellSmartTag" , f : parsenoop } ,
0x0250 : { n : "BrtBeginCellSmartTags" , f : parsenoop } ,
0x0251 : { n : "BrtEndCellSmartTags" , f : parsenoop } ,
0x0252 : { n : "BrtBeginSmartTags" , f : parsenoop } ,
0x0253 : { n : "BrtEndSmartTags" , f : parsenoop } ,
0x0254 : { n : "BrtSmartTagType" , f : parsenoop } ,
0x0255 : { n : "BrtBeginSmartTagTypes" , f : parsenoop } ,
0x0256 : { n : "BrtEndSmartTagTypes" , f : parsenoop } ,
0x0257 : { n : "BrtBeginSXFilters" , f : parsenoop } ,
0x0258 : { n : "BrtEndSXFilters" , f : parsenoop } ,
0x0259 : { n : "BrtBeginSXFILTER" , f : parsenoop } ,
0x025A : { n : "BrtEndSXFilter" , f : parsenoop } ,
0x025B : { n : "BrtBeginFills" , f : parsenoop } ,
0x025C : { n : "BrtEndFills" , f : parsenoop } ,
0x025D : { n : "BrtBeginCellWatches" , f : parsenoop } ,
0x025E : { n : "BrtEndCellWatches" , f : parsenoop } ,
0x025F : { n : "BrtCellWatch" , f : parsenoop } ,
0x0260 : { n : "BrtBeginCRErrs" , f : parsenoop } ,
0x0261 : { n : "BrtEndCRErrs" , f : parsenoop } ,
0x0262 : { n : "BrtCrashRecErr" , f : parsenoop } ,
0x0263 : { n : "BrtBeginFonts" , f : parsenoop } ,
0x0264 : { n : "BrtEndFonts" , f : parsenoop } ,
0x0265 : { n : "BrtBeginBorders" , f : parsenoop } ,
0x0266 : { n : "BrtEndBorders" , f : parsenoop } ,
0x0267 : { n : "BrtBeginFmts" , f : parsenoop } ,
0x0268 : { n : "BrtEndFmts" , f : parsenoop } ,
0x0269 : { n : "BrtBeginCellXFs" , f : parsenoop } ,
0x026A : { n : "BrtEndCellXFs" , f : parsenoop } ,
0x026B : { n : "BrtBeginStyles" , f : parsenoop } ,
0x026C : { n : "BrtEndStyles" , f : parsenoop } ,
0x0271 : { n : "BrtBigName" , f : parsenoop } ,
0x0272 : { n : "BrtBeginCellStyleXFs" , f : parsenoop } ,
0x0273 : { n : "BrtEndCellStyleXFs" , f : parsenoop } ,
0x0274 : { n : "BrtBeginComments" , f : parsenoop } ,
0x0275 : { n : "BrtEndComments" , f : parsenoop } ,
0x0276 : { n : "BrtBeginCommentAuthors" , f : parsenoop } ,
0x0277 : { n : "BrtEndCommentAuthors" , f : parsenoop } ,
2014-03-29 02:05:50 +00:00
0x0278 : { n : "BrtCommentAuthor" , f : parse _BrtCommentAuthor } ,
2014-02-17 08:44:22 +00:00
0x0279 : { n : "BrtBeginCommentList" , f : parsenoop } ,
0x027A : { n : "BrtEndCommentList" , f : parsenoop } ,
2014-03-29 02:05:50 +00:00
0x027B : { n : "BrtBeginComment" , f : parse _BrtBeginComment } ,
2014-02-17 08:44:22 +00:00
0x027C : { n : "BrtEndComment" , f : parsenoop } ,
2014-03-29 02:05:50 +00:00
0x027D : { n : "BrtCommentText" , f : parse _BrtCommentText } ,
2014-02-17 08:44:22 +00:00
0x027E : { n : "BrtBeginOleObjects" , f : parsenoop } ,
0x027F : { n : "BrtOleObject" , f : parsenoop } ,
0x0280 : { n : "BrtEndOleObjects" , f : parsenoop } ,
0x0281 : { n : "BrtBeginSxrules" , f : parsenoop } ,
0x0282 : { n : "BrtEndSxRules" , f : parsenoop } ,
0x0283 : { n : "BrtBeginActiveXControls" , f : parsenoop } ,
0x0284 : { n : "BrtActiveX" , f : parsenoop } ,
0x0285 : { n : "BrtEndActiveXControls" , f : parsenoop } ,
0x0286 : { n : "BrtBeginPCDSDTCEMembersSortBy" , f : parsenoop } ,
0x0288 : { n : "BrtBeginCellIgnoreECs" , f : parsenoop } ,
0x0289 : { n : "BrtCellIgnoreEC" , f : parsenoop } ,
0x028A : { n : "BrtEndCellIgnoreECs" , f : parsenoop } ,
0x028B : { n : "BrtCsProp" , f : parsenoop } ,
0x028C : { n : "BrtCsPageSetup" , f : parsenoop } ,
0x028D : { n : "BrtBeginUserCsViews" , f : parsenoop } ,
0x028E : { n : "BrtEndUserCsViews" , f : parsenoop } ,
0x028F : { n : "BrtBeginUserCsView" , f : parsenoop } ,
0x0290 : { n : "BrtEndUserCsView" , f : parsenoop } ,
0x0291 : { n : "BrtBeginPcdSFCIEntries" , f : parsenoop } ,
0x0292 : { n : "BrtEndPCDSFCIEntries" , f : parsenoop } ,
0x0293 : { n : "BrtPCDSFCIEntry" , f : parsenoop } ,
0x0294 : { n : "BrtBeginListParts" , f : parsenoop } ,
0x0295 : { n : "BrtListPart" , f : parsenoop } ,
0x0296 : { n : "BrtEndListParts" , f : parsenoop } ,
0x0297 : { n : "BrtSheetCalcProp" , f : parsenoop } ,
0x0298 : { n : "BrtBeginFnGroup" , f : parsenoop } ,
0x0299 : { n : "BrtFnGroup" , f : parsenoop } ,
0x029A : { n : "BrtEndFnGroup" , f : parsenoop } ,
0x029B : { n : "BrtSupAddin" , f : parsenoop } ,
0x029C : { n : "BrtSXTDMPOrder" , f : parsenoop } ,
0x029D : { n : "BrtCsProtection" , f : parsenoop } ,
0x029F : { n : "BrtBeginWsSortMap" , f : parsenoop } ,
0x02A0 : { n : "BrtEndWsSortMap" , f : parsenoop } ,
0x02A1 : { n : "BrtBeginRRSort" , f : parsenoop } ,
0x02A2 : { n : "BrtEndRRSort" , f : parsenoop } ,
0x02A3 : { n : "BrtRRSortItem" , f : parsenoop } ,
0x02A4 : { n : "BrtFileSharingIso" , f : parsenoop } ,
0x02A5 : { n : "BrtBookProtectionIso" , f : parsenoop } ,
0x02A6 : { n : "BrtSheetProtectionIso" , f : parsenoop } ,
0x02A7 : { n : "BrtCsProtectionIso" , f : parsenoop } ,
0x02A8 : { n : "BrtRangeProtectionIso" , f : parsenoop } ,
0x0400 : { n : "BrtRwDescent" , f : parsenoop } ,
0x0401 : { n : "BrtKnownFonts" , f : parsenoop } ,
0x0402 : { n : "BrtBeginSXTupleSet" , f : parsenoop } ,
0x0403 : { n : "BrtEndSXTupleSet" , f : parsenoop } ,
0x0404 : { n : "BrtBeginSXTupleSetHeader" , f : parsenoop } ,
0x0405 : { n : "BrtEndSXTupleSetHeader" , f : parsenoop } ,
0x0406 : { n : "BrtSXTupleSetHeaderItem" , f : parsenoop } ,
0x0407 : { n : "BrtBeginSXTupleSetData" , f : parsenoop } ,
0x0408 : { n : "BrtEndSXTupleSetData" , f : parsenoop } ,
0x0409 : { n : "BrtBeginSXTupleSetRow" , f : parsenoop } ,
0x040A : { n : "BrtEndSXTupleSetRow" , f : parsenoop } ,
0x040B : { n : "BrtSXTupleSetRowItem" , f : parsenoop } ,
0x040C : { n : "BrtNameExt" , f : parsenoop } ,
0x040D : { n : "BrtPCDH14" , f : parsenoop } ,
0x040E : { n : "BrtBeginPCDCalcMem14" , f : parsenoop } ,
0x040F : { n : "BrtEndPCDCalcMem14" , f : parsenoop } ,
0x0410 : { n : "BrtSXTH14" , f : parsenoop } ,
0x0411 : { n : "BrtBeginSparklineGroup" , f : parsenoop } ,
0x0412 : { n : "BrtEndSparklineGroup" , f : parsenoop } ,
0x0413 : { n : "BrtSparkline" , f : parsenoop } ,
0x0414 : { n : "BrtSXDI14" , f : parsenoop } ,
0x0415 : { n : "BrtWsFmtInfoEx14" , f : parsenoop } ,
0x0416 : { n : "BrtBeginConditionalFormatting14" , f : parsenoop } ,
0x0417 : { n : "BrtEndConditionalFormatting14" , f : parsenoop } ,
0x0418 : { n : "BrtBeginCFRule14" , f : parsenoop } ,
0x0419 : { n : "BrtEndCFRule14" , f : parsenoop } ,
0x041A : { n : "BrtCFVO14" , f : parsenoop } ,
0x041B : { n : "BrtBeginDatabar14" , f : parsenoop } ,
0x041C : { n : "BrtBeginIconSet14" , f : parsenoop } ,
0x041D : { n : "BrtDVal14" , f : parsenoop } ,
0x041E : { n : "BrtBeginDVals14" , f : parsenoop } ,
0x041F : { n : "BrtColor14" , f : parsenoop } ,
0x0420 : { n : "BrtBeginSparklines" , f : parsenoop } ,
0x0421 : { n : "BrtEndSparklines" , f : parsenoop } ,
0x0422 : { n : "BrtBeginSparklineGroups" , f : parsenoop } ,
0x0423 : { n : "BrtEndSparklineGroups" , f : parsenoop } ,
0x0425 : { n : "BrtSXVD14" , f : parsenoop } ,
0x0426 : { n : "BrtBeginSxview14" , f : parsenoop } ,
0x0427 : { n : "BrtEndSxview14" , f : parsenoop } ,
0x042A : { n : "BrtBeginPCD14" , f : parsenoop } ,
0x042B : { n : "BrtEndPCD14" , f : parsenoop } ,
0x042C : { n : "BrtBeginExtConn14" , f : parsenoop } ,
0x042D : { n : "BrtEndExtConn14" , f : parsenoop } ,
0x042E : { n : "BrtBeginSlicerCacheIDs" , f : parsenoop } ,
0x042F : { n : "BrtEndSlicerCacheIDs" , f : parsenoop } ,
0x0430 : { n : "BrtBeginSlicerCacheID" , f : parsenoop } ,
0x0431 : { n : "BrtEndSlicerCacheID" , f : parsenoop } ,
0x0433 : { n : "BrtBeginSlicerCache" , f : parsenoop } ,
0x0434 : { n : "BrtEndSlicerCache" , f : parsenoop } ,
0x0435 : { n : "BrtBeginSlicerCacheDef" , f : parsenoop } ,
0x0436 : { n : "BrtEndSlicerCacheDef" , f : parsenoop } ,
0x0437 : { n : "BrtBeginSlicersEx" , f : parsenoop } ,
0x0438 : { n : "BrtEndSlicersEx" , f : parsenoop } ,
0x0439 : { n : "BrtBeginSlicerEx" , f : parsenoop } ,
0x043A : { n : "BrtEndSlicerEx" , f : parsenoop } ,
0x043B : { n : "BrtBeginSlicer" , f : parsenoop } ,
0x043C : { n : "BrtEndSlicer" , f : parsenoop } ,
0x043D : { n : "BrtSlicerCachePivotTables" , f : parsenoop } ,
0x043E : { n : "BrtBeginSlicerCacheOlapImpl" , f : parsenoop } ,
0x043F : { n : "BrtEndSlicerCacheOlapImpl" , f : parsenoop } ,
0x0440 : { n : "BrtBeginSlicerCacheLevelsData" , f : parsenoop } ,
0x0441 : { n : "BrtEndSlicerCacheLevelsData" , f : parsenoop } ,
0x0442 : { n : "BrtBeginSlicerCacheLevelData" , f : parsenoop } ,
0x0443 : { n : "BrtEndSlicerCacheLevelData" , f : parsenoop } ,
0x0444 : { n : "BrtBeginSlicerCacheSiRanges" , f : parsenoop } ,
0x0445 : { n : "BrtEndSlicerCacheSiRanges" , f : parsenoop } ,
0x0446 : { n : "BrtBeginSlicerCacheSiRange" , f : parsenoop } ,
0x0447 : { n : "BrtEndSlicerCacheSiRange" , f : parsenoop } ,
0x0448 : { n : "BrtSlicerCacheOlapItem" , f : parsenoop } ,
0x0449 : { n : "BrtBeginSlicerCacheSelections" , f : parsenoop } ,
0x044A : { n : "BrtSlicerCacheSelection" , f : parsenoop } ,
0x044B : { n : "BrtEndSlicerCacheSelections" , f : parsenoop } ,
0x044C : { n : "BrtBeginSlicerCacheNative" , f : parsenoop } ,
0x044D : { n : "BrtEndSlicerCacheNative" , f : parsenoop } ,
0x044E : { n : "BrtSlicerCacheNativeItem" , f : parsenoop } ,
0x044F : { n : "BrtRangeProtection14" , f : parsenoop } ,
0x0450 : { n : "BrtRangeProtectionIso14" , f : parsenoop } ,
0x0451 : { n : "BrtCellIgnoreEC14" , f : parsenoop } ,
0x0457 : { n : "BrtList14" , f : parsenoop } ,
0x0458 : { n : "BrtCFIcon" , f : parsenoop } ,
0x0459 : { n : "BrtBeginSlicerCachesPivotCacheIDs" , f : parsenoop } ,
0x045A : { n : "BrtEndSlicerCachesPivotCacheIDs" , f : parsenoop } ,
0x045B : { n : "BrtBeginSlicers" , f : parsenoop } ,
0x045C : { n : "BrtEndSlicers" , f : parsenoop } ,
0x045D : { n : "BrtWbProp14" , f : parsenoop } ,
0x045E : { n : "BrtBeginSXEdit" , f : parsenoop } ,
0x045F : { n : "BrtEndSXEdit" , f : parsenoop } ,
0x0460 : { n : "BrtBeginSXEdits" , f : parsenoop } ,
0x0461 : { n : "BrtEndSXEdits" , f : parsenoop } ,
0x0462 : { n : "BrtBeginSXChange" , f : parsenoop } ,
0x0463 : { n : "BrtEndSXChange" , f : parsenoop } ,
0x0464 : { n : "BrtBeginSXChanges" , f : parsenoop } ,
0x0465 : { n : "BrtEndSXChanges" , f : parsenoop } ,
0x0466 : { n : "BrtSXTupleItems" , f : parsenoop } ,
0x0468 : { n : "BrtBeginSlicerStyle" , f : parsenoop } ,
0x0469 : { n : "BrtEndSlicerStyle" , f : parsenoop } ,
0x046A : { n : "BrtSlicerStyleElement" , f : parsenoop } ,
0x046B : { n : "BrtBeginStyleSheetExt14" , f : parsenoop } ,
0x046C : { n : "BrtEndStyleSheetExt14" , f : parsenoop } ,
0x046D : { n : "BrtBeginSlicerCachesPivotCacheID" , f : parsenoop } ,
0x046E : { n : "BrtEndSlicerCachesPivotCacheID" , f : parsenoop } ,
0x046F : { n : "BrtBeginConditionalFormattings" , f : parsenoop } ,
0x0470 : { n : "BrtEndConditionalFormattings" , f : parsenoop } ,
0x0471 : { n : "BrtBeginPCDCalcMemExt" , f : parsenoop } ,
0x0472 : { n : "BrtEndPCDCalcMemExt" , f : parsenoop } ,
0x0473 : { n : "BrtBeginPCDCalcMemsExt" , f : parsenoop } ,
0x0474 : { n : "BrtEndPCDCalcMemsExt" , f : parsenoop } ,
0x0475 : { n : "BrtPCDField14" , f : parsenoop } ,
0x0476 : { n : "BrtBeginSlicerStyles" , f : parsenoop } ,
0x0477 : { n : "BrtEndSlicerStyles" , f : parsenoop } ,
0x0478 : { n : "BrtBeginSlicerStyleElements" , f : parsenoop } ,
0x0479 : { n : "BrtEndSlicerStyleElements" , f : parsenoop } ,
0x047A : { n : "BrtCFRuleExt" , f : parsenoop } ,
0x047B : { n : "BrtBeginSXCondFmt14" , f : parsenoop } ,
0x047C : { n : "BrtEndSXCondFmt14" , f : parsenoop } ,
0x047D : { n : "BrtBeginSXCondFmts14" , f : parsenoop } ,
0x047E : { n : "BrtEndSXCondFmts14" , f : parsenoop } ,
0x0480 : { n : "BrtBeginSortCond14" , f : parsenoop } ,
0x0481 : { n : "BrtEndSortCond14" , f : parsenoop } ,
0x0482 : { n : "BrtEndDVals14" , f : parsenoop } ,
0x0483 : { n : "BrtEndIconSet14" , f : parsenoop } ,
0x0484 : { n : "BrtEndDatabar14" , f : parsenoop } ,
0x0485 : { n : "BrtBeginColorScale14" , f : parsenoop } ,
0x0486 : { n : "BrtEndColorScale14" , f : parsenoop } ,
0x0487 : { n : "BrtBeginSxrules14" , f : parsenoop } ,
0x0488 : { n : "BrtEndSxrules14" , f : parsenoop } ,
0x0489 : { n : "BrtBeginPRule14" , f : parsenoop } ,
0x048A : { n : "BrtEndPRule14" , f : parsenoop } ,
0x048B : { n : "BrtBeginPRFilters14" , f : parsenoop } ,
0x048C : { n : "BrtEndPRFilters14" , f : parsenoop } ,
0x048D : { n : "BrtBeginPRFilter14" , f : parsenoop } ,
0x048E : { n : "BrtEndPRFilter14" , f : parsenoop } ,
0x048F : { n : "BrtBeginPRFItem14" , f : parsenoop } ,
0x0490 : { n : "BrtEndPRFItem14" , f : parsenoop } ,
0x0491 : { n : "BrtBeginCellIgnoreECs14" , f : parsenoop } ,
0x0492 : { n : "BrtEndCellIgnoreECs14" , f : parsenoop } ,
0x0493 : { n : "BrtDxf14" , f : parsenoop } ,
0x0494 : { n : "BrtBeginDxF14s" , f : parsenoop } ,
0x0495 : { n : "BrtEndDxf14s" , f : parsenoop } ,
0x0499 : { n : "BrtFilter14" , f : parsenoop } ,
0x049A : { n : "BrtBeginCustomFilters14" , f : parsenoop } ,
0x049C : { n : "BrtCustomFilter14" , f : parsenoop } ,
0x049D : { n : "BrtIconFilter14" , f : parsenoop } ,
0x049E : { n : "BrtPivotCacheConnectionName" , f : parsenoop } ,
0x0800 : { n : "BrtBeginDecoupledPivotCacheIDs" , f : parsenoop } ,
0x0801 : { n : "BrtEndDecoupledPivotCacheIDs" , f : parsenoop } ,
0x0802 : { n : "BrtDecoupledPivotCacheID" , f : parsenoop } ,
0x0803 : { n : "BrtBeginPivotTableRefs" , f : parsenoop } ,
0x0804 : { n : "BrtEndPivotTableRefs" , f : parsenoop } ,
0x0805 : { n : "BrtPivotTableRef" , f : parsenoop } ,
0x0806 : { n : "BrtSlicerCacheBookPivotTables" , f : parsenoop } ,
0x0807 : { n : "BrtBeginSxvcells" , f : parsenoop } ,
0x0808 : { n : "BrtEndSxvcells" , f : parsenoop } ,
0x0809 : { n : "BrtBeginSxRow" , f : parsenoop } ,
0x080A : { n : "BrtEndSxRow" , f : parsenoop } ,
0x080C : { n : "BrtPcdCalcMem15" , f : parsenoop } ,
0x0813 : { n : "BrtQsi15" , f : parsenoop } ,
0x0814 : { n : "BrtBeginWebExtensions" , f : parsenoop } ,
0x0815 : { n : "BrtEndWebExtensions" , f : parsenoop } ,
0x0816 : { n : "BrtWebExtension" , f : parsenoop } ,
0x0817 : { n : "BrtAbsPath15" , f : parsenoop } ,
0x0818 : { n : "BrtBeginPivotTableUISettings" , f : parsenoop } ,
0x0819 : { n : "BrtEndPivotTableUISettings" , f : parsenoop } ,
0x081B : { n : "BrtTableSlicerCacheIDs" , f : parsenoop } ,
0x081C : { n : "BrtTableSlicerCacheID" , f : parsenoop } ,
0x081D : { n : "BrtBeginTableSlicerCache" , f : parsenoop } ,
0x081E : { n : "BrtEndTableSlicerCache" , f : parsenoop } ,
0x081F : { n : "BrtSxFilter15" , f : parsenoop } ,
0x0820 : { n : "BrtBeginTimelineCachePivotCacheIDs" , f : parsenoop } ,
0x0821 : { n : "BrtEndTimelineCachePivotCacheIDs" , f : parsenoop } ,
0x0822 : { n : "BrtTimelineCachePivotCacheID" , f : parsenoop } ,
0x0823 : { n : "BrtBeginTimelineCacheIDs" , f : parsenoop } ,
0x0824 : { n : "BrtEndTimelineCacheIDs" , f : parsenoop } ,
0x0825 : { n : "BrtBeginTimelineCacheID" , f : parsenoop } ,
0x0826 : { n : "BrtEndTimelineCacheID" , f : parsenoop } ,
0x0827 : { n : "BrtBeginTimelinesEx" , f : parsenoop } ,
0x0828 : { n : "BrtEndTimelinesEx" , f : parsenoop } ,
0x0829 : { n : "BrtBeginTimelineEx" , f : parsenoop } ,
0x082A : { n : "BrtEndTimelineEx" , f : parsenoop } ,
0x082B : { n : "BrtWorkBookPr15" , f : parsenoop } ,
0x082C : { n : "BrtPCDH15" , f : parsenoop } ,
0x082D : { n : "BrtBeginTimelineStyle" , f : parsenoop } ,
0x082E : { n : "BrtEndTimelineStyle" , f : parsenoop } ,
0x082F : { n : "BrtTimelineStyleElement" , f : parsenoop } ,
0x0830 : { n : "BrtBeginTimelineStylesheetExt15" , f : parsenoop } ,
0x0831 : { n : "BrtEndTimelineStylesheetExt15" , f : parsenoop } ,
0x0832 : { n : "BrtBeginTimelineStyles" , f : parsenoop } ,
0x0833 : { n : "BrtEndTimelineStyles" , f : parsenoop } ,
0x0834 : { n : "BrtBeginTimelineStyleElements" , f : parsenoop } ,
0x0835 : { n : "BrtEndTimelineStyleElements" , f : parsenoop } ,
0x0836 : { n : "BrtDxf15" , f : parsenoop } ,
0x0837 : { n : "BrtBeginDxfs15" , f : parsenoop } ,
0x0838 : { n : "brtEndDxfs15" , f : parsenoop } ,
0x0839 : { n : "BrtSlicerCacheHideItemsWithNoData" , f : parsenoop } ,
0x083A : { n : "BrtBeginItemUniqueNames" , f : parsenoop } ,
0x083B : { n : "BrtEndItemUniqueNames" , f : parsenoop } ,
0x083C : { n : "BrtItemUniqueName" , f : parsenoop } ,
0x083D : { n : "BrtBeginExtConn15" , f : parsenoop } ,
0x083E : { n : "BrtEndExtConn15" , f : parsenoop } ,
0x083F : { n : "BrtBeginOledbPr15" , f : parsenoop } ,
0x0840 : { n : "BrtEndOledbPr15" , f : parsenoop } ,
0x0841 : { n : "BrtBeginDataFeedPr15" , f : parsenoop } ,
0x0842 : { n : "BrtEndDataFeedPr15" , f : parsenoop } ,
0x0843 : { n : "BrtTextPr15" , f : parsenoop } ,
0x0844 : { n : "BrtRangePr15" , f : parsenoop } ,
0x0845 : { n : "BrtDbCommand15" , f : parsenoop } ,
0x0846 : { n : "BrtBeginDbTables15" , f : parsenoop } ,
0x0847 : { n : "BrtEndDbTables15" , f : parsenoop } ,
0x0848 : { n : "BrtDbTable15" , f : parsenoop } ,
0x0849 : { n : "BrtBeginDataModel" , f : parsenoop } ,
0x084A : { n : "BrtEndDataModel" , f : parsenoop } ,
0x084B : { n : "BrtBeginModelTables" , f : parsenoop } ,
0x084C : { n : "BrtEndModelTables" , f : parsenoop } ,
0x084D : { n : "BrtModelTable" , f : parsenoop } ,
0x084E : { n : "BrtBeginModelRelationships" , f : parsenoop } ,
0x084F : { n : "BrtEndModelRelationships" , f : parsenoop } ,
0x0850 : { n : "BrtModelRelationship" , f : parsenoop } ,
0x0851 : { n : "BrtBeginECTxtWiz15" , f : parsenoop } ,
0x0852 : { n : "BrtEndECTxtWiz15" , f : parsenoop } ,
0x0853 : { n : "BrtBeginECTWFldInfoLst15" , f : parsenoop } ,
0x0854 : { n : "BrtEndECTWFldInfoLst15" , f : parsenoop } ,
0x0855 : { n : "BrtBeginECTWFldInfo15" , f : parsenoop } ,
0x0856 : { n : "BrtFieldListActiveItem" , f : parsenoop } ,
0x0857 : { n : "BrtPivotCacheIdVersion" , f : parsenoop } ,
0x0858 : { n : "BrtSXDI15" , f : parsenoop } ,
0xFFFF : { n : "" , f : parsenoop }
} ;
2014-05-29 22:30:03 +00:00
var evert _RE = evert ( RecordEnum , 'n' ) ;
2014-05-16 00:33:34 +00:00
function fix _opts ( defaults ) {
return function ( opts ) {
defaults . forEach ( function ( d ) {
if ( typeof opts [ d [ 0 ] ] === 'undefined' ) opts [ d [ 0 ] ] = d [ 1 ] ;
if ( d [ 2 ] === 'n' ) opts [ d [ 0 ] ] = Number ( opts [ d [ 0 ] ] ) ;
} ) ;
} ;
2014-02-17 08:44:22 +00:00
}
2014-05-16 00:33:34 +00:00
var fix _read _opts = fix _opts ( [
[ 'cellNF' , false ] , /* emit cell number format string as .z */
[ 'cellHTML' , true ] , /* emit html string as .h */
[ 'cellFormula' , true ] , /* emit formulae as .f */
2014-05-29 22:30:03 +00:00
[ 'cellStyles' , false ] , /* emits style/theme as .s */
2014-05-16 00:33:34 +00:00
[ 'sheetStubs' , false ] , /* emit empty cells */
[ 'sheetRows' , 0 , 'n' ] , /* read n rows (0 = read all rows) */
[ 'bookDeps' , false ] , /* parse calculation chains */
[ 'bookSheets' , false ] , /* only try to get sheet names (no Sheets) */
[ 'bookProps' , false ] , /* only try to get properties (no Sheets) */
[ 'bookFiles' , false ] , /* include raw file structure (keys, files) */
[ 'bookVBA' , false ] , /* include vba raw data (vbaraw) */
[ 'WTF' , false ] /* WTF mode (throws errors) */
] ) ;
var fix _write _opts = fix _opts ( [
[ 'bookSST' , false ] , /* Generate Shared String Table */
[ 'bookType' , 'xlsx' ] , /* Type of workbook (xlsx/m/b) */
[ 'WTF' , false ] /* WTF mode (throws errors) */
] ) ;
function parse _zip ( zip , opts ) {
make _ssf ( SSF ) ;
2014-02-17 08:44:22 +00:00
opts = opts || { } ;
2014-05-16 00:33:34 +00:00
fix _read _opts ( opts ) ;
2014-02-17 08:44:22 +00:00
reset _cp ( ) ;
2014-05-16 00:33:34 +00:00
var entries = keys ( zip . files ) . filter ( function ( x ) { return x . substr ( - 1 ) != '/' ; } ) . sort ( ) ;
var dir = parse _ct ( getzipdata ( zip , '[Content_Types].xml' ) , opts ) ;
2014-02-17 08:44:22 +00:00
var xlsb = false ;
2014-04-03 22:51:54 +00:00
var sheets , binname ;
if ( dir . workbooks . length === 0 ) {
binname = "xl/workbook.xml" ;
if ( getzipdata ( zip , binname , true ) ) dir . workbooks . push ( binname ) ;
}
2014-02-17 08:44:22 +00:00
if ( dir . workbooks . length === 0 ) {
2014-04-03 22:51:54 +00:00
binname = "xl/workbook.bin" ;
if ( ! getzipfile ( zip , binname , true ) ) throw new Error ( "Could not find workbook" ) ;
2014-02-17 08:44:22 +00:00
dir . workbooks . push ( binname ) ;
xlsb = true ;
}
2014-05-29 22:30:03 +00:00
if ( dir . workbooks [ 0 ] . substr ( - 3 ) == "bin" ) xlsb = true ;
2014-05-22 12:16:51 +00:00
if ( xlsb ) set _cp ( 1200 ) ;
2014-02-17 08:44:22 +00:00
if ( ! opts . bookSheets && ! opts . bookProps ) {
2014-05-16 00:33:34 +00:00
strs = [ ] ;
2014-02-17 08:44:22 +00:00
if ( dir . sst ) strs = parse _sst ( getzipdata ( zip , dir . sst . replace ( /^\// , '' ) ) , dir . sst , opts ) ;
styles = { } ;
2014-03-23 21:30:00 +00:00
if ( dir . style ) styles = parse _sty ( getzipdata ( zip , dir . style . replace ( /^\// , '' ) ) , dir . style , opts ) ;
2014-05-29 22:30:03 +00:00
themes = { } ;
if ( opts . cellStyles && dir . themes . length ) themes = parse _theme ( getzipdata ( zip , dir . themes [ 0 ] . replace ( /^\// , '' ) ) , dir . themes [ 0 ] , opts ) ;
2014-02-17 08:44:22 +00:00
}
var wb = parse _wb ( getzipdata ( zip , dir . workbooks [ 0 ] . replace ( /^\// , '' ) ) , dir . workbooks [ 0 ] , opts ) ;
var props = { } , propdata = "" ;
2014-05-16 00:33:34 +00:00
if ( dir . coreprops . length !== 0 ) {
propdata = getzipdata ( zip , dir . coreprops [ 0 ] . replace ( /^\// , '' ) , true ) ;
if ( propdata ) props = parse _core _props ( propdata ) ;
if ( dir . extprops . length !== 0 ) {
propdata = getzipdata ( zip , dir . extprops [ 0 ] . replace ( /^\// , '' ) , true ) ;
if ( propdata ) parse _ext _props ( propdata , props ) ;
}
}
2014-02-17 08:44:22 +00:00
var custprops = { } ;
if ( ! opts . bookSheets || opts . bookProps ) {
if ( dir . custprops . length !== 0 ) {
propdata = getzipdata ( zip , dir . custprops [ 0 ] . replace ( /^\// , '' ) , true ) ;
2014-05-16 00:33:34 +00:00
if ( propdata ) custprops = parse _cust _props ( propdata , opts ) ;
2014-02-17 08:44:22 +00:00
}
}
var out = { } ;
if ( opts . bookSheets || opts . bookProps ) {
if ( props . Worksheets && props . SheetNames . length > 0 ) sheets = props . SheetNames ;
else if ( wb . Sheets ) sheets = wb . Sheets . map ( function ( x ) { return x . name ; } ) ;
if ( opts . bookProps ) { out . Props = props ; out . Custprops = custprops ; }
if ( typeof sheets !== 'undefined' ) out . SheetNames = sheets ;
if ( opts . bookSheets ? out . SheetNames : opts . bookProps ) return out ;
}
sheets = { } ;
var deps = { } ;
2014-03-29 22:53:15 +00:00
if ( opts . bookDeps && dir . calcchain ) deps = parse _cc ( getzipdata ( zip , dir . calcchain . replace ( /^\// , '' ) ) , dir . calcchain , opts ) ;
2014-02-17 08:44:22 +00:00
var i = 0 ;
var sheetRels = { } ;
var path , relsPath ;
if ( ! props . Worksheets ) {
var wbsheets = wb . Sheets ;
props . Worksheets = wbsheets . length ;
props . SheetNames = [ ] ;
for ( var j = 0 ; j != wbsheets . length ; ++ j ) {
props . SheetNames [ j ] = wbsheets [ j ] . name ;
}
2014-02-21 16:41:37 +00:00
}
2014-05-22 12:16:51 +00:00
2014-05-29 22:30:03 +00:00
var wbext = xlsb ? "bin" : "xml" ;
var wbrelsfile = 'xl/_rels/workbook.' + wbext + '.rels' ;
2014-05-22 12:16:51 +00:00
var wbrels = parse _rels ( getzipdata ( zip , wbrelsfile , true ) , wbrelsfile ) ;
if ( wbrels ) try {
wbrels = wb . Sheets . map ( function ( w ) { return [ w . name , wbrels [ '!id' ] [ w . id ] . Target ] ; } ) ;
} catch ( e ) { wbrels = null ; }
2014-05-29 22:30:03 +00:00
if ( wbrels && wbrels . length === 0 ) wbrels = null ;
2014-05-22 12:16:51 +00:00
/* Numbers iOS hack */
2014-02-21 16:41:37 +00:00
var nmode = ( getzipdata ( zip , "xl/worksheets/sheet.xml" , true ) ) ? 1 : 0 ;
for ( i = 0 ; i != props . Worksheets ; ++ i ) {
try {
2014-05-22 12:16:51 +00:00
if ( wbrels ) path = 'xl/' + ( wbrels [ i ] [ 1 ] ) . replace ( /[\/]?xl\// , "" ) ;
else {
2014-05-29 22:30:03 +00:00
path = 'xl/worksheets/sheet' + ( i + 1 - nmode ) + "." + wbext ;
2014-05-22 12:16:51 +00:00
path = path . replace ( /sheet0\./ , "sheet." ) ;
}
2014-02-21 16:41:37 +00:00
relsPath = path . replace ( /^(.*)(\/)([^\/]*)$/ , "$1/_rels/$3.rels" ) ;
2014-05-16 00:33:34 +00:00
sheetRels [ props . SheetNames [ i ] ] = parse _rels ( getzipdata ( zip , relsPath , true ) , path ) ;
2014-04-15 09:04:03 +00:00
sheets [ props . SheetNames [ i ] ] = parse _ws ( getzipdata ( zip , path ) , path , opts , sheetRels [ props . SheetNames [ i ] ] ) ;
2014-02-21 16:41:37 +00:00
} catch ( e ) { if ( opts . WTF ) throw e ; }
2014-02-17 08:44:22 +00:00
}
if ( dir . comments ) parse _comments ( zip , dir . comments , sheets , sheetRels , opts ) ;
out = {
Directory : dir ,
Workbook : wb ,
Props : props ,
Custprops : custprops ,
Deps : deps ,
Sheets : sheets ,
SheetNames : props . SheetNames ,
Strings : strs ,
Styles : styles ,
2014-05-29 22:30:03 +00:00
Themes : themes ,
2014-05-16 00:33:34 +00:00
SSF : SSF . get _table ( )
2014-02-17 08:44:22 +00:00
} ;
if ( opts . bookFiles ) {
2014-05-16 00:33:34 +00:00
out . keys = entries ;
2014-02-21 16:41:37 +00:00
out . files = zip . files ;
2014-02-17 08:44:22 +00:00
}
2014-04-03 22:51:54 +00:00
if ( opts . bookVBA ) {
if ( dir . vba . length > 0 ) out . vbaraw = getzipdata ( zip , dir . vba [ 0 ] , true ) ;
else if ( dir . defaults . bin === 'application/vnd.ms-office.vbaProject' ) out . vbaraw = getzipdata ( zip , 'xl/vbaProject.bin' , true ) ;
}
2014-02-17 08:44:22 +00:00
return out ;
}
2014-05-16 00:33:34 +00:00
function add _rels ( rels , rId , f , type , relobj ) {
if ( ! relobj ) relobj = { } ;
if ( ! rels [ '!id' ] ) rels [ '!id' ] = { } ;
relobj . Id = 'rId' + rId ;
2014-05-16 00:50:55 +00:00
relobj . Type = type ;
2014-05-16 00:33:34 +00:00
relobj . Target = f ;
if ( rels [ '!id' ] [ relobj . Id ] ) throw new Error ( "Cannot rewrite rId " + rId ) ;
rels [ '!id' ] [ relobj . Id ] = relobj ;
rels [ ( '/' + relobj . Target ) . replace ( "//" , "/" ) ] = relobj ;
}
function write _zip ( wb , opts ) {
2014-05-22 12:16:51 +00:00
if ( wb && ! wb . SSF ) {
wb . SSF = SSF . get _table ( ) ;
}
2014-05-16 00:33:34 +00:00
if ( wb && wb . SSF ) {
make _ssf ( SSF ) ; SSF . load _table ( wb . SSF ) ;
opts . revssf = evert ( wb . SSF ) ; opts . revssf [ wb . SSF [ 65535 ] ] = 0 ;
}
opts . rels = { } ; opts . wbrels = { } ;
opts . Strings = [ ] ; opts . Strings . Count = 0 ; opts . Strings . Unique = 0 ;
var wbext = opts . bookType == "xlsb" ? "bin" : "xml" ;
var ct = { workbooks : [ ] , sheets : [ ] , calcchains : [ ] , themes : [ ] , styles : [ ] ,
coreprops : [ ] , extprops : [ ] , custprops : [ ] , strs : [ ] , comments : [ ] , vba : [ ] ,
TODO : [ ] , rels : [ ] , xmlns : "" } ;
fix _write _opts ( opts = opts || { } ) ;
var zip = new jszip ( ) ;
var f = "" , rId = 0 ;
opts . cellXfs = [ ] ;
2014-05-22 12:16:51 +00:00
get _cell _style ( opts . cellXfs , { } , { revssf : { "General" : 0 } } ) ;
2014-05-16 00:33:34 +00:00
f = "docProps/core.xml" ;
zip . file ( f , write _core _props ( wb . Props , opts ) ) ;
ct . coreprops . push ( f ) ;
2014-05-22 12:16:51 +00:00
add _rels ( opts . rels , 2 , f , RELS . CORE _PROPS ) ;
2014-05-16 00:33:34 +00:00
f = "docProps/app.xml" ;
2014-05-22 12:16:51 +00:00
if ( ! wb . Props ) wb . Props = { } ;
2014-05-16 00:33:34 +00:00
wb . Props . SheetNames = wb . SheetNames ;
wb . Props . Worksheets = wb . SheetNames . length ;
zip . file ( f , write _ext _props ( wb . Props , opts ) ) ;
ct . extprops . push ( f ) ;
2014-05-22 12:16:51 +00:00
add _rels ( opts . rels , 3 , f , RELS . EXT _PROPS ) ;
2014-05-16 00:33:34 +00:00
2014-05-29 22:30:03 +00:00
if ( wb . Custprops !== wb . Props && keys ( wb . Custprops || { } ) . length > 0 ) {
2014-05-16 00:33:34 +00:00
f = "docProps/custom.xml" ;
zip . file ( f , write _cust _props ( wb . Custprops , opts ) ) ;
ct . custprops . push ( f ) ;
2014-05-22 12:16:51 +00:00
add _rels ( opts . rels , 4 , f , RELS . CUST _PROPS ) ;
2014-05-16 00:33:34 +00:00
}
f = "xl/workbook." + wbext ;
zip . file ( f , write _wb ( wb , f , opts ) ) ;
ct . workbooks . push ( f ) ;
add _rels ( opts . rels , 1 , f , RELS . WB ) ;
wb . SheetNames . forEach ( function ( s , i ) {
rId = i + 1 ; f = "xl/worksheets/sheet" + rId + "." + wbext ;
zip . file ( f , write _ws ( i , f , opts , wb ) ) ;
ct . sheets . push ( f ) ;
add _rels ( opts . wbrels , rId , "worksheets/sheet" + rId + "." + wbext , RELS . WS ) ;
} ) ;
if ( ( opts . Strings || [ ] ) . length > 0 ) {
f = "xl/sharedStrings." + wbext ;
zip . file ( f , write _sst ( opts . Strings , f , opts ) ) ;
ct . strs . push ( f ) ;
add _rels ( opts . wbrels , ++ rId , "sharedStrings." + wbext , RELS . SST ) ;
}
/* TODO: something more intelligent with themes */
2014-05-16 00:50:55 +00:00
2014-05-22 12:16:51 +00:00
f = "xl/theme/theme1.xml" ;
2014-05-16 00:33:34 +00:00
zip . file ( f , write _theme ( ) ) ;
ct . themes . push ( f ) ;
2014-05-22 12:16:51 +00:00
add _rels ( opts . wbrels , ++ rId , "theme/theme1.xml" , RELS . THEME ) ;
2014-05-16 00:33:34 +00:00
/* TODO: something more intelligent with styles */
2014-05-29 22:30:03 +00:00
f = "xl/styles." + wbext ;
2014-05-16 00:33:34 +00:00
zip . file ( f , write _sty ( wb , f , opts ) ) ;
ct . styles . push ( f ) ;
add _rels ( opts . wbrels , ++ rId , "styles." + wbext , RELS . STY ) ;
zip . file ( "[Content_Types].xml" , write _ct ( ct , opts ) ) ;
zip . file ( '_rels/.rels' , write _rels ( opts . rels ) ) ;
2014-05-29 22:30:03 +00:00
zip . file ( 'xl/_rels/workbook.' + wbext + '.rels' , write _rels ( opts . wbrels ) ) ;
2014-05-16 00:33:34 +00:00
return zip ;
}
function readSync ( data , opts ) {
2014-02-17 08:44:22 +00:00
var zip , d = data ;
2014-05-16 00:33:34 +00:00
var o = opts || { } ;
if ( ! o . type ) o . type = ( typeof Buffer !== 'undefined' && data instanceof Buffer ) ? "buffer" : "base64" ;
switch ( o . type ) {
2014-02-17 08:44:22 +00:00
case "base64" : zip = new jszip ( d , { base64 : true } ) ; break ;
case "binary" : zip = new jszip ( d , { base64 : false } ) ; break ;
2014-05-16 00:33:34 +00:00
case "buffer" : zip = new jszip ( d ) ; break ;
case "file" : zip = new jszip ( d = _fs . readFileSync ( data ) ) ; break ;
default : throw new Error ( "Unrecognized type " + o . type ) ;
2014-02-17 08:44:22 +00:00
}
2014-05-16 00:33:34 +00:00
return parse _zip ( zip , o ) ;
2014-02-17 08:44:22 +00:00
}
2014-05-16 00:33:34 +00:00
function readFileSync ( data , opts ) {
var o = opts || { } ; o . type = 'file' ;
2014-02-17 08:44:22 +00:00
return readSync ( data , o ) ;
}
2014-05-16 00:33:34 +00:00
function writeSync ( wb , opts ) {
var o = opts || { } ;
var z = write _zip ( wb , o ) ;
switch ( o . type ) {
case "base64" : return z . generate ( { type : "base64" } ) ;
case "binary" : return z . generate ( { type : "string" } ) ;
case "buffer" : return z . generate ( { type : "nodebuffer" } ) ;
case "file" : return _fs . writeFileSync ( o . file , z . generate ( { type : "nodebuffer" } ) ) ;
default : throw new Error ( "Unrecognized type " + o . type ) ;
}
}
function writeFileSync ( wb , filename , opts ) {
var o = opts || { } ; o . type = 'file' ;
o . file = filename ;
switch ( o . file . substr ( - 5 ) . toLowerCase ( ) ) {
case '.xlsm' : o . bookType = 'xlsm' ; break ;
case '.xlsb' : o . bookType = 'xlsb' ; break ;
}
return writeSync ( wb , o ) ;
}
2014-05-03 18:51:10 +00:00
function decode _row ( rowstr ) { return Number ( unfix _row ( rowstr ) ) - 1 ; }
function encode _row ( row ) { return "" + ( row + 1 ) ; }
function fix _row ( cstr ) { return cstr . replace ( /([A-Z]|^)([0-9]+)$/ , "$1$$$2" ) ; }
function unfix _row ( cstr ) { return cstr . replace ( /\$([0-9]+)$/ , "$1" ) ; }
2014-02-17 08:44:22 +00:00
2014-05-03 18:51:10 +00:00
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 ; }
2014-02-17 08:44:22 +00:00
function encode _col ( col ) { var s = "" ; for ( ++ col ; col ; col = Math . floor ( ( col - 1 ) / 26 ) ) s = _chr ( ( ( col - 1 ) % 26 ) + 65 ) + s ; return s ; }
2014-05-03 18:51:10 +00:00
function fix _col ( cstr ) { return cstr . replace ( /^([A-Z])/ , "$$$1" ) ; }
function unfix _col ( cstr ) { return cstr . replace ( /^\$([A-Z])/ , "$1" ) ; }
2014-02-17 08:44:22 +00:00
function split _cell ( cstr ) { return cstr . replace ( /(\$?[A-Z]*)(\$?[0-9]*)/ , "$1,$2" ) . split ( "," ) ; }
function decode _cell ( cstr ) { var splt = split _cell ( cstr ) ; return { c : decode _col ( splt [ 0 ] ) , r : decode _row ( splt [ 1 ] ) } ; }
2014-05-03 18:51:10 +00:00
function encode _cell ( cell ) { return encode _col ( cell . c ) + encode _row ( cell . r ) ; }
function fix _cell ( cstr ) { return fix _col ( fix _row ( cstr ) ) ; }
function unfix _cell ( cstr ) { return unfix _col ( unfix _row ( cstr ) ) ; }
2014-02-17 08:44:22 +00:00
function decode _range ( range ) { var x = range . split ( ":" ) . map ( decode _cell ) ; return { s : x [ 0 ] , e : x [ x . length - 1 ] } ; }
2014-05-03 18:51:10 +00:00
function encode _range ( cs , ce ) {
if ( typeof ce === 'undefined' || typeof ce === 'number' ) return encode _range ( cs . s , cs . e ) ;
if ( typeof cs !== 'string' ) cs = encode _cell ( cs ) ; if ( typeof ce !== 'string' ) ce = encode _cell ( ce ) ;
return cs == ce ? cs : cs + ":" + ce ;
}
function format _cell ( cell , v ) {
if ( ! cell || ! cell . t ) return "" ;
if ( typeof cell . w !== 'undefined' ) return cell . w ;
if ( typeof v === 'undefined' ) v = cell . v ;
if ( typeof cell . z !== 'undefined' ) try { return ( cell . w = SSF . format ( cell . z , v ) ) ; } catch ( e ) { }
if ( ! cell . XF ) return v ;
try { return ( cell . w = SSF . format ( cell . XF . ifmt || 0 , v ) ) ; } catch ( e ) { return v ; }
}
2014-02-17 08:44:22 +00:00
2014-05-29 22:30:03 +00:00
function sheet _to _json ( sheet , opts ) {
var val , row , range , header , offset = 1 , r , hdr = { } , isempty , R , C , v ;
2014-02-17 08:44:22 +00:00
var out = [ ] ;
opts = opts || { } ;
if ( ! sheet || ! sheet [ "!ref" ] ) return out ;
2014-05-29 22:30:03 +00:00
range = opts . range || sheet [ "!ref" ] ;
header = opts . header || "" ;
switch ( typeof range ) {
case 'string' : r = decode _range ( range ) ; break ;
case 'number' : r = decode _range ( sheet [ "!ref" ] ) ; r . s . r = range ; break ;
default : r = range ;
}
if ( header ) offset = 0 ;
2014-02-17 08:44:22 +00:00
for ( R = r . s . r , C = r . s . c ; C <= r . e . c ; ++ C ) {
val = sheet [ encode _cell ( { c : C , r : R } ) ] ;
2014-05-29 22:30:03 +00:00
if ( header === "A" ) hdr [ C ] = encode _col ( C ) ;
else if ( header === 1 ) hdr [ C ] = C ;
else if ( Array . isArray ( header ) ) hdr [ C ] = header [ C - r . s . c ] ;
else if ( ! val ) continue ;
else hdr [ C ] = format _cell ( val ) ;
2014-02-17 08:44:22 +00:00
}
2014-05-29 22:30:03 +00:00
for ( R = r . s . r + offset ; R <= r . e . r ; ++ R ) {
2014-02-17 08:44:22 +00:00
isempty = true ;
2014-05-29 22:30:03 +00:00
row = header === 1 ? [ ] : Object . create ( { _ _rowNum _ _ : R } ) ;
2014-02-17 08:44:22 +00:00
for ( C = r . s . c ; C <= r . e . c ; ++ C ) {
val = sheet [ encode _cell ( { c : C , r : R } ) ] ;
if ( ! val || ! val . t ) continue ;
2014-05-03 18:51:10 +00:00
v = ( val || { } ) . v ;
switch ( val . t ) {
case 'e' : continue ;
case 's' : case 'str' : break ;
case 'b' : case 'n' : break ;
2014-02-17 08:44:22 +00:00
default : throw 'unrecognized type ' + val . t ;
}
2014-05-03 18:51:10 +00:00
if ( typeof v !== 'undefined' ) {
row [ hdr [ C ] ] = opts . raw ? v || val . v : format _cell ( val , v ) ;
isempty = false ;
}
2014-02-17 08:44:22 +00:00
}
if ( ! isempty ) out . push ( row ) ;
}
return out ;
}
2014-05-29 22:30:03 +00:00
function sheet _to _row _object _array ( sheet , opts ) { if ( ! opts ) opts = { } ; delete opts . range ; return sheet _to _json ( sheet , opts ) ; }
2014-02-17 08:44:22 +00:00
function sheet _to _csv ( sheet , opts ) {
2014-02-26 19:30:32 +00:00
var out = [ ] , txt = "" ;
2014-02-17 08:44:22 +00:00
opts = opts || { } ;
2014-02-26 19:30:32 +00:00
if ( ! sheet || ! sheet [ "!ref" ] ) return "" ;
2014-05-03 18:51:10 +00:00
var r = decode _range ( sheet [ "!ref" ] ) ;
2014-02-17 08:44:22 +00:00
var fs = opts . FS || "," , rs = opts . RS || "\n" ;
for ( var R = r . s . r ; R <= r . e . r ; ++ R ) {
var row = [ ] ;
for ( var C = r . s . c ; C <= r . e . c ; ++ C ) {
2014-05-03 18:51:10 +00:00
var val = sheet [ encode _cell ( { c : C , r : R } ) ] ;
2014-02-17 08:44:22 +00:00
if ( ! val ) { row . push ( "" ) ; continue ; }
2014-05-03 18:51:10 +00:00
txt = String ( format _cell ( val ) ) ;
2014-02-17 08:44:22 +00:00
if ( txt . indexOf ( fs ) !== - 1 || txt . indexOf ( rs ) !== - 1 || txt . indexOf ( '"' ) !== - 1 )
txt = "\"" + txt . replace ( /"/g , '""' ) + "\"" ;
row . push ( txt ) ;
}
2014-02-26 19:30:32 +00:00
out . push ( row . join ( fs ) ) ;
2014-02-17 08:44:22 +00:00
}
2014-02-26 19:30:32 +00:00
return out . join ( rs ) + ( out . length ? rs : "" ) ;
2014-02-17 08:44:22 +00:00
}
var make _csv = sheet _to _csv ;
function get _formulae ( ws ) {
var cmds = [ ] ;
for ( var y in ws ) if ( y [ 0 ] !== '!' && ws . hasOwnProperty ( y ) ) {
var x = ws [ y ] ;
var val = "" ;
if ( x . f ) val = x . f ;
else if ( typeof x . w !== 'undefined' ) val = "'" + x . w ;
else if ( typeof x . v === 'undefined' ) continue ;
else val = x . v ;
cmds . push ( y + "=" + val ) ;
}
return cmds ;
}
2014-05-03 18:51:10 +00:00
var utils = {
2014-02-17 08:44:22 +00:00
encode _col : encode _col ,
encode _row : encode _row ,
encode _cell : encode _cell ,
encode _range : encode _range ,
decode _col : decode _col ,
decode _row : decode _row ,
split _cell : split _cell ,
decode _cell : decode _cell ,
decode _range : decode _range ,
sheet _to _csv : sheet _to _csv ,
make _csv : sheet _to _csv ,
2014-05-29 22:30:03 +00:00
make _json : sheet _to _json ,
2014-02-17 08:44:22 +00:00
get _formulae : get _formulae ,
2014-05-03 18:51:10 +00:00
format _cell : format _cell ,
2014-05-29 22:30:03 +00:00
sheet _to _json : sheet _to _json ,
2014-02-17 08:44:22 +00:00
sheet _to _row _object _array : sheet _to _row _object _array
} ;
2014-05-16 00:33:34 +00:00
XLSX . parseZip = parse _zip ;
2014-04-15 09:04:03 +00:00
XLSX . read = readSync ;
XLSX . readFile = readFileSync ;
2014-05-16 00:33:34 +00:00
XLSX . write = writeSync ;
XLSX . writeFile = writeFileSync ;
2014-05-03 18:51:10 +00:00
XLSX . utils = utils ;
2014-04-15 09:04:03 +00:00
XLSX . SSF = SSF ;
} ) ( typeof exports !== 'undefined' ? exports : XLSX ) ;