2014-02-17 08:44:22 +00:00
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
2014-05-29 22:30:03 +00:00
var XLSX = { } ; ( function ( XLSX ) { XLSX . version = "0.7.4" ; var current _codepage = 1252 , current _cptable ; if ( typeof module !== "undefined" && typeof require !== "undefined" ) { if ( typeof cptable === "undefined" ) cptable = require ( "./dist/cpexcel" ) ; current _cptable = cptable [ current _codepage ] } function reset _cp ( ) { set _cp ( 1252 ) } function set _cp ( cp ) { current _codepage = cp ; if ( typeof cptable !== "undefined" ) current _cptable = cptable [ cp ] } var _getchar = function ( x ) { return String . fromCharCode ( x ) } ; if ( typeof cptable !== "undefined" ) _getchar = function ( x ) { if ( current _codepage === 1200 ) return String . fromCharCode ( x ) ; if ( current _cptable ) return current _cptable . dec [ x ] ; return cptable . utils . decode ( current _codepage , [ x % 256 , x >> 8 ] ) [ 0 ] } ; function char _codes ( data ) { return data . split ( "" ) . map ( function ( x ) { return x . charCodeAt ( 0 ) } ) } function debom _xml ( data ) { if ( typeof cptable !== "undefined" ) { if ( data . charCodeAt ( 0 ) === 255 && data . charCodeAt ( 1 ) === 254 ) { return cptable . utils . decode ( 1200 , char _codes ( data . substr ( 2 ) ) ) } } return data } var SSF = { } ; var make _ssf = function ( SSF ) { var _strrev = function ( x ) { return String ( x ) . split ( "" ) . reverse ( ) . join ( "" ) } ; function fill ( c , l ) { return new Array ( l + 1 ) . join ( c ) } function pad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ? t : fill ( c || 0 , d - t . length ) + t } function rpad ( v , d , c ) { var t = String ( v ) ; return t . length >= d ? t : t + fill ( c || 0 , d - t . length ) } SSF . version = "0.7.0" ; var opts _fmt = { date1904 : 0 , output : "" , WTF : false } ; function fixopts ( o ) { for ( var y in opts _fmt ) if ( o [ y ] === undefined ) o [ y ] = opts _fmt [ y ] } SSF . opts = opts _fmt ; var table _fmt = { 0 : "General" , 1 : "0" , 2 : "0.00" , 3 : "#,##0" , 4 : "#,##0.00" , 9 : "0%" , 10 : "0.00%" , 11 : "0.00E+00" , 12 : "# ?/?" , 13 : "# ??/??" , 14 : "m/d/yy" , 15 : "d-mmm-yy" , 16 : "d-mmm" , 17 : "mmm-yy" , 18 : "h:mm AM/PM" , 19 : "h:mm:ss AM/PM" , 20 : "h:mm" , 21 : "h:mm:ss" , 22 : "m/d/yy h:mm" , 37 : "#,##0 ;(#,##0)" , 38 : "#,##0 ;[Red](#,##0)" , 39 : "#,##0.00;(#,##0.00)" , 40 : "#,##0.00;[Red](#,##0.00)" , 45 : "mm:ss" , 46 : "[h]:mm:ss" , 47 : "mmss.0" , 48 : "##0.0E+0" , 49 : "@" , 56 : '"上午/下午 "hh"時"mm"分"ss"秒 "' , 65535 : "General" } ; var days = [ [ "Sun" , "Sunday" ] , [ "Mon" , "Monday" ] , [ "Tue" , "Tuesday" ] , [ "Wed" , "Wednesday" ] , [ "Thu" , "Thursday" ] , [ "Fri" , "Friday" ] , [ "Sat" , "Saturday" ] ] ; var months = [ [ "J" , "Jan" , "January" ] , [ "F" , "Feb" , "February" ] , [ "M" , "Mar" , "March" ] , [ "A" , "Apr" , "April" ] , [ "M" , "May" , "May" ] , [ "J" , "Jun" , "June" ] , [ "J" , "Jul" , "July" ] , [ "A" , "Aug" , "August" ] , [ "S" , "Sep" , "September" ] , [ "O" , "Oct" , "October" ] , [ "N" , "Nov" , "November" ] , [ "D" , "Dec" , "December" ] ] ; var frac = function frac ( x , D , mixed ) { var sgn = x < 0 ? - 1 : 1 ; var B = x * sgn ; var P _2 = 0 , P _1 = 1 , P = 0 ; var Q _2 = 1 , Q _1 = 0 , Q = 0 ; var A = Math . floor ( B ) ; while ( Q _1 < D ) { A = Math . floor ( B ) ; P = A * P _1 + P _2 ; Q = A * Q _1 + Q _2 ; if ( B - A < 5e-10 ) break ; B = 1 / ( B - A ) ; P _2 = P _1 ; P _1 = P ; Q _2 = Q _1 ; Q _1 = Q } if ( Q > D ) { Q = Q _1 ; P = P _1 } if ( Q > D ) { Q = Q _2 ; P = P _2 } if ( ! mixed ) return [ 0 , sgn * P , Q ] ; if ( Q === 0 ) throw "Unexpected state: " + P + " " + P _1 + " " + P _2 + " " + Q + " " + Q _1 + " " + Q _2 ; var q = Math . floor ( sgn * P / Q ) ; return [ q , sgn * P - q * Q , Q ] } ; var general _fmt = function ( v , opts ) { if ( typeof v === "boolean" ) return v ? "TRUE" : "FALSE" ; if ( typeof v === "number" ) { var o , V = v < 0 ? - v : v ; if ( V >= . 1 && V < 1 ) o = v . toPrecision ( 9 ) ; else if ( V >= . 01 && V < . 1 ) o = v . toPrecision ( 8 ) ; else if ( V >= . 001 && V < . 01 ) o = v . toPrecision ( 7 ) ; else if ( V >= 1e-4 && V < . 001 ) o = v . toPrecision ( 6 ) ; else if ( V >= Math . pow ( 10 , 10 ) && V < Math . pow ( 10 , 11 ) ) o = v . toFixed ( 10 ) . substr ( 0 , 12 ) ; else if ( V > Math . pow ( 10 , - 9 ) && V < Math . pow ( 10 , 11 ) ) { o = v . toFixed ( 12 ) . replace ( /(\.[0-9]*[1-9])0*$/ , "$1" ) . replace ( /\.$/ , "" ) ; if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toPrecision ( 10 ) ; if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toExponential ( 5 ) } else { o = v . toFixed ( 11 ) . replace ( /(\.[0-9]*[1-9])0*$/ , "$1" ) ; if ( o . length > ( v < 0 ? 12 : 11 ) ) o = v . toPrecision ( 6 ) } o = o . replace ( /(\.[0-9]*[1-9])0+e/ , "$1e" ) . replace ( /\.0*e/ , "e" ) ; return o . replace ( "e" , "E" ) . replace ( /\.0*$/ , "" ) . replace ( /\.([0-9]*[^0])0*$/ , ".$1" ) . replace ( /(E[+-])([0-9])$/ , "$1" + "0" + "$2" ) } if ( typeof v === "string" ) return v ; throw new Error ( "unsupported value in General format: " + v ) } ; SSF . _general = general _fmt ; function fix _hijri ( date , o ) { return 0 } var parse _date _code = function parse _date _code ( v , opts , b2 ) { var date = Math . floor ( v ) , time = Math . floor ( 86400 * ( v - date ) + 1e-6 ) , dow = 0 ; var dout = [ ] ; var out = { D : date , T : time , u : 86400 * ( v - date ) - time , y : 0 , m : 0 , d : 0 , H : 0 , M : 0 , S : 0 , q : 0 } ; fixopts ( opts = opts || { } ) ; if ( opts . date1904 ) date += 1462 ; if ( date > 2958465 ) return null ; if ( out . u > . 999 ) { out . u = 0 ; if ( ++ time == 86400 ) { time = 0 ; ++ date } } if ( date === 60 ) { dout = b2 ? [ 1317 , 10 ,
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 ( ct2type , true ) ; XMLNS . CT = "http://schemas.openxmlformats.org/package/2006/content-types" ; function parse _ct ( data , opts ) { var ctext = { } ; if ( ! data || ! data . match ) return data ; var ct = { workbooks : [ ] , sheets : [ ] , calcchains : [ ] , themes : [ ] , styles : [ ] , coreprops : [ ] , extprops : [ ] , custprops : [ ] , strs : [ ] , comments : [ ] , vba : [ ] , TODO : [ ] , rels : [ ] , xmlns : "" } ; ( data . match ( /<[^>]*>/g ) || [ ] ) . forEach ( function ( x ) { var y = parsexmltag ( x ) ; switch ( y [ 0 ] . replace ( /<\w*:/ , "<" ) ) { 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 ( y . ContentType in ct2type ) ct [ ct2type [ y . ContentType ] ] . push ( y . PartName ) ; else if ( opts . WTF ) console . error ( y ) ; break } } ) ; if ( ct . xmlns !== XMLNS . CT ) throw new Error ( "Unknown Namespace: " + ct . xmlns ) ; ct . calcchain = ct . calcchains . length > 0 ? ct . calcchains [ 0 ] : "" ; ct . sst = ct . strs . length > 0 ? ct . strs [ 0 ] : "" ; ct . style = ct . styles . length > 0 ? ct . styles [ 0 ] : "" ; ct . defaults = ctext ; delete ct . calcchains ; return ct } var CTYPE _XML _ROOT = writextag ( "Types" , null , { xmlns : XMLNS . CT , "xmlns:xsd" : XMLNS . xsd , "xmlns:xsi" : XMLNS . xsi } ) ; var CTYPE _DEFAULTS = [ [ "xml" , "application/xml" ] , [ "bin" , "application/vnd.ms-excel.sheet.binary.macroEnabled.main" ] , [ "rels" , type2ct . rels [ 0 ] ] ] . map ( function ( x ) { return writextag ( "Default" , null , { Extension : x [ 0 ] , ContentType : x [ 1 ] } ) } ) ; function write _ct ( ct , opts ) { var o = [ ] , v ; o . push ( XML _HEADER ) ; o . push ( CTYPE _XML _ROOT ) ; o = o . concat ( CTYPE _DEFAULTS ) ; var f1 = function ( w ) { if ( ct [ w ] && ct [ w ] . length > 0 ) { v = ct [ w ] [ 0 ] ; o . push ( writextag ( "Override" , null , { PartName : ( v [ 0 ] == "/" ? "" : "/" ) + v , ContentType : CT _LIST [ w ] [ opts . bookType || "xlsx" ] } ) ) } } ; var f2 = function ( w ) { ct [ w ] . forEach ( function ( v ) { o . push ( writextag ( "Override" , null , { PartName : ( v [ 0 ] == "/" ? "" : "/" ) + v , ContentType : CT _LIST [ w ] [ opts . bookType || "xlsx" ] } ) ) } ) } ; var f3 = function ( t ) { ( ct [ t ] || [ ] ) . forEach ( function ( v ) { o . push ( writextag ( "Override" , null , { PartName : ( v [ 0 ] == "/" ? "" : "/" ) + v , ContentType : type2ct [ t ] [ 0 ] } ) ) } ) } ; f1 ( "workbooks" ) ; f2 ( "sheets" ) ; f3 ( "themes" ) ; [ "strs" , "styles" ] . forEach ( f1 ) ; [ "coreprops" , "extprops" , "custprops" ] . forEach ( f3 ) ; if ( o . length > 2 ) { o . push ( "</Types>" ) ; o [ 1 ] = o [ 1 ] . replace ( "/>" , ">" ) } return o . join ( "" ) } var RELS = { WB : "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" , SHEET : "http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument" } ; function parse _rels ( data , currentFilePath ) { if ( ! data ) return data ; if ( currentFilePath . charAt ( 0 ) !== "/" ) { currentFilePath = "/" + currentFilePath } var rels = { } ; var hash = { } ; var resolveRelativePathIntoAbsolute = function ( to ) { var toksFrom = currentFilePath . split ( "/" ) ; toksFrom . pop ( ) ; var toksTo = to . split ( "/" ) ; var reversed = [ ] ; while ( toksTo . length !== 0 ) { var tokTo = toksTo . shift ( ) ; if ( tokTo === ".." ) { toksFrom . pop ( ) } else if ( tokTo !== "." ) { toksFrom . push ( tokTo ) } } return toksFrom . join ( "/" ) } ; data . match ( /<[^>]*>/g ) . forEach ( function ( x ) { var y = parsexmltag ( x ) ; if ( y [ 0 ] === "<Relationship" ) { var rel = { } ; rel . Type = y . Type ; rel . Target = y . Target ; rel . Id = y . Id ; rel . TargetMode = y . TargetMode ; var canonictarget = y . TargetMode === "External" ? y . Target : resolveRelativePathIntoAbsolute ( y . Target ) ; rels [ canonictarget ] = rel ; hash [ y . Id ] = rel } } ) ; rels [ "!id" ] = hash ; return rels } XMLNS . RELS = "http://schemas.openxmlformats.org/package/2006/relationships" ; var RELS _ROOT = writextag ( "Relationships" , null , { xmlns : XM
2014-05-31 15:44:56 +00:00
authors . push ( x . match ( /<(?:\w+:)?author[^>]*>(.*)/ ) [ 1 ] ) } ) ; ( data . match ( /<(?:\w+:)?commentList>([^\u2603]*)<\/(?:\w+:)?commentList>/m ) || [ "" , "" ] ) [ 1 ] . split ( /<\/(?:\w+:)?comment>/ ) . forEach ( function ( x , index ) { if ( x === "" || x . trim ( ) === "" ) return ; var y = parsexmltag ( x . match ( /<(?:\w+:)?comment[^>]*>/ ) [ 0 ] ) ; var comment = { author : y . authorId && authors [ y . authorId ] ? authors [ y . authorId ] : undefined , ref : y . ref , guid : y . guid } ; var cell = decode _cell ( y . ref ) ; if ( opts . sheetRows && opts . sheetRows <= cell . r ) return ; var textMatch = x . match ( /<text>([^\u2603]*)<\/text>/m ) ; if ( ! textMatch || ! textMatch [ 1 ] ) return ; var rt = parse _si ( textMatch [ 1 ] ) ; comment . r = rt . r ; comment . t = rt . t ; if ( opts . cellHTML ) comment . h = rt . h ; commentList . push ( comment ) } ) ; return commentList } function write _comments _xml ( data , opts ) { } var parse _BrtBeginComment = function ( data , length ) { var out = { } ; out . iauthor = data . read _shift ( 4 ) ; var rfx = parse _UncheckedRfX ( data , 16 ) ; out . rfx = rfx . s ; out . ref = encode _cell ( rfx . s ) ; data . l += 16 ; return out } ; var parse _BrtCommentAuthor = parse _XLWideString ; var parse _BrtCommentText = parse _RichStr ; function parse _comments _bin ( data , opts ) { var out = [ ] ; var authors = [ ] ; var c = { } ; var pass = false ; recordhopper ( data , function ( val , R , RT ) { switch ( R . n ) { case "BrtCommentAuthor" : authors . push ( val ) ; break ; case "BrtBeginComment" : c = val ; break ; case "BrtCommentText" : c . t = val . t ; c . h = val . h ; c . r = val . r ; break ; case "BrtEndComment" : c . author = authors [ c . iauthor ] ; delete c . iauthor ; if ( opts . sheetRows && opts . sheetRows <= c . rfx . r ) break ; delete c . rfx ; out . push ( c ) ; break ; case "BrtBeginComments" : break ; case "BrtEndComments" : break ; case "BrtBeginCommentAuthors" : break ; case "BrtEndCommentAuthors" : break ; case "BrtBeginCommentList" : break ; case "BrtEndCommentList" : break ; default : if ( ! pass || opts . WTF ) throw new Error ( "Unexpected record " + RT + " " + R . n ) } } ) ; return out } function write _comments _bin ( data , opts ) { } function parse _comments ( zip , dirComments , sheets , sheetRels , opts ) { for ( var i = 0 ; i != dirComments . length ; ++ i ) { var canonicalpath = dirComments [ i ] ; var comments = parse _cmnt ( getzipdata ( zip , canonicalpath . replace ( /^\// , "" ) , true ) , canonicalpath , opts ) ; if ( ! comments || ! comments . length ) continue ; var sheetNames = keys ( sheets ) ; for ( var j = 0 ; j != sheetNames . length ; ++ j ) { var sheetName = sheetNames [ j ] ; var rels = sheetRels [ sheetName ] ; if ( rels ) { var rel = rels [ canonicalpath ] ; if ( rel ) insertCommentsIntoSheet ( sheetName , sheets [ sheetName ] , comments ) } } } } function insertCommentsIntoSheet ( sheetName , sheet , comments ) { comments . forEach ( function ( comment ) { var cell = sheet [ comment . ref ] ; if ( ! cell ) { cell = { } ; sheet [ comment . ref ] = cell ; var range = decode _range ( sheet [ "!ref" ] || "BDWGO1000001:A1" ) ; var thisCell = decode _cell ( comment . ref ) ; if ( range . s . r > thisCell . r ) range . s . r = thisCell . r ; if ( range . e . r < thisCell . r ) range . e . r = thisCell . r ; if ( range . s . c > thisCell . c ) range . s . c = thisCell . c ; if ( range . e . c < thisCell . c ) range . e . c = thisCell . c ; var encoded = encode _range ( range ) ; if ( encoded !== sheet [ "!ref" ] ) sheet [ "!ref" ] = encoded } if ( ! cell . c ) cell . c = [ ] ; var o = { a : comment . author , t : comment . t , r : comment . r } ; if ( comment . h ) o . h = comment . h ; cell . c . push ( o ) } ) } var parse _CellParsedFormula = function ( data , length ) { var cce = data . read _shift ( 4 ) ; return parsenoop ( data , length - 4 ) } ; var strs = { } ; var _ssfopts = { } ; RELS . WS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" ; function get _sst _id ( sst , str ) { for ( var i = 0 ; i != sst . length ; ++ i ) if ( sst [ i ] . t === str ) { sst . Count ++ ; return i } sst [ sst . length ] = { t : str } ; sst . Count ++ ; sst . Unique ++ ; return sst . length - 1 } function get _cell _style ( styles , cell , opts ) { var z = opts . revssf [ cell . z || "General" ] ; for ( var i = 0 ; i != styles . length ; ++ i ) if ( styles [ i ] . numFmtId === z ) return i ; styles [ styles . length ] = { numFmtId : z , fontId : 0 , fillId : 0 , borderId : 0 , xfId : 0 , applyNumberFormat : 1 } ; return styles . length - 1 } function parse _ws _xml ( data , opts , rels ) { if ( ! data ) return data ; var s = { } , mtch ; var ref = data . match ( /<dimension ref="([^"]*)"\s*\/>/ ) ; if ( ref && ref . length == 2 && ref [ 1 ] . indexOf ( ":" ) !== - 1 ) s [ "!ref" ] = ref [ 1 ] ; var mergecells = [ ] ; if ( data . match ( /<\/mergeCells>/ ) ) { var merges = data . match ( /<mergeCell ref="([A-Z0-9:]+)"\s*\/>/g ) ; mergecells = merges . map ( function ( range ) { return decode _range ( /<mergeCell ref="([A-Z0-9:]+)"\s*\/>/ . exec ( range ) [ 1 ] ) } ) } var refguess = { s : { r : 1e6 , c : 1e6 } , e : { r : 0 , c : 0 } } ; var sidx = 0 ; var match _v = matchtag ( "v" ) , match _f = matchtag ( "f" ) ; mtch = data . match ( / < ( ? : \ w + : ) ? s h
2014-05-29 22:30:03 +00:00
var evert _RE = evert ( RecordEnum , "n" ) ; function fix _opts ( defaults ) { return function ( opts ) { defaults . forEach ( function ( d ) { if ( typeof opts [ d [ 0 ] ] === "undefined" ) opts [ d [ 0 ] ] = d [ 1 ] ; if ( d [ 2 ] === "n" ) opts [ d [ 0 ] ] = Number ( opts [ d [ 0 ] ] ) } ) } } var fix _read _opts = fix _opts ( [ [ "cellNF" , false ] , [ "cellHTML" , true ] , [ "cellFormula" , true ] , [ "cellStyles" , false ] , [ "sheetStubs" , false ] , [ "sheetRows" , 0 , "n" ] , [ "bookDeps" , false ] , [ "bookSheets" , false ] , [ "bookProps" , false ] , [ "bookFiles" , false ] , [ "bookVBA" , false ] , [ "WTF" , false ] ] ) ; var fix _write _opts = fix _opts ( [ [ "bookSST" , false ] , [ "bookType" , "xlsx" ] , [ "WTF" , false ] ] ) ; function parse _zip ( zip , opts ) { make _ssf ( SSF ) ; opts = opts || { } ; fix _read _opts ( opts ) ; reset _cp ( ) ; var entries = keys ( zip . files ) . filter ( function ( x ) { return x . substr ( - 1 ) != "/" } ) . sort ( ) ; var dir = parse _ct ( getzipdata ( 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 ] . substr ( - 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 ( /^\// , "" ) ) , 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 = getzipdata ( zip , dir . coreprops [ 0 ] . replace ( /^\// , "" ) , true ) ; if ( propdata ) props = parse _core _props ( propdata ) ; if ( dir . extprops . length !== 0 ) { propdata = getzipdata ( zip , dir . extprops [ 0 ] . replace ( /^\// , "" ) , true ) ; if ( propdata ) parse _ext _props ( propdata , props ) } } var custprops = { } ; if ( ! opts . bookSheets || opts . bookProps ) { if ( dir . custprops . length !== 0 ) { propdata = getzipdata ( 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 ( 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 ( getzipdata ( zip , wbrelsfile , true ) , wbrelsfile ) ; if ( wbrels ) try { wbrels = wb . Sheets . map ( function ( w ) { return [ w . name , wbrels [ "!id" ] [ w . id ] . Target ] } ) } catch ( e ) { wbrels = null } if ( wbrels && wbrels . length === 0 ) wbrels = null ; var nmode = getzipdata ( zip , "xl/worksheets/sheet.xml" , true ) ? 1 : 0 ; for ( i = 0 ; i != props . Worksheets ; ++ i ) { try { if ( wbrels ) 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" ) ; sheetRels [ props . SheetNames [ i ] ] = parse _rels ( getzipdata ( zip , relsPath , true ) , path ) ; sheets [ props . SheetNames [ i ] ] = parse _ws ( getzipdata ( zip , path ) , path , opts , sheetRels [ props . SheetNames [ i ] ] ) } catch ( e ) { if ( opts . WTF ) throw e } } 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 . bin === " application / vnd . ms - office . vbaP
2014-02-17 08:44:22 +00:00
//# sourceMappingURL=dist/xlsx.min.map