2016-12-31 08:20:45 +00:00
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
2017-03-10 23:39:17 +00:00
var XLSX = { } ; ( function make _xlsx ( XLSX ) { XLSX . version = "0.9.1" ; var current _codepage = 1200 , current _cptable ; if ( typeof module !== "undefined" && typeof require !== "undefined" ) { if ( typeof cptable === "undefined" ) cptable = require ( "./dist/cpexcel.js" ) ; current _cptable = cptable [ current _codepage ] } function reset _cp ( ) { set _cp ( 1200 ) } var set _cp = function ( cp ) { current _codepage = cp } ; function char _codes ( data ) { var o = [ ] ; for ( var i = 0 , len = data . length ; i < len ; ++ i ) o [ i ] = data . charCodeAt ( i ) ; return o } var debom = function ( data ) { var c1 = data . charCodeAt ( 0 ) , c2 = data . charCodeAt ( 1 ) ; if ( c1 == 255 && c2 == 254 ) return data . substr ( 2 ) ; if ( c1 == 254 && c2 == 255 ) return data . substr ( 2 ) ; if ( c1 == 65279 ) return data . substr ( 1 ) ; return data } ; var _getchar = function _gc1 ( x ) { return String . fromCharCode ( x ) } ; if ( typeof cptable !== "undefined" ) { set _cp = function ( cp ) { current _codepage = cp ; current _cptable = cptable [ cp ] } ; debom = function ( data ) { if ( data . charCodeAt ( 0 ) === 255 && data . charCodeAt ( 1 ) === 254 ) { return cptable . utils . decode ( 1200 , char _codes ( data . substr ( 2 ) ) ) } return data } ; _getchar = function _gc2 ( x ) { if ( current _codepage === 1200 ) return String . fromCharCode ( x ) ; return cptable . utils . decode ( current _codepage , [ x & 255 , x >> 8 ] ) [ 0 ] } } var Base64 = function make _b64 ( ) { var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ; return { encode : function ( input , utf8 ) { var o = "" ; var c1 , c2 , c3 , e1 , e2 , e3 , e4 ; for ( var i = 0 ; i < input . length ; ) { c1 = input . charCodeAt ( i ++ ) ; c2 = input . charCodeAt ( i ++ ) ; c3 = input . charCodeAt ( i ++ ) ; e1 = c1 >> 2 ; e2 = ( c1 & 3 ) << 4 | c2 >> 4 ; e3 = ( c2 & 15 ) << 2 | c3 >> 6 ; e4 = c3 & 63 ; if ( isNaN ( c2 ) ) { e3 = e4 = 64 } else if ( isNaN ( c3 ) ) { e4 = 64 } o += map . charAt ( e1 ) + map . charAt ( e2 ) + map . charAt ( e3 ) + map . charAt ( e4 ) } return o } , decode : function b64 _decode ( input , utf8 ) { var o = "" ; var c1 , c2 , c3 ; var e1 , e2 , e3 , e4 ; input = input . replace ( /[^A-Za-z0-9\+\/\=]/g , "" ) ; for ( var i = 0 ; i < input . length ; ) { e1 = map . indexOf ( input . charAt ( i ++ ) ) ; e2 = map . indexOf ( input . charAt ( i ++ ) ) ; e3 = map . indexOf ( input . charAt ( i ++ ) ) ; e4 = map . indexOf ( input . charAt ( i ++ ) ) ; c1 = e1 << 2 | e2 >> 4 ; c2 = ( e2 & 15 ) << 4 | e3 >> 2 ; c3 = ( e3 & 3 ) << 6 | e4 ; o += String . fromCharCode ( c1 ) ; if ( e3 != 64 ) { o += String . fromCharCode ( c2 ) } if ( e4 != 64 ) { o += String . fromCharCode ( c3 ) } } return o } } } ( ) ; var has _buf = typeof Buffer !== "undefined" ; function new _raw _buf ( len ) { return new ( has _buf ? Buffer : Array ) ( len ) } function s2a ( s ) { if ( has _buf ) return new Buffer ( s , "binary" ) ; return s . split ( "" ) . map ( function ( x ) { return x . charCodeAt ( 0 ) & 255 } ) } var bconcat = function ( bufs ) { return [ ] . concat . apply ( [ ] , bufs ) } ; var chr0 = /\u0000/g , chr1 = /[\u0001-\u0006]/ ; var SSF = { } ; var make _ssf = function make _ssf ( SSF ) { SSF . version = "0.8.1" ; function _strrev ( x ) { var o = "" , i = x . length - 1 ; while ( i >= 0 ) o += x . charAt ( i -- ) ; return o } function fill ( c , l ) { var o = "" ; while ( o . length < l ) o += c ; return o } function pad0 ( v , d ) { var t = "" + v ; return t . length >= d ? t : fill ( "0" , d - t . length ) + t } function pad _ ( v , d ) { var t = "" + v ; return t . length >= d ? t : fill ( " " , d - t . length ) + t } function rpad _ ( v , d ) { var t = "" + v ; return t . length >= d ? t : t + fill ( " " , d - t . length ) } function pad0r1 ( v , d ) { var t = "" + Math . round ( v ) ; return t . length >= d ? t : fill ( "0" , d - t . length ) + t } function pad0r2 ( v , d ) { var t = "" + v ; return t . length >= d ? t : fill ( "0" , d - t . length ) + t } var p2 _32 = Math . pow ( 2 , 32 ) ; function pad0r ( v , d ) { if ( v > p2 _32 || v < - p2 _32 ) return pad0r1 ( v , d ) ; var i = Math . round ( v ) ; return pad0r2 ( i , d ) } function isgeneral ( s , i ) { return s . length >= 7 + i && ( s . charCodeAt ( i ) | 32 ) === 103 && ( s . charCodeAt ( i + 1 ) | 32 ) === 101 && ( s . charCodeAt ( i + 2 ) | 32 ) === 110 && ( s . charCodeAt ( i + 3 ) | 32 ) === 101 && ( s . charCodeAt ( i + 4 ) | 32 ) === 114 && ( s . charCodeAt ( i + 5 ) | 32 ) === 97 && ( s . charCodeAt ( i + 6 ) | 32 ) === 108 } var opts _fmt = [ [ "date1904" , 0 ] , [ "output" , "" ] , [ "WTF" , false ] ] ; function fixopts ( o ) { for ( var y = 0 ; y != opts _fmt . length ; ++ y ) if ( o [ opts _fmt [ y ] [ 0 ] ] === undefined ) o [ opts _fmt [ y ] [ 0 ] ] = opts _fmt [ y ] [ 1 ] } 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" ] , [
var buf , buf _chain ; if ( ! chkd ) chkd = new Array ( sl ) ; var modulus = ssz - 1 , j , jj ; buf = [ ] ; buf _chain = [ ] ; for ( j = start ; j >= 0 ; ) { chkd [ j ] = true ; buf [ buf . length ] = j ; buf _chain . push ( sectors [ j ] ) ; var addr = fat _addrs [ Math . floor ( j * 4 / ssz ) ] ; jj = j * 4 & modulus ; if ( ssz < 4 + jj ) throw "FAT boundary crossed: " + j + " 4 " + ssz ; if ( ! sectors [ addr ] ) break ; j = _ _readInt32LE ( sectors [ addr ] , jj ) } return { nodes : buf , data : _ _toBuffer ( [ buf _chain ] ) } } function make _sector _list ( sectors , dir _start , fat _addrs , ssz ) { var sl = sectors . length , sector _list = new Array ( sl ) ; var chkd = new Array ( sl ) , buf , buf _chain ; var modulus = ssz - 1 , i , j , k , jj ; for ( i = 0 ; i < sl ; ++ i ) { buf = [ ] ; k = i + dir _start ; if ( k >= sl ) k -= sl ; if ( chkd [ k ] === true ) continue ; buf _chain = [ ] ; for ( j = k ; j >= 0 ; ) { chkd [ j ] = true ; buf [ buf . length ] = j ; buf _chain . push ( sectors [ j ] ) ; var addr = fat _addrs [ Math . floor ( j * 4 / ssz ) ] ; jj = j * 4 & modulus ; if ( ssz < 4 + jj ) throw "FAT boundary crossed: " + j + " 4 " + ssz ; if ( ! sectors [ addr ] ) break ; j = _ _readInt32LE ( sectors [ addr ] , jj ) } sector _list [ k ] = { nodes : buf , data : _ _toBuffer ( [ buf _chain ] ) } } return sector _list } function read _directory ( dir _start , sector _list , sectors , Paths , nmfs , files , FileIndex ) { var blob ; var minifat _store = 0 , pl = Paths . length ? 2 : 0 ; var sector = sector _list [ dir _start ] . data ; var i = 0 , namelen = 0 , name , o , ctime , mtime ; for ( ; i < sector . length ; i += 128 ) { blob = sector . slice ( i , i + 128 ) ; prep _blob ( blob , 64 ) ; namelen = blob . read _shift ( 2 ) ; if ( namelen === 0 ) continue ; name = _ _utf16le ( blob , 0 , namelen - pl ) ; Paths . push ( name ) ; o = { name : name , type : blob . read _shift ( 1 ) , color : blob . read _shift ( 1 ) , L : blob . read _shift ( 4 , "i" ) , R : blob . read _shift ( 4 , "i" ) , C : blob . read _shift ( 4 , "i" ) , clsid : blob . read _shift ( 16 ) , state : blob . read _shift ( 4 , "i" ) } ; ctime = blob . read _shift ( 2 ) + blob . read _shift ( 2 ) + blob . read _shift ( 2 ) + blob . read _shift ( 2 ) ; if ( ctime !== 0 ) { o . ctime = ctime ; o . ct = read _date ( blob , blob . l - 8 ) } mtime = blob . read _shift ( 2 ) + blob . read _shift ( 2 ) + blob . read _shift ( 2 ) + blob . read _shift ( 2 ) ; if ( mtime !== 0 ) { o . mtime = mtime ; o . mt = read _date ( blob , blob . l - 8 ) } o . start = blob . read _shift ( 4 , "i" ) ; o . size = blob . read _shift ( 4 , "i" ) ; if ( o . type === 5 ) { minifat _store = o . start ; if ( nmfs > 0 && minifat _store !== ENDOFCHAIN ) sector _list [ minifat _store ] . name = "!StreamData" } else if ( o . size >= 4096 ) { o . storage = "fat" ; if ( sector _list [ o . start ] === undefined ) sector _list [ o . start ] = get _sector _list ( sectors , o . start , sector _list . fat _addrs , sector _list . ssz ) ; sector _list [ o . start ] . name = o . name ; o . content = sector _list [ o . start ] . data . slice ( 0 , o . size ) ; prep _blob ( o . content , 0 ) } else { o . storage = "minifat" ; if ( minifat _store !== ENDOFCHAIN && o . start !== ENDOFCHAIN ) { o . content = sector _list [ minifat _store ] . data . slice ( o . start * MSSZ , o . start * MSSZ + o . size ) ; prep _blob ( o . content , 0 ) } } files [ name ] = o ; FileIndex . push ( o ) } } function read _date ( blob , offset ) { return new Date ( ( _ _readUInt32LE ( blob , offset + 4 ) / 1e7 * Math . pow ( 2 , 32 ) + _ _readUInt32LE ( blob , offset ) / 1e7 - 11644473600 ) * 1e3 ) } var fs ; function readFileSync ( filename , options ) { if ( fs === undefined ) fs = require ( "fs" ) ; return parse ( fs . readFileSync ( filename ) , options ) } function readSync ( blob , options ) { switch ( options !== undefined && options . type !== undefined ? options . type : "base64" ) { case "file" : return readFileSync ( blob , options ) ; case "base64" : return parse ( s2a ( Base64 . decode ( blob ) ) , options ) ; case "binary" : return parse ( s2a ( blob ) , options ) } return parse ( blob ) } var MSSZ = 64 ; var ENDOFCHAIN = - 2 ; var HEADER _SIGNATURE = "d0cf11e0a1b11ae1" ; var HEADER _CLSID = "00000000000000000000000000000000" ; var consts = { MAXREGSECT : - 6 , DIFSECT : - 4 , FATSECT : - 3 , ENDOFCHAIN : ENDOFCHAIN , FREESECT : - 1 , HEADER _SIGNATURE : HEADER _SIGNATURE , HEADER _MINOR _VERSION : "3e00" , MAXREGSID : - 6 , NOSTREAM : - 1 , HEADER _CLSID : HEADER _CLSID , EntryTypes : [ "unknown" , "storage" , "stream" , "lockbytes" , "property" , "root" ] } ; exports . read = readSync ; exports . parse = parse ; exports . utils = { ReadShift : ReadShift , CheckField : CheckField , prep _blob : prep _blob , bconcat : bconcat , consts : consts } ; return exports } ( ) ; if ( typeof require !== "undefined" && typeof module !== "undefined" && typeof DO _NOT _EXPORT _CFB === "undefined" ) { module . exports = CFB } function isval ( x ) { return x !== undefined && x !== null } function keys ( o ) { return Object . keys ( o ) } function evert _key ( obj , key ) { var o = [ ] , K = keys ( obj ) ; for ( var i = 0 ; i !== K . length ; ++ i ) o [ obj [ K [ i ] ] [ key ] ] = K [ i ] ; return o } function evert ( obj ) { var o = [ ] , K = keys ( obj ) ; for ( var i = 0 ; i !== K . length ; ++ i ) o [ obj [ K [ i ] ] ] = K [ i ] ; return o } function evert _num ( obj ) { var o = [ ] , K = keys ( obj ) ; for ( var i = 0 ; i !== K . length ; ++ i ) o [
"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" : "TODO" , "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml" : "TODO" , "application/vnd.ms-excel.queryTable" : "TODO" , "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml" : "TODO" , "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" , "application/vnd.ms-excel.tableSingleCells" : "TODO" , "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml" : "TODO" , "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" , "application/vnd.ms-excel.wsSortMap" : "TODO" , "application/vnd.ms-excel.table" : "TODO" , "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml" : "TODO" , "application/vnd.openxmlformats-officedocument.theme+xml" : "themes" , "application/vnd.ms-excel.Timeline+xml" : "TODO" , "application/vnd.ms-excel.TimelineCache+xml" : "TODO" , "application/vnd.ms-office.vbaProject" : "vba" , "application/vnd.ms-office.vbaProjectSignature" : "vba" , "application/vnd.ms-office.volatileDependencies" : "TODO" , "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml" : "TODO" , "application/vnd.ms-excel.controlproperties+xml" : "TODO" , "application/vnd.openxmlformats-officedocument.model+data" : "TODO" , "application/vnd.ms-excel.Survey+xml" : "TODO" , "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" , "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 : { 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 : { 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 _arr ( ct2type ) ; XMLNS . CT = "http://schemas.openxmlformats.org/package/2006/content-types" ; function parse _ct ( data , opts ) { var ct = { workbooks : [ ] , sheets : [ ] , calcchains : [ ] , themes : [ ] , styles : [ ] , coreprops : [ ] , extprops : [ ] , custprops : [ ] , strs : [ ] , comments : [ ] , vba : [ ] , TODO : [ ] , rels : [ ] , xmlns : "" } ; if ( ! data || ! data . match ) return ct ; var ctext = { } ; ( data . match ( tagregex ) || [ ] ) . forEach ( function ( x ) { var y = parsexmltag ( x ) ; switch ( y [ 0 ] . replace ( nsregex , "<" ) ) { case "<?xml" : break ; case "<Types" : ct . xmlns = y [ "xmlns" + ( y [ 0 ] . match ( /<(\w+):/ ) || [ "" , "" ] ) [ 1 ] ] ; break ; case "<Default" : ctext [ y . Extension ] = y . ContentType ; break ; case "<Override" : if ( ct [ ct2type [ y . ContentType ] ] !== undefined ) ct [ ct2type [ y . ContentType ] ] . p
var lastcol = blob . read _shift ( 2 ) ; if ( rkrecs . length != lastcol - col + 1 ) throw "MulRK length mismatch" ; return { r : rw , c : col , C : lastcol , rkrec : rkrecs } } function parse _CellStyleXF ( blob , length , style ) { var o = { } ; var a = blob . read _shift ( 4 ) , b = blob . read _shift ( 4 ) ; var c = blob . read _shift ( 4 ) , d = blob . read _shift ( 2 ) ; o . patternType = XLSFillPattern [ c >> 26 ] ; o . icvFore = d & 127 ; o . icvBack = d >> 7 & 127 ; return o } function parse _CellXF ( blob , length ) { return parse _CellStyleXF ( blob , length , 0 ) } function parse _StyleXF ( blob , length ) { return parse _CellStyleXF ( blob , length , 1 ) } function parse _XF ( blob , length ) { var o = { } ; o . ifnt = blob . read _shift ( 2 ) ; o . ifmt = blob . read _shift ( 2 ) ; o . flags = blob . read _shift ( 2 ) ; o . fStyle = o . flags >> 2 & 1 ; length -= 6 ; o . data = parse _CellStyleXF ( blob , length , o . fStyle ) ; return o } function parse _Guts ( blob , length ) { blob . l += 4 ; var out = [ blob . read _shift ( 2 ) , blob . read _shift ( 2 ) ] ; if ( out [ 0 ] !== 0 ) out [ 0 ] -- ; if ( out [ 1 ] !== 0 ) out [ 1 ] -- ; if ( out [ 0 ] > 7 || out [ 1 ] > 7 ) throw "Bad Gutters: " + out . join ( "|" ) ; return out } function parse _BoolErr ( blob , length , opts ) { var cell = parse _XLSCell ( blob , 6 ) ; if ( opts . biff == 2 ) ++ blob . l ; var val = parse _Bes ( blob , 2 ) ; cell . val = val ; cell . t = val === true || val === false ? "b" : "e" ; return cell } function parse _Number ( blob , length ) { var cell = parse _XLSCell ( blob , 6 ) ; var xnum = parse _Xnum ( blob , 8 ) ; cell . val = xnum ; return cell } var parse _XLHeaderFooter = parse _OptXLUnicodeString ; function parse _SupBook ( blob , length , opts ) { var end = blob . l + length ; var ctab = blob . read _shift ( 2 ) ; var cch = blob . read _shift ( 2 ) ; var virtPath ; if ( cch >= 1 && cch <= 255 ) virtPath = parse _XLUnicodeStringNoCch ( blob , cch ) ; var rgst = blob . read _shift ( end - blob . l ) ; opts . sbcch = cch ; return [ cch , ctab , virtPath , rgst ] } function parse _ExternName ( blob , length , opts ) { var flags = blob . read _shift ( 2 ) ; var body ; var o = { fBuiltIn : flags & 1 , fWantAdvise : flags >>> 1 & 1 , fWantPict : flags >>> 2 & 1 , fOle : flags >>> 3 & 1 , fOleLink : flags >>> 4 & 1 , cf : flags >>> 5 & 1023 , fIcon : flags >>> 15 & 1 } ; if ( opts . sbcch === 14849 ) body = parse _AddinUdf ( blob , length - 2 , opts ) ; o . body = body || blob . read _shift ( length - 2 ) ; return o } function parse _Lbl ( blob , length , opts ) { var target = blob . l + length ; var flags = blob . read _shift ( 2 ) ; var chKey = blob . read _shift ( 1 ) ; var cch = blob . read _shift ( 1 ) ; var cce = blob . read _shift ( opts && opts . biff == 2 ? 1 : 2 ) ; if ( ! opts || opts . biff >= 5 ) { blob . l += 2 ; var itab = blob . read _shift ( 2 ) ; blob . l += 4 } var name = parse _XLUnicodeStringNoCch ( blob , cch , opts ) ; var npflen = target - blob . l ; if ( opts && opts . biff == 2 ) -- npflen ; var rgce = target == blob . l || cce == 0 ? [ ] : parse _NameParsedFormula ( blob , npflen , opts , cce ) ; return { chKey : chKey , Name : name , rgce : rgce } } function parse _ExternSheet ( blob , length , opts ) { if ( opts . biff < 8 ) return parse _ShortXLUnicodeString ( blob , length , opts ) ; var o = parslurp2 ( blob , length , parse _XTI ) ; var oo = [ ] ; if ( opts . sbcch === 1025 ) { for ( var i = 0 ; i != o . length ; ++ i ) oo . push ( opts . snames [ o [ i ] [ 1 ] ] ) ; return oo } else return o } function parse _ShrFmla ( blob , length , opts ) { var ref = parse _RefU ( blob , 6 ) ; blob . l ++ ; var cUse = blob . read _shift ( 1 ) ; length -= 8 ; return [ parse _SharedParsedFormula ( blob , length , opts ) , cUse ] } function parse _Array ( blob , length , opts ) { var ref = parse _Ref ( blob , 6 ) ; switch ( opts . biff ) { case 2 : blob . l ++ ; length -= 7 ; break ; case 3 : case 4 : blob . l += 2 ; length -= 8 ; break ; default : blob . l += 6 ; length -= 12 } return [ ref , parse _ArrayParsedFormula ( blob , length , opts , ref ) ] } function parse _MTRSettings ( blob , length ) { var fMTREnabled = blob . read _shift ( 4 ) !== 0 ; var fUserSetThreadCount = blob . read _shift ( 4 ) !== 0 ; var cUserThreadCount = blob . read _shift ( 4 ) ; return [ fMTREnabled , fUserSetThreadCount , cUserThreadCount ] } function parse _NoteSh ( blob , length , opts ) { if ( opts . biff < 8 ) return ; var row = blob . read _shift ( 2 ) , col = blob . read _shift ( 2 ) ; var flags = blob . read _shift ( 2 ) , idObj = blob . read _shift ( 2 ) ; var stAuthor = parse _XLUnicodeString2 ( blob , 0 , opts ) ; if ( opts . biff < 8 ) blob . read _shift ( 1 ) ; return [ { r : row , c : col } , stAuthor , idObj , flags ] } function parse _Note ( blob , length , opts ) { return parse _NoteSh ( blob , length , opts ) } function parse _MergeCells ( blob , length ) { var merges = [ ] ; var cmcs = blob . read _shift ( 2 ) ; while ( cmcs -- ) merges . push ( parse _Ref8U ( blob , length ) ) ; return merges } function parse _Obj ( blob , length ) { var cmo = parse _FtCmo ( blob , 22 ) ; var fts = parse _FtArray ( blob , length - 22 , cmo [ 1 ] ) ; return { cmo : cmo , ft : fts } } function parse _TxO ( blob , length , opts ) { var s = blob . l ; var texts = "" ; try { blob . l += 4 ; var ot = ( opts . lastobj || { cmo : [ 0 , 0 ] } ) . cmo [ 1 ] ; var controlInfo ; if ( [ 0 , 5 , 7 , 11 , 12 , 14 ] .
o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) } return o . join ( "" ) } function parse _BrtFmt ( data , length ) { var ifmt = data . read _shift ( 2 ) ; var stFmtCode = parse _XLWideString ( data , length - 2 ) ; return [ ifmt , stFmtCode ] } function parse _BrtFont ( data , length ) { var out = { flags : { } } ; out . dyHeight = data . read _shift ( 2 ) ; out . grbit = parse _FontFlags ( data , 2 ) ; out . bls = data . read _shift ( 2 ) ; out . sss = data . read _shift ( 2 ) ; out . uls = data . read _shift ( 1 ) ; out . bFamily = data . read _shift ( 1 ) ; out . bCharSet = data . read _shift ( 1 ) ; data . l ++ ; out . brtColor = parse _BrtColor ( data , 8 ) ; out . bFontScheme = data . read _shift ( 1 ) ; out . name = parse _XLWideString ( data , length - 21 ) ; out . flags . Bold = out . bls === 700 ; 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 & 2 ; out . flags . Sup = out . sss & 1 ; return out } 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 } } function parse _sty _bin ( data , opts ) { styles . NumberFmt = [ ] ; for ( var y in SSF . _table ) styles . NumberFmt [ y ] = SSF . _table [ y ] ; styles . CellXf = [ ] ; var state = "" ; var pass = false ; recordhopper ( data , function hopper _sty ( val , R , RT ) { switch ( R . n ) { case "BrtFmt" : styles . NumberFmt [ val [ 0 ] ] = val [ 1 ] ; SSF . load ( val [ 1 ] , val [ 0 ] ) ; break ; case "BrtFont" : break ; case "BrtKnownFonts" : break ; case "BrtFill" : break ; case "BrtBorder" : break ; case "BrtXF" : if ( state === "CELLXFS" ) { styles . CellXf . push ( val ) } break ; case "BrtStyle" : break ; case "BrtDXF" : break ; case "BrtMRUColor" : break ; case "BrtIndexedColor" : break ; 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 ) } } ) ; return styles } function write _sty _bin ( data , opts ) { var ba = buf _array ( ) ; write _record ( ba , "BrtBeginStyleSheet" ) ; write _record ( ba , "BrtEndStyleSheet" ) ; return ba . end ( ) } RELS . THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" ; function parse _clrScheme ( t , opts ) { themes . themeElements . clrScheme = [ ] ; var color = { } ; ( t [ 0 ] . match ( tagregex ) || [ ] ) . forEach ( function ( x ) { var y = parsexmltag ( x ) ; switch ( y [ 0 ] ) { case "<a:clrScheme" : case "</a:clrScheme>" : break ; case "<a:srgbClr" : color . rgb = y . val ; break ; case "<a:sysClr" : color . rgb = y . lastClr ; break ; case "<a:dk1>" : case "</a:dk1>" : case "<a:dk2>" : case "</a:dk2>" : case "<a:lt1>" : case "</a:lt1>" : case "<a:lt2>" : case "</a:lt2>" : case "<a:accent1>" : case "</a:accent1>" : case "<a:accent2>" : case "</a:accent2>" : case "<a:accent3>" : case "</a:accent3>" : case "<a:accent4>" : case "</a:accent4>" : case "<a:accent5>" : case "</a:accent5>" : case "<a:accent6>" : case "</a:accent6>" : case "<a:hlink>" : ca
44 : { n : "PtgRefN" , f : parse _PtgRefN } , 45 : { n : "PtgAreaN" , f : parse _PtgAreaN } , 57 : { n : "PtgNameX" , f : parse _PtgNameX } , 58 : { n : "PtgRef3d" , f : parse _PtgRef3d } , 59 : { n : "PtgArea3d" , f : parse _PtgArea3d } , 60 : { n : "PtgRefErr3d" , f : parse _PtgRefErr3d } , 61 : { n : "PtgAreaErr3d" , f : parse _PtgAreaErr3d } , 255 : { } } ; var PtgDupes = { 64 : 32 , 96 : 32 , 65 : 33 , 97 : 33 , 66 : 34 , 98 : 34 , 67 : 35 , 99 : 35 , 68 : 36 , 100 : 36 , 69 : 37 , 101 : 37 , 70 : 38 , 102 : 38 , 71 : 39 , 103 : 39 , 72 : 40 , 104 : 40 , 73 : 41 , 105 : 41 , 74 : 42 , 106 : 42 , 75 : 43 , 107 : 43 , 76 : 44 , 108 : 44 , 77 : 45 , 109 : 45 , 89 : 57 , 121 : 57 , 90 : 58 , 122 : 58 , 91 : 59 , 123 : 59 , 92 : 60 , 124 : 60 , 93 : 61 , 125 : 61 } ; ( function ( ) { for ( var y in PtgDupes ) PtgTypes [ y ] = PtgTypes [ PtgDupes [ y ] ] } ) ( ) ; var Ptg18 = { } ; var Ptg19 = { 1 : { n : "PtgAttrSemi" , f : parse _PtgAttrSemi } , 2 : { n : "PtgAttrIf" , f : parse _PtgAttrIf } , 4 : { n : "PtgAttrChoose" , f : parse _PtgAttrChoose } , 8 : { n : "PtgAttrGoto" , f : parse _PtgAttrGoto } , 16 : { n : "PtgAttrSum" , f : parse _PtgAttrSum } , 32 : { n : "PtgAttrBaxcel" , f : parse _PtgAttrBaxcel } , 64 : { n : "PtgAttrSpace" , f : parse _PtgAttrSpace } , 65 : { n : "PtgAttrSpaceSemi" , f : parse _PtgAttrSpaceSemi } , 128 : { n : "PtgAttrIfError" , f : parse _PtgAttrIfError } , 255 : { } } ; function parse _Formula ( blob , length , opts ) { var end = blob . l + length ; var cell = parse _XLSCell ( blob , 6 ) ; if ( opts . biff == 2 ) ++ blob . l ; var val = parse _FormulaValue ( blob , 8 ) ; var flags = blob . read _shift ( 1 ) ; if ( opts . biff != 2 ) { blob . read _shift ( 1 ) ; if ( opts . biff >= 5 ) { var chn = blob . read _shift ( 4 ) } } var cbf = parse _XLSCellParsedFormula ( blob , end - blob . l , opts ) ; return { cell : cell , val : val [ 0 ] , formula : cbf , shared : flags >> 3 & 1 , tt : val [ 1 ] } } function parse _FormulaValue ( blob ) { var b ; if ( _ _readUInt16LE ( blob , blob . l + 6 ) !== 65535 ) return [ parse _Xnum ( blob ) , "n" ] ; switch ( blob [ blob . l ] ) { case 0 : blob . l += 8 ; return [ "String" , "s" ] ; case 1 : b = blob [ blob . l + 2 ] === 1 ; blob . l += 8 ; return [ b , "b" ] ; case 2 : b = blob [ blob . l + 2 ] ; blob . l += 8 ; return [ b , "e" ] ; case 3 : blob . l += 8 ; return [ "" , "s" ] } return [ ] } function parse _RgbExtra ( blob , length , rgce , opts ) { if ( opts . biff < 8 ) return parsenoop ( blob , length ) ; var target = blob . l + length ; var o = [ ] ; for ( var i = 0 ; i !== rgce . length ; ++ i ) { switch ( rgce [ i ] [ 0 ] ) { case "PtgArray" : rgce [ i ] [ 1 ] = parse _PtgExtraArray ( blob , 0 , opts ) ; o . push ( rgce [ i ] [ 1 ] ) ; break ; case "PtgMemArea" : rgce [ i ] [ 2 ] = parse _PtgExtraMem ( blob , rgce [ i ] [ 1 ] ) ; o . push ( rgce [ i ] [ 2 ] ) ; break ; case "PtgExp" : if ( opts && opts . biff == 12 ) { rgce [ i ] [ 1 ] [ 1 ] = blob . read _shift ( 4 ) ; o . push ( rgce [ i ] [ 1 ] ) } break ; default : break } } length = target - blob . l ; if ( length !== 0 ) o . push ( parsenoop ( blob , length ) ) ; return o } function parse _NameParsedFormula ( blob , length , opts , cce ) { var target = blob . l + length ; var rgce = parse _Rgce ( blob , cce , opts ) ; var rgcb ; if ( target !== blob . l ) rgcb = parse _RgbExtra ( blob , target - blob . l , rgce , opts ) ; return [ rgce , rgcb ] } function parse _XLSCellParsedFormula ( blob , length , opts ) { var target = blob . l + length , len = opts . biff == 2 ? 1 : 2 ; var rgcb , cce = blob . read _shift ( len ) ; if ( cce == 65535 ) return [ [ ] , parsenoop ( blob , length - 2 ) ] ; var rgce = parse _Rgce ( blob , cce , opts ) ; if ( length !== cce + len ) rgcb = parse _RgbExtra ( blob , length - cce - len , rgce , opts ) ; return [ rgce , rgcb ] } function parse _SharedParsedFormula ( blob , length , opts ) { var target = blob . l + length ; var rgcb , cce = blob . read _shift ( 2 ) ; var rgce = parse _Rgce ( blob , cce , opts ) ; if ( cce == 65535 ) return [ [ ] , parsenoop ( blob , length - 2 ) ] ; if ( length !== cce + 2 ) rgcb = parse _RgbExtra ( blob , target - cce - 2 , rgce , opts ) ; return [ rgce , rgcb ] } function parse _ArrayParsedFormula ( blob , length , opts , ref ) { var target = blob . l + length , len = opts . biff == 2 ? 1 : 2 ; var rgcb , cce = blob . read _shift ( len ) ; if ( cce == 65535 ) return [ [ ] , parsenoop ( blob , length - 2 ) ] ; var rgce = parse _Rgce ( blob , cce , opts ) ; if ( length !== cce + len ) rgcb = parse _RgbExtra ( blob , length - cce - len , rgce , opts ) ; return [ rgce , rgcb ] } function parse _Rgce ( blob , length , opts ) { var target = blob . l + length ; var R , id , ptgs = [ ] ; while ( target != blob . l ) { length = target - blob . l ; id = blob [ blob . l ] ; R = PtgTypes [ id ] ; if ( id === 24 || id === 25 ) { id = blob [ blob . l + 1 ] ; R = ( id === 24 ? Ptg18 : Ptg19 ) [ id ] } if ( ! R || ! R . f ) { ptgs . push ( parsenoop ( blob , length ) ) } else { ptgs . push ( [ R . n , R . f ( blob , length , opts ) ] ) } } return ptgs } function stringify _array ( f ) { var o = [ ] ; for ( var i = 0 ; i < f . length ; ++ i ) { var x = f [ i ] , r = [ ] ; for ( var j = 0 ; j < x . length ; ++ j ) { var y = x [ j ] ; if ( y ) switch ( y [ 0 ] ) { case 2 : r . push ( '"' + y [ 1 ] . replace ( /"/g , '""' ) + '"' ) ; break ; default : r . push ( y [ 1 ] ) } else r . push ( "" ) } o . push ( r . join ( "," ) ) } return o . join ( ";" ) } var PtgBinOp = { PtgAdd : "+" , PtgConcat : "&" , PtgDiv : "/" , PtgEq : "=" , PtgGe : ">=" , PtgGt : ">" , PtgLe : "<=" , PtgLt : "<" , PtgMul : "*" , PtgNe : "<>" , PtgPower : "^" , PtgSub :
var o = '<mergeCells count="' + merges . length + '">' ; for ( var i = 0 ; i != merges . length ; ++ i ) o += '<mergeCell ref="' + encode _range ( merges [ i ] ) + '"/>' ; return o + "</mergeCells>" } function parse _ws _xml _hlinks ( s , data , rels ) { for ( var i = 0 ; i != data . length ; ++ i ) { var val = parsexmltag ( data [ i ] , true ) ; if ( ! val . ref ) return ; var rel = rels ? rels [ "!id" ] [ val . id ] : null ; if ( rel ) { val . Target = rel . Target ; if ( val . location ) val . Target += "#" + val . location ; val . Rel = rel } else { val . Target = val . location ; rel = { Target : val . location , TargetMode : "Internal" } ; val . Rel = rel } var rng = safe _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 : "stub" , v : undefined } ; s [ addr ] . l = val } } } function parse _ws _xml _cols ( columns , cols ) { var seencol = false ; for ( var coli = 0 ; coli != cols . length ; ++ coli ) { var coll = parsexmltag ( cols [ coli ] , true ) ; var colm = parseInt ( coll . min , 10 ) - 1 , colM = parseInt ( coll . max , 10 ) - 1 ; delete coll . min ; delete coll . max ; if ( ! seencol && coll . width ) { seencol = true ; find _mdw ( + coll . width , coll ) } if ( coll . width ) { coll . wpx = width2px ( + coll . width ) ; coll . wch = px2char ( coll . wpx ) ; coll . MDW = MDW } while ( colm <= colM ) columns [ colm ++ ] = coll } } function write _ws _xml _cols ( ws , cols ) { var o = [ "<cols>" ] , col , width ; for ( var i = 0 ; i != cols . length ; ++ i ) { if ( ! ( col = cols [ i ] ) ) continue ; var p = { min : i + 1 , max : i + 1 } ; width = - 1 ; if ( col . wpx ) width = px2char ( col . wpx ) ; else if ( col . wch ) width = col . wch ; if ( width > - 1 ) { p . width = char2width ( width ) ; p . customWidth = 1 } o [ o . length ] = writextag ( "col" , null , p ) } o [ o . length ] = "</cols>" ; return o . join ( "" ) } function write _ws _xml _cell ( cell , ref , ws , opts , idx , wb ) { if ( cell . v === undefined ) return "" ; var vv = "" ; var oldt = cell . t , oldv = cell . v ; switch ( cell . t ) { case "b" : vv = cell . v ? "1" : "0" ; break ; case "n" : vv = "" + cell . v ; break ; case "e" : vv = BErr [ cell . v ] ; break ; case "d" : if ( opts . cellDates ) vv = new Date ( cell . v ) . toISOString ( ) ; else { cell . t = "n" ; vv = "" + ( cell . v = datenum ( new Date ( cell . v ) ) ) ; if ( typeof cell . z === "undefined" ) cell . z = SSF . _table [ 14 ] } break ; default : vv = cell . v ; break } var v = writetag ( "v" , escapexml ( vv ) ) , o = { r : ref } ; var os = get _cell _style ( opts . cellXfs , cell , opts ) ; if ( os !== 0 ) o . s = os ; switch ( cell . t ) { case "n" : break ; case "d" : o . t = "d" ; break ; case "b" : o . t = "b" ; break ; case "e" : o . t = "e" ; break ; default : if ( opts . bookSST ) { v = writetag ( "v" , "" + get _sst _id ( opts . Strings , cell . v ) ) ; o . t = "s" ; break } o . t = "str" ; break } if ( cell . t != oldt ) { cell . t = oldt ; cell . v = oldv } return writextag ( "c" , v , o ) } var parse _ws _xml _data = function parse _ws _xml _data _factory ( ) { var cellregex = /<(?:\w+:)?c[ >]/ , rowregex = /<\/(?:\w+:)?row>/ ; var rregex = /r=["']([^"']*)["']/ , isregex = /<(?:\w+:)?is>([\S\s]*?)<\/(?:\w+:)?is>/ ; var refregex = /ref=["']([^"']*)["']/ ; var match _v = matchtag ( "v" ) , match _f = matchtag ( "f" ) ; return function parse _ws _xml _data ( sdata , s , opts , guess ) { var ri = 0 , x = "" , cells = [ ] , cref = [ ] , idx = 0 , i = 0 , cc = 0 , d = "" , p ; var tag , tagr = 0 , tagc = 0 ; var sstr , ftag ; var fmtid = 0 , fillid = 0 , do _format = Array . isArray ( styles . CellXf ) , cf ; var arrayf = [ ] ; var sharedf = [ ] ; for ( var marr = sdata . split ( rowregex ) , mt = 0 , marrlen = marr . length ; mt != marrlen ; ++ mt ) { x = marr [ mt ] . trim ( ) ; var xlen = x . length ; if ( xlen === 0 ) continue ; for ( ri = 0 ; ri < xlen ; ++ ri ) if ( x . charCodeAt ( ri ) === 62 ) break ; ++ ri ; tag = parsexmltag ( x . substr ( 0 , ri ) , true ) ; tagr = typeof tag . r !== "undefined" ? parseInt ( tag . r , 10 ) : tagr + 1 ; tagc = - 1 ; if ( opts . sheetRows && opts . sheetRows < tagr ) continue ; if ( guess . s . r > tagr - 1 ) guess . s . r = tagr - 1 ; if ( guess . e . r < tagr - 1 ) guess . e . r = tagr - 1 ; cells = x . substr ( ri ) . split ( cellregex ) ; for ( ri = 0 ; ri != cells . length ; ++ ri ) { x = cells [ ri ] . trim ( ) ; if ( x . length === 0 ) continue ; cref = x . match ( rregex ) ; idx = ri ; i = 0 ; cc = 0 ; x = "<c " + ( x . substr ( 0 , 1 ) == "<" ? ">" : "" ) + x ; if ( cref != null && cref . length === 2 ) { idx = 0 ; d = cref [ 1 ] ; for ( i = 0 ; i != d . length ; ++ i ) { if ( ( cc = d . charCodeAt ( i ) - 64 ) < 1 || cc > 26 ) break ; idx = 26 * idx + cc } -- idx ; tagc = idx } else ++ tagc ; for ( i = 0 ; i != x . length ; ++ i ) if ( x . charCodeAt ( i ) === 62 ) break ; ++ i ; tag = parsexmltag ( x . substr ( 0 , i ) , true ) ; if ( ! tag . r ) tag . r = utils . encode _cell ( { r : tagr - 1 , c : tagc } ) ; d = x . substr ( i ) ; p = { t : "" } ; if ( ( cref = d . match ( match _v ) ) != null && cref [ 1 ] !== "" ) p . v = unescapexml ( cref [ 1 ] ) ; if ( opts . cellFormula ) { if ( ( cref = d . match ( match _f ) ) != null && cref [ 1 ] !== "" ) { p . f = unescapexml ( utf8read ( cref [ 1 ] ) ) ; if ( cref [ 0 ] . indexOf ( 't="array"' ) > - 1 ) { p . F = ( d . match ( refregex ) || [ ] ) [ 1 ] ; if ( p . F . indexOf ( ":" ) > - 1 ) arrayf . push ( [ safe _decode _range ( p . F ) , p . F ] ) } else if ( cref [ 0 ] . indexOf ( 't="shared"' ) > - 1 ) { ftag = parsexmltag ( cref [ 0 ] ) ; sharedf
var nf = "General" , sid = cell . StyleID , S = { } ; o = o || { } ; var interiors = [ ] ; var i = 0 ; if ( sid === undefined && row ) sid = row . StyleID ; if ( sid === undefined && csty ) sid = csty . StyleID ; while ( styles [ sid ] !== undefined ) { if ( styles [ sid ] . nf ) nf = styles [ sid ] . nf ; if ( styles [ sid ] . Interior ) interiors . push ( styles [ sid ] . Interior ) ; if ( ! styles [ sid ] . Parent ) break ; sid = styles [ sid ] . Parent } switch ( data . Type ) { case "Boolean" : cell . t = "b" ; cell . v = parsexmlbool ( xml ) ; break ; case "String" : cell . t = "s" ; cell . r = xlml _fixstr ( unescapexml ( xml ) ) ; cell . v = xml . indexOf ( "<" ) > - 1 ? unescapexml ( ss ) : cell . r ; break ; case "DateTime" : cell . v = ( Date . parse ( xml ) - new Date ( Date . UTC ( 1899 , 11 , 30 ) ) ) / ( 24 * 60 * 60 * 1e3 ) ; if ( cell . v !== cell . v ) cell . v = unescapexml ( xml ) ; else if ( cell . v >= 1 && cell . v < 60 ) cell . v = cell . v - 1 ; if ( ! nf || nf == "General" ) nf = "yyyy-mm-dd" ; case "Number" : if ( cell . v === undefined ) cell . v = + xml ; if ( ! cell . t ) cell . t = "n" ; break ; case "Error" : cell . t = "e" ; cell . v = RBErr [ xml ] ; cell . w = xml ; break ; default : cell . t = "s" ; cell . v = xlml _fixstr ( ss ) ; break } safe _format _xlml ( cell , nf , o ) ; if ( o . cellFormula != null ) { if ( cell . Formula ) { var fstr = unescapexml ( cell . Formula ) ; if ( fstr . charCodeAt ( 0 ) == 61 ) fstr = fstr . substr ( 1 ) ; cell . f = rc _to _a1 ( fstr , base ) ; cell . Formula = undefined ; if ( cell . ArrayRange == "RC" ) cell . F = rc _to _a1 ( "RC:RC" , base ) ; else if ( cell . ArrayRange ) { cell . F = rc _to _a1 ( cell . ArrayRange , base ) ; arrayf . push ( [ safe _decode _range ( cell . F ) , cell . F ] ) } } else { for ( i = 0 ; i < arrayf . length ; ++ i ) if ( base . r >= arrayf [ i ] [ 0 ] . s . r && base . r <= arrayf [ i ] [ 0 ] . e . r ) if ( base . c >= arrayf [ i ] [ 0 ] . s . c && base . c <= arrayf [ i ] [ 0 ] . e . c ) cell . F = arrayf [ i ] [ 1 ] } } if ( o . cellStyles ) { interiors . forEach ( function ( x ) { if ( ! S . patternType && x . patternType ) S . patternType = x . patternType } ) ; cell . s = S } cell . ixfe = cell . StyleID !== undefined ? cell . StyleID : "Default" } function xlml _clean _comment ( comment ) { comment . t = comment . v ; comment . v = comment . w = comment . ixfe = undefined } function xlml _normalize ( d ) { if ( has _buf && Buffer . isBuffer ( d ) ) return d . toString ( "utf8" ) ; if ( typeof d === "string" ) return d ; throw new Error ( "Bad input format: expected Buffer or string" ) } var xlmlregex = /<(\/?)([^\s?>!\/:]*:|)([^\s?>]*[^\s?>\/])[^>]*>/gm ; function parse _xlml _xml ( d , opts ) { var str = debom ( xlml _normalize ( d ) ) ; if ( opts && opts . type == "binary" && typeof cptable !== "undefined" ) str = cptable . utils . decode ( 65001 , char _codes ( str ) ) ; if ( str . substr ( 0 , 1e3 ) . indexOf ( "<html" ) >= 0 ) return parse _html ( str , opts ) ; var Rn ; var state = [ ] , tmp ; var sheets = { } , sheetnames = [ ] , cursheet = { } , sheetname = "" ; var table = { } , cell = { } , row = { } ; var dtag = xlml _parsexmltag ( '<Data ss:Type="String">' ) , didx = 0 ; var c = 0 , r = 0 ; var refguess = { s : { r : 2e6 , c : 2e6 } , e : { r : 0 , c : 0 } } ; var styles = { } , stag = { } ; var ss = "" , fidx = 0 ; var mergecells = [ ] ; var Props = { } , Custprops = { } , pidx = 0 , cp = { } ; var comments = [ ] , comment = { } ; var cstys = [ ] , csty ; var arrayf = [ ] ; xlmlregex . lastIndex = 0 ; str = str . replace ( /<!--([^\u2603]*?)-->/gm , "" ) ; while ( Rn = xlmlregex . exec ( str ) ) switch ( Rn [ 3 ] ) { case "Data" : if ( state [ state . length - 1 ] [ 1 ] ) break ; if ( Rn [ 1 ] === "/" ) parse _xlml _data ( str . slice ( didx , Rn . index ) , ss , dtag , state [ state . length - 1 ] [ 0 ] == "Comment" ? comment : cell , { c : c , r : r } , styles , cstys [ c ] , row , arrayf , opts ) ; else { ss = "" ; dtag = xlml _parsexmltag ( Rn [ 0 ] ) ; didx = Rn . index + Rn [ 0 ] . length } break ; case "Cell" : if ( Rn [ 1 ] === "/" ) { if ( comments . length > 0 ) cell . c = comments ; if ( ( ! opts . sheetRows || opts . sheetRows > r ) && cell . v !== undefined ) cursheet [ encode _col ( c ) + encode _row ( r ) ] = cell ; if ( cell . HRef ) { cell . l = { Target : cell . HRef , tooltip : cell . HRefScreenTip } ; cell . HRef = cell . HRefScreenTip = undefined } if ( cell . MergeAcross || cell . MergeDown ) { var cc = c + ( parseInt ( cell . MergeAcross , 10 ) | 0 ) ; var rr = r + ( parseInt ( cell . MergeDown , 10 ) | 0 ) ; mergecells . push ( { s : { c : c , r : r } , e : { c : cc , r : rr } } ) } ++ c ; if ( cell . MergeAcross ) c += + cell . MergeAcross } else { cell = xlml _parsexmltagobj ( Rn [ 0 ] ) ; if ( cell . Index ) c = + cell . Index - 1 ; if ( c < refguess . s . c ) refguess . s . c = c ; if ( c > refguess . e . c ) refguess . e . c = c ; if ( Rn [ 0 ] . slice ( - 2 ) === "/>" ) ++ c ; comments = [ ] } break ; case "Row" : if ( Rn [ 1 ] === "/" || Rn [ 0 ] . slice ( - 2 ) === "/>" ) { if ( r < refguess . s . r ) refguess . s . r = r ; if ( r > refguess . e . r ) refguess . e . r = r ; if ( Rn [ 0 ] . slice ( - 2 ) === "/>" ) { row = xlml _parsexmltag ( Rn [ 0 ] ) ; if ( row . Index ) r = + row . Index - 1 } c = 0 ; ++ r } else { row = xlml _parsexmltag ( Rn [ 0 ] ) ; if ( row . Index ) r = + row . Index - 1 } break ; case "Worksheet" : if ( Rn [ 1 ] === "/" ) { if ( ( tmp = state . pop ( ) ) [ 0 ] !== Rn [ 3 ] ) throw "Bad state: " + tmp ; sheetnames . push ( sheetname ) ; if ( refguess . s . r <= refguess . e . r && refguess . s . c <= refguess . e . c ) cursheet [ "!ref" ]
} , 22 : { n : "BrtPCDIBoolean" , f : parsenoop } , 23 : { n : "BrtPCDIError" , f : parsenoop } , 24 : { n : "BrtPCDIString" , f : parsenoop } , 25 : { n : "BrtPCDIDatetime" , f : parsenoop } , 26 : { n : "BrtPCDIIndex" , f : parsenoop } , 27 : { n : "BrtPCDIAMissing" , f : parsenoop } , 28 : { n : "BrtPCDIANumber" , f : parsenoop } , 29 : { n : "BrtPCDIABoolean" , f : parsenoop } , 30 : { n : "BrtPCDIAError" , f : parsenoop } , 31 : { n : "BrtPCDIAString" , f : parsenoop } , 32 : { n : "BrtPCDIADatetime" , f : parsenoop } , 33 : { n : "BrtPCRRecord" , f : parsenoop } , 34 : { n : "BrtPCRRecordDt" , f : parsenoop } , 35 : { n : "BrtFRTBegin" , f : parsenoop } , 36 : { n : "BrtFRTEnd" , f : parsenoop } , 37 : { n : "BrtACBegin" , f : parsenoop } , 38 : { n : "BrtACEnd" , f : parsenoop } , 39 : { n : "BrtName" , f : parse _BrtName } , 40 : { n : "BrtIndexRowBlock" , f : parsenoop } , 42 : { n : "BrtIndexBlock" , f : parsenoop } , 43 : { n : "BrtFont" , f : parse _BrtFont } , 44 : { n : "BrtFmt" , f : parse _BrtFmt } , 45 : { n : "BrtFill" , f : parsenoop } , 46 : { n : "BrtBorder" , f : parsenoop } , 47 : { n : "BrtXF" , f : parse _BrtXF } , 48 : { n : "BrtStyle" , f : parsenoop } , 49 : { n : "BrtCellMeta" , f : parsenoop } , 50 : { n : "BrtValueMeta" , f : parsenoop } , 51 : { n : "BrtMdb" , f : parsenoop } , 52 : { n : "BrtBeginFmd" , f : parsenoop } , 53 : { n : "BrtEndFmd" , f : parsenoop } , 54 : { n : "BrtBeginMdx" , f : parsenoop } , 55 : { n : "BrtEndMdx" , f : parsenoop } , 56 : { n : "BrtBeginMdxTuple" , f : parsenoop } , 57 : { n : "BrtEndMdxTuple" , f : parsenoop } , 58 : { n : "BrtMdxMbrIstr" , f : parsenoop } , 59 : { n : "BrtStr" , f : parsenoop } , 60 : { n : "BrtColInfo" , f : parsenoop } , 62 : { n : "BrtCellRString" , f : parsenoop } , 63 : { n : "BrtCalcChainItem$" , f : parse _BrtCalcChainItem$ } , 64 : { n : "BrtDVal" , f : parsenoop } , 65 : { n : "BrtSxvcellNum" , f : parsenoop } , 66 : { n : "BrtSxvcellStr" , f : parsenoop } , 67 : { n : "BrtSxvcellBool" , f : parsenoop } , 68 : { n : "BrtSxvcellErr" , f : parsenoop } , 69 : { n : "BrtSxvcellDate" , f : parsenoop } , 70 : { n : "BrtSxvcellNil" , f : parsenoop } , 128 : { n : "BrtFileVersion" , f : parsenoop } , 129 : { n : "BrtBeginSheet" , f : parsenoop } , 130 : { n : "BrtEndSheet" , f : parsenoop } , 131 : { n : "BrtBeginBook" , f : parsenoop , p : 0 } , 132 : { n : "BrtEndBook" , f : parsenoop } , 133 : { n : "BrtBeginWsViews" , f : parsenoop } , 134 : { n : "BrtEndWsViews" , f : parsenoop } , 135 : { n : "BrtBeginBookViews" , f : parsenoop } , 136 : { n : "BrtEndBookViews" , f : parsenoop } , 137 : { n : "BrtBeginWsView" , f : parsenoop } , 138 : { n : "BrtEndWsView" , f : parsenoop } , 139 : { n : "BrtBeginCsViews" , f : parsenoop } , 140 : { n : "BrtEndCsViews" , f : parsenoop } , 141 : { n : "BrtBeginCsView" , f : parsenoop } , 142 : { n : "BrtEndCsView" , f : parsenoop } , 143 : { n : "BrtBeginBundleShs" , f : parsenoop } , 144 : { n : "BrtEndBundleShs" , f : parsenoop } , 145 : { n : "BrtBeginSheetData" , f : parsenoop } , 146 : { n : "BrtEndSheetData" , f : parsenoop } , 147 : { n : "BrtWsProp" , f : parse _BrtWsProp } , 148 : { n : "BrtWsDim" , f : parse _BrtWsDim , p : 16 } , 151 : { n : "BrtPane" , f : parsenoop } , 152 : { n : "BrtSel" , f : parsenoop } , 153 : { n : "BrtWbProp" , f : parse _BrtWbProp } , 154 : { n : "BrtWbFactoid" , f : parsenoop } , 155 : { n : "BrtFileRecover" , f : parsenoop } , 156 : { n : "BrtBundleSh" , f : parse _BrtBundleSh } , 157 : { n : "BrtCalcProp" , f : parsenoop } , 158 : { n : "BrtBookView" , f : parsenoop } , 159 : { n : "BrtBeginSst" , f : parse _BrtBeginSst } , 160 : { n : "BrtEndSst" , f : parsenoop } , 161 : { n : "BrtBeginAFilter" , f : parsenoop } , 162 : { n : "BrtEndAFilter" , f : parsenoop } , 163 : { n : "BrtBeginFilterColumn" , f : parsenoop } , 164 : { n : "BrtEndFilterColumn" , f : parsenoop } , 165 : { n : "BrtBeginFilters" , f : parsenoop } , 166 : { n : "BrtEndFilters" , f : parsenoop } , 167 : { n : "BrtFilter" , f : parsenoop } , 168 : { n : "BrtColorFilter" , f : parsenoop } , 169 : { n : "BrtIconFilter" , f : parsenoop } , 170 : { n : "BrtTop10Filter" , f : parsenoop } , 171 : { n : "BrtDynamicFilter" , f : parsenoop } , 172 : { n : "BrtBeginCustomFilters" , f : parsenoop } , 173 : { n : "BrtEndCustomFilters" , f : parsenoop } , 174 : { n : "BrtCustomFilter" , f : parsenoop } , 175 : { n : "BrtAFilterDateGroupItem" , f : parsenoop } , 176 : { n : "BrtMergeCell" , f : parse _BrtMergeCell } , 177 : { n : "BrtBeginMergeCells" , f : parsenoop } , 178 : { n : "BrtEndMergeCells" , f : parsenoop } , 179 : { n : "BrtBeginPivotCacheDef" , f : parsenoop } , 180 : { n : "BrtEndPivotCacheDef" , f : parsenoop } , 181 : { n : "BrtBeginPCDFields" , f : parsenoop } , 182 : { n : "BrtEndPCDFields" , f : parsenoop } , 183 : { n : "BrtBeginPCDField" , f : parsenoop } , 184 : { n : "BrtEndPCDField" , f : parsenoop } , 185 : { n : "BrtBeginPCDSource" , f : parsenoop } , 186 : { n : "BrtEndPCDSource" , f : parsenoop } , 187 : { n : "BrtBeginPCDSRange" , f : parsenoop } , 188 : { n : "BrtEndPCDSRange" , f : parsenoop } , 189 : { n : "BrtBeginPCDFAtbl" , f : parsenoop } , 190 : { n : "BrtEndPCDFAtbl" , f : parsenoop } , 191 : { n : "BrtBeginPCDIRun" , f : parsenoop } , 192 : { n : "BrtEndPCDIRun" , f : parsenoop } , 193 : { n : "BrtBeginPivotCacheRecords" , f : parsenoop } , 194 : { n : "BrtEndPivotCacheRecords" , f : parsenoop } , 195 : { n :
f : parse _Protect } , 19 : { n : "Password" , f : parse _Password } , 20 : { n : "Header" , f : parse _Header } , 21 : { n : "Footer" , f : parse _Footer } , 23 : { n : "ExternSheet" , f : parse _ExternSheet } , 24 : { n : "Lbl" , f : parse _Lbl } , 25 : { n : "WinProtect" , f : parse _WinProtect } , 26 : { n : "VerticalPageBreaks" , f : parse _VerticalPageBreaks } , 27 : { n : "HorizontalPageBreaks" , f : parse _HorizontalPageBreaks } , 28 : { n : "Note" , f : parse _Note } , 29 : { n : "Selection" , f : parse _Selection } , 34 : { n : "Date1904" , f : parse _Date1904 } , 35 : { n : "ExternName" , f : parse _ExternName } , 38 : { n : "LeftMargin" , f : parse _LeftMargin } , 39 : { n : "RightMargin" , f : parse _RightMargin } , 40 : { n : "TopMargin" , f : parse _TopMargin } , 41 : { n : "BottomMargin" , f : parse _BottomMargin } , 42 : { n : "PrintRowCol" , f : parse _PrintRowCol } , 43 : { n : "PrintGrid" , f : parse _PrintGrid } , 47 : { n : "FilePass" , f : parse _FilePass } , 49 : { n : "Font" , f : parse _Font } , 51 : { n : "PrintSize" , f : parse _PrintSize } , 60 : { n : "Continue" , f : parse _Continue } , 61 : { n : "Window1" , f : parse _Window1 } , 64 : { n : "Backup" , f : parse _Backup } , 65 : { n : "Pane" , f : parse _Pane } , 66 : { n : "CodePage" , f : parse _CodePage } , 77 : { n : "Pls" , f : parse _Pls } , 80 : { n : "DCon" , f : parse _DCon } , 81 : { n : "DConRef" , f : parse _DConRef } , 82 : { n : "DConName" , f : parse _DConName } , 85 : { n : "DefColWidth" , f : parse _DefColWidth } , 89 : { n : "XCT" , f : parse _XCT } , 90 : { n : "CRN" , f : parse _CRN } , 91 : { n : "FileSharing" , f : parse _FileSharing } , 92 : { n : "WriteAccess" , f : parse _WriteAccess } , 93 : { n : "Obj" , f : parse _Obj } , 94 : { n : "Uncalced" , f : parse _Uncalced } , 95 : { n : "CalcSaveRecalc" , f : parse _CalcSaveRecalc } , 96 : { n : "Template" , f : parse _Template } , 97 : { n : "Intl" , f : parse _Intl } , 99 : { n : "ObjProtect" , f : parse _ObjProtect } , 125 : { n : "ColInfo" , f : parse _ColInfo } , 128 : { n : "Guts" , f : parse _Guts } , 129 : { n : "WsBool" , f : parse _WsBool } , 130 : { n : "GridSet" , f : parse _GridSet } , 131 : { n : "HCenter" , f : parse _HCenter } , 132 : { n : "VCenter" , f : parse _VCenter } , 133 : { n : "BoundSheet8" , f : parse _BoundSheet8 } , 134 : { n : "WriteProtect" , f : parse _WriteProtect } , 140 : { n : "Country" , f : parse _Country } , 141 : { n : "HideObj" , f : parse _HideObj } , 144 : { n : "Sort" , f : parse _Sort } , 146 : { n : "Palette" , f : parse _Palette } , 151 : { n : "Sync" , f : parse _Sync } , 152 : { n : "LPr" , f : parse _LPr } , 153 : { n : "DxGCol" , f : parse _DxGCol } , 154 : { n : "FnGroupName" , f : parse _FnGroupName } , 155 : { n : "FilterMode" , f : parse _FilterMode } , 156 : { n : "BuiltInFnGroupCount" , f : parse _BuiltInFnGroupCount } , 157 : { n : "AutoFilterInfo" , f : parse _AutoFilterInfo } , 158 : { n : "AutoFilter" , f : parse _AutoFilter } , 160 : { n : "Scl" , f : parse _Scl } , 161 : { n : "Setup" , f : parse _Setup } , 174 : { n : "ScenMan" , f : parse _ScenMan } , 175 : { n : "SCENARIO" , f : parse _SCENARIO } , 176 : { n : "SxView" , f : parse _SxView } , 177 : { n : "Sxvd" , f : parse _Sxvd } , 178 : { n : "SXVI" , f : parse _SXVI } , 180 : { n : "SxIvd" , f : parse _SxIvd } , 181 : { n : "SXLI" , f : parse _SXLI } , 182 : { n : "SXPI" , f : parse _SXPI } , 184 : { n : "DocRoute" , f : parse _DocRoute } , 185 : { n : "RecipName" , f : parse _RecipName } , 189 : { n : "MulRk" , f : parse _MulRk } , 190 : { n : "MulBlank" , f : parse _MulBlank } , 193 : { n : "Mms" , f : parse _Mms } , 197 : { n : "SXDI" , f : parse _SXDI } , 198 : { n : "SXDB" , f : parse _SXDB } , 199 : { n : "SXFDB" , f : parse _SXFDB } , 200 : { n : "SXDBB" , f : parse _SXDBB } , 201 : { n : "SXNum" , f : parse _SXNum } , 202 : { n : "SxBool" , f : parse _SxBool } , 203 : { n : "SxErr" , f : parse _SxErr } , 204 : { n : "SXInt" , f : parse _SXInt } , 205 : { n : "SXString" , f : parse _SXString } , 206 : { n : "SXDtr" , f : parse _SXDtr } , 207 : { n : "SxNil" , f : parse _SxNil } , 208 : { n : "SXTbl" , f : parse _SXTbl } , 209 : { n : "SXTBRGIITM" , f : parse _SXTBRGIITM } , 210 : { n : "SxTbpg" , f : parse _SxTbpg } , 211 : { n : "ObProj" , f : parse _ObProj } , 213 : { n : "SXStreamID" , f : parse _SXStreamID } , 215 : { n : "DBCell" , f : parse _DBCell } , 216 : { n : "SXRng" , f : parse _SXRng } , 217 : { n : "SxIsxoper" , f : parse _SxIsxoper } , 218 : { n : "BookBool" , f : parse _BookBool } , 220 : { n : "DbOrParamQry" , f : parse _DbOrParamQry } , 221 : { n : "ScenarioProtect" , f : parse _ScenarioProtect } , 222 : { n : "OleObjectSize" , f : parse _OleObjectSize } , 224 : { n : "XF" , f : parse _XF } , 225 : { n : "InterfaceHdr" , f : parse _InterfaceHdr } , 226 : { n : "InterfaceEnd" , f : parse _InterfaceEnd } , 227 : { n : "SXVS" , f : parse _SXVS } , 229 : { n : "MergeCells" , f : parse _MergeCells } , 233 : { n : "BkHim" , f : parse _BkHim } , 235 : { n : "MsoDrawingGroup" , f : parse _MsoDrawingGroup } , 236 : { n : "MsoDrawing" , f : parse _MsoDrawing } , 237 : { n : "MsoDrawingSelection" , f : parse _MsoDrawingSelection } , 239 : { n : "PhoneticInfo" , f : parse _PhoneticInfo } , 240 : { n : "SxRule" , f : parse _SxRule } , 241 : { n : "SXEx" , f : parse _SXEx } , 242 : { n : "SxFilt" , f : parse _SxFilt } , 244 : { n : "SxDXF" , f : parse _SxDXF } , 245 : { n : "SxItm" , f : parse _SxItm } , 246 : { n : "SxName" , f : parse _SxName } , 247 : { n : "SxSelect" , f : parse _SxSelect } , 248 : { n : "SXPair" , f : parse _SXP
} function safe _parse _ws ( zip , path , relsPath , sheet , sheetRels , sheets , opts , wb ) { try { sheetRels [ sheet ] = parse _rels ( getzipstr ( zip , relsPath , true ) , path ) ; sheets [ sheet ] = parse _ws ( getzipdata ( zip , path ) , path , opts , sheetRels [ sheet ] , wb ) } catch ( e ) { if ( opts . WTF ) throw e } } var nodirs = function nodirs ( x ) { return x . slice ( - 1 ) != "/" } ; function parse _zip ( zip , opts ) { make _ssf ( SSF ) ; opts = opts || { } ; fix _read _opts ( opts ) ; reset _cp ( ) ; if ( safegetzipfile ( zip , "META-INF/manifest.xml" ) ) return parse _ods ( zip , opts ) ; if ( safegetzipfile ( zip , "objectdata.xml" ) ) return parse _ods ( zip , opts ) ; var entries = keys ( zip . files ) . filter ( nodirs ) . sort ( ) ; var dir = parse _ct ( getzipstr ( zip , "[Content_Types].xml" ) , opts ) ; var xlsb = false ; var sheets , binname ; if ( dir . workbooks . length === 0 ) { binname = "xl/workbook.xml" ; if ( getzipdata ( zip , binname , true ) ) dir . workbooks . push ( binname ) } if ( dir . workbooks . length === 0 ) { binname = "xl/workbook.bin" ; if ( ! getzipfile ( zip , binname , true ) ) throw new Error ( "Could not find workbook" ) ; dir . workbooks . push ( binname ) ; xlsb = true } if ( dir . workbooks [ 0 ] . slice ( - 3 ) == "bin" ) xlsb = true ; if ( xlsb ) set _cp ( 1200 ) ; if ( ! opts . bookSheets && ! opts . bookProps ) { strs = [ ] ; if ( dir . sst ) strs = parse _sst ( getzipdata ( zip , dir . sst . replace ( /^\// , "" ) ) , dir . sst , opts ) ; styles = { } ; if ( dir . style ) styles = parse _sty ( getzipdata ( zip , dir . style . replace ( /^\// , "" ) ) , dir . style , opts ) ; themes = { } ; if ( opts . cellStyles && dir . themes . length ) themes = parse _theme ( getzipdata ( zip , dir . themes [ 0 ] . replace ( /^\// , "" ) , true ) , dir . themes [ 0 ] , opts ) } var wb = parse _wb ( getzipdata ( zip , dir . workbooks [ 0 ] . replace ( /^\// , "" ) ) , dir . workbooks [ 0 ] , opts ) ; var props = { } , propdata = "" ; if ( dir . coreprops . length !== 0 ) { propdata = getzipstr ( zip , dir . coreprops [ 0 ] . replace ( /^\// , "" ) , true ) ; if ( propdata ) props = parse _core _props ( propdata ) ; if ( dir . extprops . length !== 0 ) { propdata = getzipstr ( zip , dir . extprops [ 0 ] . replace ( /^\// , "" ) , true ) ; if ( propdata ) parse _ext _props ( propdata , props ) } } var custprops = { } ; if ( ! opts . bookSheets || opts . bookProps ) { if ( dir . custprops . length !== 0 ) { propdata = getzipstr ( zip , dir . custprops [ 0 ] . replace ( /^\// , "" ) , true ) ; if ( propdata ) custprops = parse _cust _props ( propdata , opts ) } } 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 pluck ( 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 = { } ; if ( opts . bookDeps && dir . calcchain ) deps = parse _cc ( getzipdata ( zip , dir . calcchain . replace ( /^\// , "" ) ) , dir . calcchain , opts ) ; 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 } } var wbext = xlsb ? "bin" : "xml" ; var wbrelsfile = "xl/_rels/workbook." + wbext + ".rels" ; var wbrels = parse _rels ( getzipstr ( zip , wbrelsfile , true ) , wbrelsfile ) ; if ( wbrels ) wbrels = safe _parse _wbrels ( wbrels , wb . Sheets ) ; var nmode = getzipdata ( zip , "xl/worksheets/sheet.xml" , true ) ? 1 : 0 ; for ( i = 0 ; i != props . Worksheets ; ++ i ) { if ( wbrels && wbrels [ i ] ) path = "xl/" + wbrels [ i ] [ 1 ] . replace ( /[\/]?xl\// , "" ) ; else { path = "xl/worksheets/sheet" + ( i + 1 - nmode ) + "." + wbext ; path = path . replace ( /sheet0\./ , "sheet." ) } relsPath = path . replace ( /^(.*)(\/)([^\/]*)$/ , "$1/_rels/$3.rels" ) ; safe _parse _ws ( zip , path , relsPath , props . SheetNames [ i ] , sheetRels , sheets , opts , wb ) } 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 , Themes : themes , SSF : SSF . get _table ( ) } ; if ( opts . bookFiles ) { out . keys = entries ; out . files = zip . files } if ( opts . bookVBA ) { if ( dir . vba . length > 0 ) out . vbaraw = getzipdata ( zip , dir . vba [ 0 ] , true ) ; else if ( dir . defaults && dir . defaults . bin === "application/vnd.ms-office.vbaProject" ) out . vbaraw = getzipdata ( zip , "xl/vbaProject.bin" , true ) } return out } function add _rels ( rels , rId , f , type , relobj ) { if ( ! relobj ) relobj = { } ; if ( ! rels [ "!id" ] ) rels [ "!id" ] = { } ; relobj . Id = "rId" + rId ; relobj . Type = type ; relobj . Target = f ; if ( rels [ "!id" ] [ relobj . Id ] ) throw new Error ( "Cannot rewrite rId " + rId ) ; rels [ "!id" ] [ relobj . Id ] = relobj ; rels [ ( "/" + relobj . Target ) . replac