var XMLNS_WB = [ 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', 'http://schemas.microsoft.com/office/excel/2006/main', 'http://schemas.microsoft.com/office/excel/2006/2' ]; /* 18.2 Workbook */ function parse_wb_xml(data) { var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" }; var pass = false; data.match(/<[^>]*>/g).forEach(function(x) { var y = parsexmltag(x); switch(y[0]) { case '': break; /* 18.2.13 fileVersion CT_FileVersion ? */ case '': break; /* 18.2.12 fileSharing CT_FileSharing ? */ case '': break; /* 18.2.28 workbookPr CT_WorkbookPr ? */ case '': delete y[0]; wb.WBProps = y; break; /* 18.2.29 workbookProtection CT_WorkbookProtection ? */ case '': break; /* 18.2.1 bookViews CT_BookViews ? */ case '': case '': break; /* 18.2.30 workbookView CT_BookView + */ case '': case '': break; // aggregate sheet /* 18.2.19 sheet CT_Sheet + */ case '': break; /* 18.2.14 functionGroup CT_FunctionGroup + */ case '': break; /* 18.2.8 externalReference CT_ExternalReference + */ case '': break; case '': pass=true; break; case '': pass=false; break; /* 18.2.5 definedName CT_DefinedName + */ case '': case '': break; /* 18.2.2 calcPr CT_CalcPr ? */ case '': delete y[0]; wb.CalcPr = y; break; /* 18.2.16 oleSize CT_OleSize ? (ref required) */ case '': case '': case '': break; /* 18.2.18 pivotCaches CT_PivotCaches ? */ case '': case '': case '': break; /* 18.2.23 smartTagTypes CT_SmartTagTypes ? */ case '': case '': break; /* 18.2.22 smartTagType CT_SmartTagType ? */ case '': break; /* 18.2.11 fileRecoveryPr CT_FileRecoveryPr ? */ case '': break; /* 18.2.26 webPublishObjects CT_WebPublishObjects ? */ case '': case '': break; /* 18.2.25 webPublishObject CT_WebPublishObject ? */ case '': case '': case '': break; /* 18.2.7 ext CT_Extension + */ case '': pass=false; break; /* Others */ case '': pass=false; break; } }); if(XMLNS_WB.indexOf(wb.xmlns) === -1) throw new Error("Unknown Namespace: " + wb.xmlns); var z; /* defaults */ for(z in WBPropsDef) if(typeof wb.WBProps[z] === 'undefined') wb.WBProps[z] = WBPropsDef[z]; for(z in CalcPrDef) if(typeof wb.CalcPr[z] === 'undefined') wb.CalcPr[z] = CalcPrDef[z]; wb.WBView.forEach(function(w){for(var z in WBViewDef) if(typeof w[z] === 'undefined') w[z]=WBViewDef[z]; }); wb.Sheets.forEach(function(w){for(var z in SheetDef) if(typeof w[z] === 'undefined') w[z]=SheetDef[z]; }); _ssfopts.date1904 = parsexmlbool(wb.WBProps.date1904, 'date1904'); return wb; }