Fix type error in sheets

pull/1/head
yflory 4 years ago committed by ansuz
parent c9540d36a8
commit 935fbc775f

@ -12867,13 +12867,13 @@ deleted){self.dependencyFormulas.delColumnTable(tableName,deleted);var wsActive=
wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback, wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback,
isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive= isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive=
function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex= function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex=
function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){return this.aWorksheetsById[id]};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName= function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){if(this.aWorksheetsById[id])return this.aWorksheetsById[id];var s;this.aWorksheets.some(function(_s){if(_s.Id===id){s=_s;return true}});return s};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==
function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName; name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,
oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null, this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName;oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);
null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();History.TurnOff();var wsActive=this.getActiveWs(); History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();
var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);newSheet.initPostOpen(this.wsHandlers, History.TurnOff();var wsActive=this.getActiveWs();var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);
{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),newSheet.getId(),tableNames,opt_base64)); newSheet.initPostOpen(this.wsHandlers,{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),
History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(), newSheet.getId(),tableNames,opt_base64));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(),
true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()}; true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()};
Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(), Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(),
{insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom, {insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom,

@ -10071,13 +10071,13 @@ deleted){self.dependencyFormulas.delColumnTable(tableName,deleted);var wsActive=
wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback, wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback,
isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive= isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive=
function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex= function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex=
function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){return this.aWorksheetsById[id]};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName= function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){if(this.aWorksheetsById[id])return this.aWorksheetsById[id];var s;this.aWorksheets.some(function(_s){if(_s.Id===id){s=_s;return true}});return s};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==
function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName; name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,
oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null, this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName;oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);
null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();History.TurnOff();var wsActive=this.getActiveWs(); History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();
var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);newSheet.initPostOpen(this.wsHandlers, History.TurnOff();var wsActive=this.getActiveWs();var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);
{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),newSheet.getId(),tableNames,opt_base64)); newSheet.initPostOpen(this.wsHandlers,{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),
History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(), newSheet.getId(),tableNames,opt_base64));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(),
true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()}; true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()};
Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(), Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(),
{insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom, {insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom,

@ -10019,13 +10019,13 @@ deleted){self.dependencyFormulas.delColumnTable(tableName,deleted);var wsActive=
wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback, wsActive.getHidden())wsActive.setHidden(false);if(!bNoBuildDep)this.dependencyFormulas.initOpen();if(bSnapshot)this.snapshot=this._getSnapshot()};Workbook.prototype.initPostOpenZip=function(pivotCaches){var t=this;this.forEach(function(ws){ws.initPostOpenZip(pivotCaches,t.oNumFmtsOpen)})};Workbook.prototype.setCommonIndexObjectsFrom=function(wb){this.oStyleManager=wb.oStyleManager;this.sharedStrings=wb.sharedStrings;this.workbookFormulas=wb.workbookFormulas};Workbook.prototype.forEach=function(callback,
isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive= isCopyPaste){if(isCopyPaste||isCopyPaste===false)callback(this.getActiveWs(),this.getActive());else for(var i=0,l=this.aWorksheets.length;i<l;++i)callback(this.aWorksheets[i],i)};Workbook.prototype.rebuildColors=function(){AscCommonExcel.g_oColorManager.rebuildColors();this.forEach(function(ws){ws.rebuildColors()})};Workbook.prototype.getDefaultFont=function(){return g_oDefaultFormat.Font.getName()};Workbook.prototype.getDefaultSize=function(){return g_oDefaultFormat.Font.getSize()};Workbook.prototype.getActive=
function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex= function(){return this.nActive};Workbook.prototype.getActiveWs=function(){return this.getWorksheet(this.nActive)};Workbook.prototype.setActive=function(index){if(index>=0&&index<this.aWorksheets.length){this.nActive=index;this.cleanFindResults();return true}return false};Workbook.prototype.setActiveById=function(sheetId){var ws=this.getWorksheetById(sheetId);if(!ws&&Array.isArray(this.aWorksheets))ws=this.aWorksheets[this.aWorksheets.length-1];return this.setActive(ws.getIndex())};Workbook.prototype.getSheetIdByIndex=
function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){return this.aWorksheetsById[id]};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName= function(index){var ws=this.getWorksheet(index);return ws?ws.getId():null};Workbook.prototype.getWorksheet=function(index){if(index>=0&&index<this.aWorksheets.length)return this.aWorksheets[index];return null};Workbook.prototype.getWorksheetById=function(id){if(this.aWorksheetsById[id])return this.aWorksheetsById[id];var s;this.aWorksheets.some(function(_s){if(_s.Id===id){s=_s;return true}});return s};Workbook.prototype.getWorksheetByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==
function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName; name)return this.aWorksheets[i];return null};Workbook.prototype.getWorksheetIndexByName=function(name){for(var i=0;i<this.aWorksheets.length;i++)if(this.aWorksheets[i].getName()==name)return i;return null};Workbook.prototype.getWorksheetCount=function(){return this.aWorksheets.length};Workbook.prototype.createWorksheet=function(indexBefore,sName,sId){this.dependencyFormulas.lockRecal();History.Create_NewPoint();History.TurnOff();var wsActive=this.getActiveWs();var oNewWorksheet=new Worksheet(this,
oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null, this.aWorksheets.length,sId);if(this.checkValidSheetName(sName))oNewWorksheet.sName=sName;oNewWorksheet.initPostOpen(this.wsHandlers,{});if(null!=indexBefore&&indexBefore>=0&&indexBefore<this.aWorksheets.length)this.aWorksheets.splice(indexBefore,0,oNewWorksheet);else{indexBefore=this.aWorksheets.length;this.aWorksheets.push(oNewWorksheet)}this.aWorksheetsById[oNewWorksheet.getId()]=oNewWorksheet;this._updateWorksheetIndexes(wsActive);History.TurnOn();this._insertWorksheetFormula(oNewWorksheet.index);
null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();History.TurnOff();var wsActive=this.getActiveWs(); History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId()));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames,opt_sheet,opt_base64){var renameParams;if(index>=0&&index<this.aWorksheets.length){this.dependencyFormulas.buildDependency();
var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);newSheet.initPostOpen(this.wsHandlers, History.TurnOff();var wsActive=this.getActiveWs();var wsFrom=opt_sheet?opt_sheet:this.aWorksheets[index];var newSheet=new Worksheet(this,-1,sId);if(null!=insertBefore&&insertBefore>=0&&insertBefore<this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);if(opt_sheet)this.addingWorksheet=newSheet;this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.copyFromFormulas(renameParams);
{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),newSheet.getId(),tableNames,opt_base64)); newSheet.initPostOpen(this.wsHandlers,{},{});History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams,opt_sheet);if(opt_sheet)this.dependencyFormulas.copyDefNameByWorkbook(wsFrom,newSheet,renameParams,opt_sheet);this._insertWorksheetFormula(insertBefore);if(!tableNames)tableNames=newSheet.getTableNames();History.Add(AscCommonExcel.g_oUndoRedoWorkbook,AscCH.historyitem_Workbook_SheetAdd,null,null,new UndoRedoData_SheetAdd(insertBefore,newSheet.getName(),wsFrom.getId(),
History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(), newSheet.getId(),tableNames,opt_base64));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());newSheet.copyFromAfterInsert(wsFrom);if(!(bFromRedo===true)){wsFrom.copyObjects(newSheet,renameParams);var i;if(wsFrom.aNamedSheetViews)for(i=0;i<wsFrom.aNamedSheetViews.length;++i)newSheet.addNamedSheetView(wsFrom.aNamedSheetViews[i].clone(renameParams.tableNameMap));if(wsFrom.dataValidations&&wsFrom.dataValidations.elems)for(i=0;i<wsFrom.dataValidations.elems.length;++i)newSheet.addDataValidation(wsFrom.dataValidations.elems[i].clone(),
true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()}; true)}this.sortDependency();if(opt_sheet)this.addingWorksheet=null}return renameParams};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index<this.aWorksheets.length)this.aWorksheets.splice(index,0,sheet);else this.aWorksheets.push(sheet);this.aWorksheetsById[sheet.getId()]=sheet;this._updateWorksheetIndexes(wsActive);this._insertWorksheetFormula(index);this._insertTablePartsName(sheet);sheet._BuildDependencies(sheet.getCwf());this.sortDependency()};
Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(), Workbook.prototype._insertTablePartsName=function(sheet){if(sheet&&sheet.TableParts&&sheet.TableParts.length)for(var i=0;i<sheet.TableParts.length;i++){var tablePart=sheet.TableParts[i];this.dependencyFormulas.addTableName(sheet,tablePart);tablePart.buildDependencies()}};Workbook.prototype._insertWorksheetFormula=function(index){if(index>0&&index<this.aWorksheets.length){var oWsBefore=this.aWorksheets[index-1];this.dependencyFormulas.changeSheet(this.dependencyFormulas.prepareChangeSheet(oWsBefore.getId(),
{insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom, {insert:index}))}};Workbook.prototype.replaceWorksheet=function(indexFrom,indexTo){if(indexFrom>=0&&indexFrom<this.aWorksheets.length&&indexTo>=0&&indexTo<this.aWorksheets.length){var wsActive=this.getActiveWs();var oWsFrom=this.aWorksheets[indexFrom];var tempW={wF:oWsFrom,wFI:indexFrom,wTI:indexTo};if(tempW.wFI<tempW.wTI)tempW.wTI++;this.dependencyFormulas.lockRecal();var prepared=this.dependencyFormulas.prepareChangeSheet(oWsFrom.getId(),{replace:tempW},null);var movedSheet=this.aWorksheets.splice(indexFrom,

Loading…
Cancel
Save