2016-12-31 08:20:45 +00:00
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
2017-03-10 01:09:18 +00:00
var XLSX = { } ; ( function make _xlsx ( XLSX ) { XLSX . version = "0.9.0" ; 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.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 ] ] . 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
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 ] . indexOf ( ot ) == - 1 ) blob . l += 6 ; else controlInfo = parse _ControlInfo ( blob , 6 , opts ) ; var cchText = blob . read _shift ( 2 ) ; var cbRuns = blob . read _shift ( 2 ) ; var ifntEmpty = parse _FontIndex ( blob , 2 ) ; var len = blob . read _shift ( 2 ) ; blob . l += len ; for ( var i = 1 ; i < blob . lens . length - 1 ; ++ i ) { if ( blob . l - s != blob . lens [ i ] ) throw "TxO: bad continue record" ; var hdr = b
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>" : case "</a:hlink>" : 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" } } ) } function parse _fontScheme ( t , opts ) { } function parse _fmtScheme ( t , opts ) { } var clrsregex = /<a:clrScheme([^>]*)>[^\u2603]*<\/a:clrScheme>/ ; var fntsregex = / < a : f o n t S c h e m e ( [ ^ > ] * ) > [ ^ \
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 : "-" } ; function stringify _formula ( formula , range , cell , supbooks , opts ) { var _range = { s : { c : 0 , r : 0 } , e : { c : 0 , r : 0 } } ; var stack = [ ] , e1 , e2 , type , c , ixti , nameidx , r , sname = "" ; if ( ! formula [ 0 ] || ! formula [ 0 ] [ 0 ] ) return "" ; var last _sp = - 1 , sp = "" ; for ( var ff = 0 , fflen = formula [ 0 ] . length ; ff < fflen ; ++ ff ) { var f = formula [ 0 ] [ ff ] ; switch ( f [ 0 ] ) { case "PtgUminus" : stack . push ( "-" + stack . pop ( ) ) ; break ; case "PtgUplus" : stack . push ( "+" + stack . pop ( ) ) ; break ; case "PtgPercent" : stack . push ( stack . pop ( ) + "%" ) ; break ; case "PtgAdd" : case "PtgConcat" : case "PtgDiv" : case "PtgEq" : case "PtgGe" : case "PtgGt" : case "PtgLe" : case "PtgLt" : case "PtgMul" : case "PtgNe" : case "PtgPower" : case "PtgSub" : e1 = stack . pop ( ) ; e2 = stack . pop ( ) ; if ( last _sp >= 0 ) { switch ( formula [ 0 ] [ last _sp ] [ 1 ] [ 0 ] ) { case 0 : sp = fil
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 [ parseInt ( ftag . si , 10 ) ] = [ ftag , unescapexml ( utf8read ( cref [ 1 ] ) ) ] } } else if ( cref = d . match ( /<f[^>]*\/>/ ) ) { ftag = parsexmltag ( cref [ 0 ] ) ; if ( sharedf [ ftag . si ] ) p . f = shift _formula _xlsx ( sharedf [ ftag . si ] [ 1 ] , sharedf [ ftag . si ] [ 0 ] . ref , tag . r ) } var _tag = decode _cell ( tag . r ) ; for ( i = 0 ; i < arrayf . length ; ++ i ) if ( _tag . r >= arrayf [ i ] [ 0 ] . s . r && _tag . r <= arrayf [ i ] [ 0 ] . e . r ) if ( _tag . c >= arrayf [ i ] [ 0 ] . s . c && _tag . c <= arrayf [ i ] [ 0 ] . e . c ) p . F = arrayf [ i ] [ 1 ] } if ( tag . t === undefined && p . v === undefined ) { if ( ! opts . sheetStubs ) continue ; p . t = "stub" } else p . t = tag . t || "n" ; if ( guess . s . c > idx ) guess . s . c = idx ; if ( guess . e . c < idx ) guess . e . c = idx ; switch ( p . t ) { case "n" : p . v = parseFloat ( p . v ) ; break ; case "s" : sstr = strs [ parseInt ( p . v , 10 ) ] ; if ( typeof p . v == "undefined" ) { if ( ! opts . sheetStubs ) continue ; p . t = "stub" } p . v = sstr . t ; p . r = sstr . r ; if ( opts . cellHTML ) p . h = sstr . h ; break ; case "str" : p . t = "s" ; p . v = p . v != null ? utf8read ( p . v ) : "" ; if ( opts . cellHTML ) p . h = p . v ; break ; case "inlineStr" : cref = d . match ( isregex ) ; p . t = "s" ; if ( cref != null ) { if ( sstr = parse _si ( cref [ 1 ] ) ) p . v = sstr . t } else p . v = "" ; break ; case "b" : p . v = parsexmlbool ( p . v ) ; break ; case "d" : if ( ! opts . cellDates ) { p . v = datenum ( new Date ( p . v ) ) ; p . t = "n" } break ; case "e" : p . w = p . v ; p . v = RBErr [ p . v ] ; break } fmtid = fillid = 0 ; if ( do _format && tag . s !== undefined ) { cf = styles . CellXf [ tag . s ] ; if ( cf != null ) { if ( cf . numFmtId != nul
} ) ; 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 ( 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 ; 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" ] = encode _range ( refguess ) ; if ( mergecells . length ) cursheet [ "!merges" ] = mergecells ; sheets [ sheetname ] = cursheet } else { refguess = { s : { r : 2e6 , c : 2e6 } , e : { r : 0 , c : 0 } } ; r = c = 0 ; state . push ( [ Rn [ 3 ] , false ] ) ; tmp = xlml _parsexmltag ( Rn [ 0 ] ) ; sheetname = tmp . Name ; cursheet = { } ; mergecells = [ ] } break ; case "Table" : if ( Rn [ 1 ] === "/" ) { if ( ( tmp = state . pop ( ) ) [ 0 ] !== Rn [ 3 ] ) throw "Bad state: " + tmp } else if ( Rn [ 0 ] . slice ( - 2 ) == "/>" ) break ; else { table = xlml _parsexmltag ( Rn [ 0 ] ) ; state . push ( [ Rn [ 3 ] , false ] ) ; cstys = [ ] } break ; case "Style" : if ( Rn [ 1 ] === "/" ) process _style _xlml ( styles , stag , opts ) ; else stag = xlml _parsexmltag ( Rn [ 0 ] ) ; break ; case "NumberFormat" : stag . nf = xlml _parsexmltag ( Rn [ 0 ] ) . Format || "General" ; break ; case "Column" : if ( state [ state . length - 1 ] [ 0 ] !== "Table" ) break ; csty = xlml _parsexmltag ( Rn [ 0 ] ) ; cstys [ csty . Index - 1 || cstys . length ] = csty ; for ( var i = 0 ; i < + csty . Span ; ++ i ) cstys [ cstys . length ] = csty ; break ; case "NamedRange" : break ; case "NamedCell" : break ; case "B" : break ; case "I" : break ; case "U" : break ; case "S" : break ; case "Sub" : break ; case "Sup" : break ; case "Span" : break ; case "Border" : break ; case "Alignment" : break ; case "Borders" : break ; case "Font" : if ( Rn [ 0 ] . slice ( - 2 ) === "/>" ) break ; else if ( Rn [ 1 ] === "/" ) ss += str . slice ( fidx , Rn . index ) ; else fidx = Rn . index + Rn [ 0 ] . length ; break ; case "Interior" : if ( ! opts . cellStyles ) break ; stag . Interior = xlml _parsexmltag ( Rn [ 0 ] ) ; break ; case "Protection" : break ; case "Author" : case "Title" : case "Description" : case "Created" : case "Keywords" : case "Subject" : case "Category" : case "Company" : case "LastAuthor" : case "LastSaved" : case "LastPrinted" : case "Version" : case "Revision" : case "TotalTime" : case "HyperlinkBase" : case "Manager" : if ( Rn [ 0 ] . slice ( - 2 ) === "/>" ) break ; else if ( Rn [ 1 ] === "/" ) xlml _set _prop ( Props , Rn [ 3 ] , str . slice ( pidx , Rn . index ) ) ; else pidx = Rn . index + Rn [ 0 ] . length ; break ; case "Paragraphs" : break ; case "Styles" : case "Workbook" : if (
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 : "BrtBeginPCDHierarchies" , f : parsenoop } , 196 : { n : "BrtEndPCDHierarchies" , f : parsenoop } , 197 : { n : "BrtBeginPCDHierarchy" , f : parsenoop } , 198 : { n : "BrtEndPCDHierarchy" , f : parsenoop } , 199 : { n : "BrtBeginPCDHFieldsUsage" , f : parsenoop } , 200 : { n : "BrtEndPCDHFieldsUsage" , f : parsenoop } , 201 : { n : "BrtBeginExtConnection" , f : parsenoop } , 202 : { n : "BrtEndExtConnection" , f : parsenoop } , 203 : { n : "BrtBeginECDbProps" , f : parsenoop } , 204 : { n : "BrtEndECDbProps" , f : parsenoop } , 205 : { n : "BrtBeginECOlapProps" , f : parsenoop } , 206 : { n : "BrtEndECOlapProps" , f : parsenoop } , 207 : { n : "BrtBeginPCDSConsol" , f : parsenoop } , 208 : { n : "BrtEndPCDSConsol" , f : parsenoop } , 209 : { n : "BrtBeginPCDSCPages" , f : parsenoop } , 210 : { n : "BrtEndPCDSCPages" , f : parsenoop } , 211 : { n : "BrtBeginPCDSCPage" , f : parsenoop } , 212 : { n : "BrtEndPCDSCPage" , f : parsenoop } , 213 : { n : "BrtBeginPCDSCPItem" , f : parsenoop } , 214 : { n : "BrtEndPCDSCPItem" , f : parsenoop } , 215 : { n : "BrtBeginPCDSCSets" , f : parsenoop } , 216 : { n : "BrtEndPCDSCSets" , f : parsenoop } , 217 : { n : "BrtBeginPCDSCSet" , f : parsenoop } , 218 : { n : "BrtEndPCDSCSet" , f : parsenoop } , 219 : { n : "BrtBeginPCDFGroup" , f : parsenoop } , 220 : { n : "BrtEndPCDFGroup" , f : parsenoop } , 221 : { n : "BrtBeginPCDFGItems" , f : parsenoop } , 222 : { n : "BrtEndPCDFGItems" , f : parsenoop } , 223 : { n : "BrtBeginPCDFGRange" , f : parsenoop } , 224 : { n : "BrtEndPCDFGRange" , f : parsenoop } , 225 : { n : "BrtBeginPCDFGDiscrete" , f : parsenoop } , 226 : { n : "BrtEndPCDFGDiscrete" , f : parsenoop } , 227 : { n : "BrtBeginPCDSDTupleCache" , f : parsenoop } , 228 : { n : "BrtEndPCDSDTupleCache" , f : parsenoop } , 229 : { n : "BrtBeginPCDSDTCEntries" , f : parsenoop } , 230 : { n : "BrtEndPCDSDTCEntries" , f : parsenoop } , 231 : { n : "BrtBeginPCDSDTCEMembers" , f : parsenoop } , 232 : { n : "BrtEndPCDSDTCEMembers" , f : parsenoop } , 233 : { n : "BrtBeginPCDSDTCEMember" , f : parsenoop } , 234 : { n : "BrtEndPCDSDTCEMember" , f : pars
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 _SXPair } , 249 : { n : "SxFmla" , f : parse _SxFmla } , 251 : { n : "SxFormat" , f : parse _SxFormat } , 252 : { n : "SST" , f : parse _SST } , 253 : { n : "LabelSst" , f : parse _LabelSst } , 255 : { n : "ExtSST" , f : parse _ExtSST } , 256 : { n : "SXVDEx" , f : parse _SXVDEx } , 259 : { n : "SXFormula" , f : parse _SXFormula } , 290 : { n : "SXDBEx" , f : parse _SXDBEx } , 311 : { n : "RRDInsDel" , f : parse _RRDInsDel } , 312 : { n : "RRDHead" , f : parse _RRDHead } , 315 : { n : "RRDChgCell" , f : parse _RRDChgCell } , 317 : { n : "RRTabId" , f : parse _RRTabId } , 318 : { n : "RRDRenSheet" , f : parse _RRDRenSheet } , 319 : { n : "RRSort" , f : parse _RRSort } , 320 : { n : "RRDMove" , f : parse _RRDMove } , 330 : { n : "RRFormat" , f : parse _RRFormat } , 331 : { n : "RRAutoFmt" , f : parse _RRAutoFmt } , 333 : { n : "RRInsertSh" , f : parse _RRInsertSh } , 334 : { n : "RRDMoveBegin" , f : parse _RRDMoveBegin } , 335 : { n : "RRDMoveEnd" , f : parse _RRDMoveEnd } , 336 : { n : "RRDInsDelBegin" , f : parse _RRDInsDelBegin } , 337 : { n : "RRDInsDelEnd" , f : parse _RRDInsDelEnd } , 338 : { n : "RRDConflict" , f : parse _RRDConflict } , 339 : { n : "RRDDefName" , f : parse _RRDDefName } , 340 : { n : "RRDRstEtxp" , f : parse _RRDRstEtxp } , 351 : { n : "LRng" , f : parse _LRng } , 352 : { n : "UsesELFs" , f : parse _UsesELFs } , 353 : { n : "DSF" , f : parse _DSF } , 401 : { n : "CUsr" , f : parse _CUsr } , 402 : { n : "CbUsr" , f : parse _CbUsr } , 403 : { n : "UsrInfo" , f : parse _UsrInfo } , 404 : { n : "UsrExcl" , f : parse _UsrExcl } , 405 : { n : "FileLock" , f : parse _FileLock } , 406 : { n : "RRDInfo" , f : parse _RRDInfo } , 407 : { n : "BCUsrs" , f : parse _BCUsrs } , 408 : { n : "UsrChk" , f : parse _UsrChk } , 425 : { n : "UserBView" , f : parse _UserBView } , 426 : { n : "UserSViewBegin" , f : parse _UserSViewBegin } , 427 : { n : "UserSViewEnd" , f : parse _UserSViewEnd } , 428 : { n : "RRDUserView" , f : parse _RRDUserView } , 429 : { n : "Qsi" , f : parse _Qsi } , 430 : { n : "SupBook" , f : parse _SupBook } , 431 : { n : "Prot4Rev" , f : parse _Prot4Rev } , 432 : { n : "CondFmt" , f : parse _CondFmt } , 433 : { n : "CF" , f : parse _CF } , 434 : { n : "DVal" , f : parse _DVal } , 437 : { n : " DC
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 ) . replace ( "//" , "/" ) ] = relobj } function write _zip ( wb , opts ) { if ( opts . bookType == "ods" ) return write _ods ( wb , opts ) ; if ( wb && ! wb . SSF ) { wb . SSF = SSF . get _table ( ) } if ( wb && wb . SSF ) { make _ssf ( SSF ) ; SSF . load _table ( wb . SSF ) ; opts . revssf = evert _num ( 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 = [ ] ; get _cell _style ( opts . cellXfs , { } , { revssf : { General : 0 } } ) ; if ( ! wb . Props ) wb . Props = { } ; f = "docProps/core.xml" ; zip . file ( f , write _core _props ( wb . Props , opts ) ) ; ct . coreprops . push ( f ) ; add _rels ( opts . rels , 2 , f , RELS . CORE _PROPS ) ; f = "docProps/app.xml" ; wb . Props . SheetNames = wb . SheetNames ; wb . Props . Worksheets = wb . SheetNames . length ; zip . file ( f , write _ext _props ( wb . Props , opts ) ) ; ct . extprops . push ( f ) ; add _rels ( opts . rels , 3 , f , RELS . EXT _PROPS ) ; if ( wb . Custprops !== wb . Props && keys ( wb . Custprops || { } ) . length > 0 ) { f = "docProps/custom.xml" ; zip . file ( f , write _cust _props ( wb . Custprops , opts ) ) ; ct . custprops . push ( f ) ; add _rels ( opts . rels , 4 , f , RELS . CUST _PROPS ) } f = "xl/workbook." + wbext ; zip . file ( f , write _wb ( wb , f , opts ) ) ; ct . workbooks . push ( f ) ; add _rels ( opts . rels , 1 , f , RELS . WB ) ; for ( rId = 1 ; rId <= wb . SheetNames . length ; ++ rId ) { f = "xl/worksheets/sheet" + rId + "." + wbext ; zip . file ( f , write _ws ( rId - 1 , f , opts , wb ) ) ; ct . sheets . push ( f ) ; add _rels ( opts . wbrels , rId , "worksheets/sheet" + rId + "." + wbext , RELS . WS ) } if ( opts . Strings != null && opts . Strings . length > 0 ) { f = "xl/sharedStrings." + wbext ; zip . file ( f , write _sst ( opts . Strings , f , opts ) ) ; ct . strs