diff --git a/www/common/onlyoffice/v2/sdkjs/cell/sdk-all.js b/www/common/onlyoffice/v2/sdkjs/cell/sdk-all.js index e0a155348..0bc2199ed 100644 --- a/www/common/onlyoffice/v2/sdkjs/cell/sdk-all.js +++ b/www/common/onlyoffice/v2/sdkjs/cell/sdk-all.js @@ -12269,212 +12269,212 @@ null;this.clrSchemeMap=null;this.CellStyles=new AscCommonExcel.CCellStyles;this. 0)this.nActive=0;if(this.nActive>=this.aWorksheets.length)this.nActive=this.aWorksheets.length-1;var self=this;this.wsHandlers=new AscCommonExcel.asc_CHandlersList({"changeRefTablePart":function(table){self.dependencyFormulas.changeTableRef(table)},"changeColumnTablePart":function(tableName){self.dependencyFormulas.renameTableColumn(tableName)},"deleteColumnTablePart":function(tableName,deleted){self.dependencyFormulas.delColumnTable(tableName,deleted)},"onFilterInfo":function(){self.handlers.trigger("asc_onFilterInfo")}}); for(var i=0,length=tableCustomFunc.length;i=0&&index= -0&&index=0&&indexBefore=0&&index=0&&insertBefore=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length=this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0, -g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges(); -var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i -0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType,elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas, -changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges=true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i= -end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions=options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count,index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory= -new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom=startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase= -Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk=function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16| -this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+=index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+ -4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1];this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+ -7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount=0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this); -this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange, -new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet=this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone(); -var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!=to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!== -to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules=[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined? -new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter=new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink= -null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom=function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table= -[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res=getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize, -gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws=new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor(); -else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc=0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom? -Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction=function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row, -col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator=AscCommonExcel.ECfOperator.Operator_containsText; -break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&&oRuleElement.getFormula&&oRuleElement.getFormula(this, -formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this, -oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf: -null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val? -rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat(): -""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName= -function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(),null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName); -var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor=function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null}; -Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())}; -Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&&this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex= -oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]}; -Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value));view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}}; -Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result= -this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i=removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0, -0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents=function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow= -cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed=shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift= -AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone();newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(), -newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies(); -cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange= -new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp;this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex= -row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border,g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol: -cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns);this.updatePivotOffset(oActualRange,offset); -this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount, -this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count-1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)}, -function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+ -1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()};Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal(); -History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp;this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex= -col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders= -this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount= -Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i< -index+count;++i)this.cellsByCol[i]=prevCellsByCol.clone();this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(0,index,gc_nMaxRow0,index+count-1)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddCols,this.getId(),new Asc.Range(index,0,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(false,index, -index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertColsAfter=function(index,count){return this.insertColsBefore(index+1,count)};Worksheet.prototype.getDefaultWidth=function(){return this.oSheetFormatPr.dDefaultColWidth};Worksheet.prototype.getDefaultFontName=function(){return this.workbook.getDefaultFont()};Worksheet.prototype.getDefaultFontSize=function(){return this.workbook.getDefaultSize()}; -Worksheet.prototype.getBaseColWidth=function(){return this.oSheetFormatPr.nBaseColWidth||8};Worksheet.prototype.charCountToModelColWidth=function(count){return this.workbook.charCountToModelColWidth(count)};Worksheet.prototype.modelColWidthToColWidth=function(mcw){return this.workbook.modelColWidthToColWidth(mcw)};Worksheet.prototype.colWidthToCharCount=function(w){return this.workbook.colWidthToCharCount(w)};Worksheet.prototype.getColWidth=function(index){var col=this._getColNoEmptyWithAll(index); -if(null!=col&&null!=col.width)return col.width;var dResult=this.oSheetFormatPr.dDefaultColWidth;if(dResult===undefined||dResult===null||dResult==0)dResult=-1;return dResult};Worksheet.prototype.setColWidth=function(width,start,stop){width=this.charCountToModelColWidth(width);if(0==width)return this.setColHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oSelection=History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(start, -0,stop,gc_nMaxRow0);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var oThis=this,prevCol;var fProcessCol=function(col){if(col.width!=width){if(_summaryRight&&!bNotAddCollapsed&&col.getCollapsed())oThis.setCollapsedCol(false,null,col);else if(!_summaryRight&&!bNotAddCollapsed&&prevCol&&prevCol.getCollapsed())oThis.setCollapsedCol(false, -null,prevCol);prevCol=col;var oOldProps=col.getWidthProp();col.width=width;col.CustomWidth=true;col.BestFit=null;col.setHidden(null);oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(0==start&&gc_nMaxCol0==stop){var col=this.getAllCol();fProcessCol(col);for(var i in this.aCols){var col= -this.aCols[i];if(null!=col)fProcessCol(col)}}else{if(!_summaryRight)if(!bNotAddCollapsed&&start>0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden=function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden, -start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden, -null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index, -false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&& -outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(), -new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight,val));this.sheetPr.SummaryRight=val}; -Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(null,bDel); -var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val);var oNewProps=col.getOutlineLevel(); -if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit=!!(column.BestFit||null===column.BestFit&& -null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp, -oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i);else col=this._getCol(i); -if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes=null;if(null!= -this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection=History.GetSelection(); -if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null,row);else if(!_summaryBelow&& -!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}}; -if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getRowHidden= -function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow= -function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&&!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&& -outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow=function(bCollapse,rowIndex,curRow){var oThis=this; -var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex,0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow= -function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.setOutlineRow=function(val,start, -stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight=function(index){var isCustomHeight=false; -this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps=row.getHeightProp();row.setCustomHeight(!bBestFit); -row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range=this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow); -else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange=function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0(); -var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax=r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin, -nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData=new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style= -cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol;processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col, -fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs=oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount); -if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck=[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1, -c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1== -oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1, -oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0());if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength= -this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory=this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory, -oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom= -function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1, -oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i= -oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies=function(cellRange){var ca; -for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i=0&&index=0&&index=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,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId())); +History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet.index};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames){if(index>=0&&index=0&&insertBefore< +this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);var renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.initPostOpen(this.wsHandlers);History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams);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));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());if(!(bFromRedo===true))wsFrom.copyObjects(newSheet,wsFrom);this.sortDependency()}};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length= +this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0,g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+ +";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges();var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType, +elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas,changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges= +true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i=end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions= +options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count, +index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory=new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom= +startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase=Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk= +function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16|this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+= +index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1]; +this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount= +0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this);this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone(); +if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange,new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet= +this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!= +to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules= +[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined?new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter= +new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink=null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom= +function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table=[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res= +getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize,gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws= +new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor();else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc= +0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom?Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction= +function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator= +AscCommonExcel.ECfOperator.Operator_containsText;break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&& +oRuleElement.getFormula&&oRuleElement.getFormula(this,formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf: +null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row, +col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val= +""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row, +col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat():""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName=function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(), +null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName);var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor= +function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null};Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&& +this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex=oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId()); +History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]};Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value)); +view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result=this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i= +removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0,0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents= +function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow=cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed= +shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift=AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone(); +newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(),newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed; +if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies();cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows= +function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange=new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp; +this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex=row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border, +g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol:cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns); +this.updatePivotOffset(oActualRange,offset);this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}); +this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count- +1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)},function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true}; +Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()}; +Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp; +this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex=col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+ +count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount=Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden= +function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!== +undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden,null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col= +null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&&outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight, +val));this.sheetPr.SummaryRight=val};Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel(); +col.setOutlineLevel(null,bDel);var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val); +var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit= +!!(column.BestFit||null===column.BestFit&&null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i); +else col=this._getCol(i);if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes= +null;if(null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection= +History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null, +row);else if(!_summaryBelow&&!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index, +true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()}; +Worksheet.prototype.getRowHidden=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr? +this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&& +!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&&outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow= +function(bCollapse,rowIndex,curRow){var oThis=this;var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex, +0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow=function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)}; +Worksheet.prototype.setOutlineRow=function(val,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight= +function(index){var isCustomHeight=false;this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps= +row.getHeightProp();row.setCustomHeight(!bBestFit);row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range= +this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow);else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange= +function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0();var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax= +r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin,nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData= +new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style=cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol; +processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs= +oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck= +[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1,c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck, +oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1==oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1, +oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0()); +if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i +0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength=this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory= +this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight, +this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom=function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr= +this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1,oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount, +sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies= +function(cellRange){var ca;for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i=this.aWorksheets.length)this.nActive=this.aWorksheets.length-1;var self=this;this.wsHandlers=new AscCommonExcel.asc_CHandlersList({"changeRefTablePart":function(table){self.dependencyFormulas.changeTableRef(table)},"changeColumnTablePart":function(tableName){self.dependencyFormulas.renameTableColumn(tableName)},"deleteColumnTablePart":function(tableName,deleted){self.dependencyFormulas.delColumnTable(tableName,deleted)},"onFilterInfo":function(){self.handlers.trigger("asc_onFilterInfo")}}); for(var i=0,length=tableCustomFunc.length;i=0&&index= -0&&index=0&&indexBefore=0&&index=0&&insertBefore=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length=this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0, -g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges(); -var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i -0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType,elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas, -changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges=true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i= -end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions=options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count,index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory= -new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom=startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase= -Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk=function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16| -this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+=index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+ -4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1];this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+ -7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount=0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this); -this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange, -new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet=this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone(); -var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!=to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!== -to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules=[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined? -new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter=new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink= -null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom=function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table= -[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res=getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize, -gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws=new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor(); -else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc=0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom? -Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction=function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row, -col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator=AscCommonExcel.ECfOperator.Operator_containsText; -break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&&oRuleElement.getFormula&&oRuleElement.getFormula(this, -formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this, -oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf: -null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val? -rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat(): -""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName= -function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(),null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName); -var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor=function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null}; -Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())}; -Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&&this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex= -oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]}; -Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value));view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}}; -Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result= -this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i=removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0, -0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents=function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow= -cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed=shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift= -AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone();newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(), -newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies(); -cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange= -new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp;this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex= -row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border,g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol: -cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns);this.updatePivotOffset(oActualRange,offset); -this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount, -this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count-1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)}, -function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+ -1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()};Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal(); -History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp;this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex= -col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders= -this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount= -Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i< -index+count;++i)this.cellsByCol[i]=prevCellsByCol.clone();this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(0,index,gc_nMaxRow0,index+count-1)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddCols,this.getId(),new Asc.Range(index,0,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(false,index, -index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertColsAfter=function(index,count){return this.insertColsBefore(index+1,count)};Worksheet.prototype.getDefaultWidth=function(){return this.oSheetFormatPr.dDefaultColWidth};Worksheet.prototype.getDefaultFontName=function(){return this.workbook.getDefaultFont()};Worksheet.prototype.getDefaultFontSize=function(){return this.workbook.getDefaultSize()}; -Worksheet.prototype.getBaseColWidth=function(){return this.oSheetFormatPr.nBaseColWidth||8};Worksheet.prototype.charCountToModelColWidth=function(count){return this.workbook.charCountToModelColWidth(count)};Worksheet.prototype.modelColWidthToColWidth=function(mcw){return this.workbook.modelColWidthToColWidth(mcw)};Worksheet.prototype.colWidthToCharCount=function(w){return this.workbook.colWidthToCharCount(w)};Worksheet.prototype.getColWidth=function(index){var col=this._getColNoEmptyWithAll(index); -if(null!=col&&null!=col.width)return col.width;var dResult=this.oSheetFormatPr.dDefaultColWidth;if(dResult===undefined||dResult===null||dResult==0)dResult=-1;return dResult};Worksheet.prototype.setColWidth=function(width,start,stop){width=this.charCountToModelColWidth(width);if(0==width)return this.setColHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oSelection=History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(start, -0,stop,gc_nMaxRow0);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var oThis=this,prevCol;var fProcessCol=function(col){if(col.width!=width){if(_summaryRight&&!bNotAddCollapsed&&col.getCollapsed())oThis.setCollapsedCol(false,null,col);else if(!_summaryRight&&!bNotAddCollapsed&&prevCol&&prevCol.getCollapsed())oThis.setCollapsedCol(false, -null,prevCol);prevCol=col;var oOldProps=col.getWidthProp();col.width=width;col.CustomWidth=true;col.BestFit=null;col.setHidden(null);oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(0==start&&gc_nMaxCol0==stop){var col=this.getAllCol();fProcessCol(col);for(var i in this.aCols){var col= -this.aCols[i];if(null!=col)fProcessCol(col)}}else{if(!_summaryRight)if(!bNotAddCollapsed&&start>0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden=function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden, -start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden, -null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index, -false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&& -outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(), -new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight,val));this.sheetPr.SummaryRight=val}; -Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(null,bDel); -var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val);var oNewProps=col.getOutlineLevel(); -if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit=!!(column.BestFit||null===column.BestFit&& -null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp, -oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i);else col=this._getCol(i); -if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes=null;if(null!= -this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection=History.GetSelection(); -if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null,row);else if(!_summaryBelow&& -!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}}; -if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getRowHidden= -function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow= -function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&&!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&& -outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow=function(bCollapse,rowIndex,curRow){var oThis=this; -var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex,0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow= -function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.setOutlineRow=function(val,start, -stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight=function(index){var isCustomHeight=false; -this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps=row.getHeightProp();row.setCustomHeight(!bBestFit); -row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range=this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow); -else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange=function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0(); -var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax=r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin, -nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData=new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style= -cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol;processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col, -fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs=oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount); -if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck=[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1, -c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1== -oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1, -oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0());if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength= -this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory=this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory, -oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom= -function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1, -oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i= -oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies=function(cellRange){var ca; -for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i=0&&index=0&&index=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,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId())); +History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet.index};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames){if(index>=0&&index=0&&insertBefore< +this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);var renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.initPostOpen(this.wsHandlers);History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams);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));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());if(!(bFromRedo===true))wsFrom.copyObjects(newSheet,wsFrom);this.sortDependency()}};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length= +this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0,g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+ +";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges();var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType, +elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas,changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges= +true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i=end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions= +options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count, +index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory=new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom= +startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase=Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk= +function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16|this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+= +index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1]; +this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount= +0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this);this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone(); +if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange,new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet= +this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!= +to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules= +[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined?new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter= +new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink=null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom= +function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table=[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res= +getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize,gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws= +new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor();else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc= +0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom?Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction= +function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator= +AscCommonExcel.ECfOperator.Operator_containsText;break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&& +oRuleElement.getFormula&&oRuleElement.getFormula(this,formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf: +null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row, +col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val= +""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row, +col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat():""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName=function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(), +null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName);var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor= +function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null};Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&& +this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex=oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId()); +History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]};Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value)); +view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result=this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i= +removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0,0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents= +function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow=cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed= +shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift=AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone(); +newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(),newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed; +if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies();cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows= +function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange=new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp; +this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex=row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border, +g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol:cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns); +this.updatePivotOffset(oActualRange,offset);this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}); +this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count- +1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)},function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true}; +Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()}; +Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp; +this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex=col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+ +count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount=Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden= +function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!== +undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden,null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col= +null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&&outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight, +val));this.sheetPr.SummaryRight=val};Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel(); +col.setOutlineLevel(null,bDel);var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val); +var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit= +!!(column.BestFit||null===column.BestFit&&null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i); +else col=this._getCol(i);if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes= +null;if(null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection= +History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null, +row);else if(!_summaryBelow&&!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index, +true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()}; +Worksheet.prototype.getRowHidden=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr? +this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&& +!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&&outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow= +function(bCollapse,rowIndex,curRow){var oThis=this;var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex, +0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow=function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)}; +Worksheet.prototype.setOutlineRow=function(val,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight= +function(index){var isCustomHeight=false;this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps= +row.getHeightProp();row.setCustomHeight(!bBestFit);row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range= +this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow);else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange= +function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0();var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax= +r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin,nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData= +new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style=cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol; +processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs= +oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck= +[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1,c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck, +oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1==oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1, +oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0()); +if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i +0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength=this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory= +this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight, +this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom=function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr= +this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1,oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount, +sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies= +function(cellRange){var ca;for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i=this.aWorksheets.length)this.nActive=this.aWorksheets.length-1;var self=this;this.wsHandlers=new AscCommonExcel.asc_CHandlersList({"changeRefTablePart":function(table){self.dependencyFormulas.changeTableRef(table)},"changeColumnTablePart":function(tableName){self.dependencyFormulas.renameTableColumn(tableName)},"deleteColumnTablePart":function(tableName,deleted){self.dependencyFormulas.delColumnTable(tableName,deleted)},"onFilterInfo":function(){self.handlers.trigger("asc_onFilterInfo")}}); for(var i=0,length=tableCustomFunc.length;i=0&&index= -0&&index=0&&indexBefore=0&&index=0&&insertBefore=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length=this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0, -g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges(); -var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i -0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType,elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas, -changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges=true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i= -end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions=options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count,index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory= -new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom=startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase= -Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk=function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16| -this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+=index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+ -4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1];this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+ -7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount=0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this); -this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange, -new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet=this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone(); -var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!=to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!== -to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules=[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined? -new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter=new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink= -null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom=function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table= -[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res=getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize, -gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws=new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor(); -else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc=0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom? -Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction=function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row, -col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator=AscCommonExcel.ECfOperator.Operator_containsText; -break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&&oRuleElement.getFormula&&oRuleElement.getFormula(this, -formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this, -oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf: -null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val? -rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat(): -""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName= -function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(),null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName); -var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor=function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null}; -Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())}; -Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&&this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex= -oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]}; -Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value));view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}}; -Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result= -this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i=removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0, -0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents=function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow= -cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed=shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift= -AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone();newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(), -newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies(); -cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange= -new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp;this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex= -row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border,g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol: -cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns);this.updatePivotOffset(oActualRange,offset); -this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount, -this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count-1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)}, -function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+ -1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()};Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal(); -History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp;this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex= -col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders= -this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount= -Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i< -index+count;++i)this.cellsByCol[i]=prevCellsByCol.clone();this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(0,index,gc_nMaxRow0,index+count-1)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddCols,this.getId(),new Asc.Range(index,0,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(false,index, -index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true};Worksheet.prototype.insertColsAfter=function(index,count){return this.insertColsBefore(index+1,count)};Worksheet.prototype.getDefaultWidth=function(){return this.oSheetFormatPr.dDefaultColWidth};Worksheet.prototype.getDefaultFontName=function(){return this.workbook.getDefaultFont()};Worksheet.prototype.getDefaultFontSize=function(){return this.workbook.getDefaultSize()}; -Worksheet.prototype.getBaseColWidth=function(){return this.oSheetFormatPr.nBaseColWidth||8};Worksheet.prototype.charCountToModelColWidth=function(count){return this.workbook.charCountToModelColWidth(count)};Worksheet.prototype.modelColWidthToColWidth=function(mcw){return this.workbook.modelColWidthToColWidth(mcw)};Worksheet.prototype.colWidthToCharCount=function(w){return this.workbook.colWidthToCharCount(w)};Worksheet.prototype.getColWidth=function(index){var col=this._getColNoEmptyWithAll(index); -if(null!=col&&null!=col.width)return col.width;var dResult=this.oSheetFormatPr.dDefaultColWidth;if(dResult===undefined||dResult===null||dResult==0)dResult=-1;return dResult};Worksheet.prototype.setColWidth=function(width,start,stop){width=this.charCountToModelColWidth(width);if(0==width)return this.setColHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oSelection=History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(start, -0,stop,gc_nMaxRow0);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var oThis=this,prevCol;var fProcessCol=function(col){if(col.width!=width){if(_summaryRight&&!bNotAddCollapsed&&col.getCollapsed())oThis.setCollapsedCol(false,null,col);else if(!_summaryRight&&!bNotAddCollapsed&&prevCol&&prevCol.getCollapsed())oThis.setCollapsedCol(false, -null,prevCol);prevCol=col;var oOldProps=col.getWidthProp();col.width=width;col.CustomWidth=true;col.BestFit=null;col.setHidden(null);oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(0==start&&gc_nMaxCol0==stop){var col=this.getAllCol();fProcessCol(col);for(var i in this.aCols){var col= -this.aCols[i];if(null!=col)fProcessCol(col)}}else{if(!_summaryRight)if(!bNotAddCollapsed&&start>0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden=function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden, -start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden, -null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index, -false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&& -outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(), -new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight,val));this.sheetPr.SummaryRight=val}; -Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(null,bDel); -var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val);var oNewProps=col.getOutlineLevel(); -if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit=!!(column.BestFit||null===column.BestFit&& -null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp, -oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i);else col=this._getCol(i); -if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes=null;if(null!= -this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection=History.GetSelection(); -if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null,row);else if(!_summaryBelow&& -!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}}; -if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getRowHidden= -function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow= -function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&&!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&& -outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow=function(bCollapse,rowIndex,curRow){var oThis=this; -var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex,0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow= -function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.setOutlineRow=function(val,start, -stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight=function(index){var isCustomHeight=false; -this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps=row.getHeightProp();row.setCustomHeight(!bBestFit); -row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range=this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow); -else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange=function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0(); -var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax=r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin, -nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData=new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style= -cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol;processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col, -fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs=oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount); -if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck=[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1, -c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1== -oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1, -oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0());if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength= -this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory=this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory, -oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom= -function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1, -oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i= -oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet, -AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies=function(cellRange){var ca; -for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i=0&&index=0&&index=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,null,new UndoRedoData_SheetAdd(indexBefore,oNewWorksheet.getName(),null,oNewWorksheet.getId())); +History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(oNewWorksheet.getId());this.dependencyFormulas.unlockRecal();return oNewWorksheet.index};Workbook.prototype.copyWorksheet=function(index,insertBefore,sName,sId,bFromRedo,tableNames){if(index>=0&&index=0&&insertBefore< +this.aWorksheets.length)this.aWorksheets.splice(insertBefore,0,newSheet);else this.aWorksheets.push(newSheet);this.aWorksheetsById[newSheet.getId()]=newSheet;this._updateWorksheetIndexes(wsActive);var renameParams=newSheet.copyFrom(wsFrom,sName,tableNames);newSheet.initPostOpen(this.wsHandlers);History.TurnOn();this.dependencyFormulas.copyDefNameByWorksheet(wsFrom,newSheet,renameParams);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));History.SetSheetUndo(wsActive.getId());History.SetSheetRedo(newSheet.getId());if(!(bFromRedo===true))wsFrom.copyObjects(newSheet,wsFrom);this.sortDependency()}};Workbook.prototype.insertWorksheet=function(index,sheet){var wsActive=this.getActiveWs();if(null!=index&&index>=0&&index0&&index=0&&indexFrom=0&&indexTo=0;--i){ws=this.getWorksheet(i);if(false===ws.getHidden()){oRes=ws;break}}return oRes};Workbook.prototype.removeWorksheet=function(nIndex,outputParams){var bEmpty=true;for(var i=0,length= +this.aWorksheets.length;ig_nSheetNameMaxLength){name=name.substring(0,g_nSheetNameMaxLength-sPosfix.length);sNewName=name+sPosfix}var bUniqueName=true;for(var i=0;i0)aPointChangesBase64.push(nLen+ +";"+oMemory.GetBase64Memory2(nPosStart,nLen))}};Workbook.prototype.SerializeHistory=function(){var aRes=[];var t,j,length2;AscCommon.CollaborativeEditing.Refresh_DCChanges();var aActions=this.aCollaborativeActions.concat(History.GetSerializeArray());if(aActions.length>0){var oMemory=new AscCommon.CMemory;for(var i=0,length=aActions.length;i0)for(i=0;i0&&changesModify.length>0){var wbSnapshotCur=wbSnapshot._getSnapshot();var formulas=[];for(i=0;i0){this._forwardTransformationFormula(wbSnapshotCur._getSnapshot(),formulas,changesMasterSelected,res);formulas=[]}elem.oClass.Redo(elem.nActionType, +elem.oData,elem.nSheetId,wbSnapshotCur)}if(renameRes)this._forwardTransformationRenameEnd(renameRes,res.renameSheet,getRes,elem)}this._forwardTransformationFormula(wbSnapshotCur,formulas,changesMasterSelected,res)}return res};Workbook.prototype._forwardTransformationRenameStart=function(wbSnapshot,changes,getRes){var res={newName:null};for(var i=0;i0){var i,elem,ftFormula,ws;for(i=0;i0){this.bCollaborativeChanges= +true;var dstLen=0;var aIndexes=[],i,length=aChanges.length,sChange;for(i=0;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}if(!result2){if(options.scanForward){i=0;end=active}else{i=end-1;start=active+1}inc*=-1;for(;i=start;i+=inc){ws=this.getWorksheet(i);if(ws.getHidden())continue;result2=ws.findCellText(options);if(result2)break}}if(result2){this.handlers.trigger("undoRedoHideSheet",i);key=result2.col+"-"+result2.row}}if(key){this.lastFindOptions= +options.clone();this.lastFindCells[key]=true}}if(!result2&&!result)this.cleanFindResults();return result2||result};Workbook.prototype.getComment=function(id){if(id){var sheet;for(var i=0;i>0,index+1),this.maxIndex+1);if(newAllocatedCount>allocatedCount){var oldData=this.data;this.data=new Uint8Array(newAllocatedCount*this.structSize);if(oldData)this.data.set(oldData)}}this.count=Math.min(Math.max(this.count, +index+1),this.maxIndex+1)};SheetMemory.prototype.hasSize=function(index){return index+1<=this.count};SheetMemory.prototype.getSize=function(){return this.count};SheetMemory.prototype.clone=function(){var sheetMemory=new SheetMemory(this.structSize,this.maxIndex);sheetMemory.data=this.data?new Uint8Array(this.data):null;sheetMemory.count=this.count;return sheetMemory};SheetMemory.prototype.deleteRange=function(start,deleteCount){if(start0){var startOffsetFrom= +startFrom*this.structSize;var endOffsetFrom=(startFrom+countCopied)*this.structSize;var startOffsetTo=startTo*this.structSize;this.data.set(sheetMemory.data.subarray(startOffsetFrom,endOffsetFrom),startOffsetTo)}}var countErase=Math.min(count-countCopied,this.count-(startTo+countCopied));if(countErase>0){var startOffsetErase=(startTo+countCopied)*this.structSize;var endOffsetErase=(startTo+countCopied+countErase)*this.structSize;this.data.fill(0,startOffsetErase,endOffsetErase)}};SheetMemory.prototype.copyRangeByChunk= +function(from,fromCount,to,toCount){if(from>>8&255};SheetMemory.prototype.getUint32=function(index,offset){offset+=index*this.structSize;return AscFonts.FT_Common.IntToUInt(this.data[offset]|this.data[offset+1]<<8|this.data[offset+2]<<16|this.data[offset+3]<<24)};SheetMemory.prototype.setUint32=function(index,offset,val){offset+=index*this.structSize;this.data[offset]=val&255;this.data[offset+1]=val>>>8&255;this.data[offset+2]=val>>>16&255;this.data[offset+3]=val>>>24&255};SheetMemory.prototype.getFloat64=function(index,offset){offset+= +index*this.structSize;tempHelpUnit[0]=this.data[offset];tempHelpUnit[1]=this.data[offset+1];tempHelpUnit[2]=this.data[offset+2];tempHelpUnit[3]=this.data[offset+3];tempHelpUnit[4]=this.data[offset+4];tempHelpUnit[5]=this.data[offset+5];tempHelpUnit[6]=this.data[offset+6];tempHelpUnit[7]=this.data[offset+7];return tempHelpFloat[0]};SheetMemory.prototype.setFloat64=function(index,offset,val){offset+=index*this.structSize;tempHelpFloat[0]=val;this.data[offset]=tempHelpUnit[0];this.data[offset+1]=tempHelpUnit[1]; +this.data[offset+2]=tempHelpUnit[2];this.data[offset+3]=tempHelpUnit[3];this.data[offset+4]=tempHelpUnit[4];this.data[offset+5]=tempHelpUnit[5];this.data[offset+6]=tempHelpUnit[6];this.data[offset+7]=tempHelpUnit[7]};function Worksheet(wb,_index,sId){this.workbook=wb;this.sName=this.workbook.getUniqueSheetNameFrom(g_sNewSheetNamePattern,false);this.bHidden=false;this.oSheetFormatPr=new AscCommonExcel.SheetFormatPr;this.index=_index;this.Id=null!=sId?sId:AscCommon.g_oIdCounter.Get_NewId();this.nRowsCount= +0;this.nColsCount=0;this.rowsData=new SheetMemory(AscCommonExcel.g_nRowStructSize,gc_nMaxRow0);this.cellsByCol=[];this.cellsByColRowsCount=0;this.aCols=[];this.hiddenManager=new HiddenManager(this);this.Drawings=[];this.TableParts=[];this.AutoFilter=null;this.oAllCol=null;this.aComments=[];var oThis=this;this.bExcludeHiddenRows=false;this.bIgnoreWriteFormulas=false;this.mergeManager=new RangeDataManager(function(data,from,to){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone(); +if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeMerge,oThis.getId(),oHistoryRange,new UndoRedoData_FromTo(new UndoRedoData_BBox(from),new UndoRedoData_BBox(to)))}if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.mergeManager.worksheet= +this;this.hyperlinkManager=new RangeDataManager(function(data,from,to,oChangeParam){if(History.Is_On()&&(null!=from||null!=to)){if(null!=from)from=from.clone();if(null!=to)to=to.clone();var oHistoryRange=from;if(null==oHistoryRange)oHistoryRange=to;var oHistoryData=null;if(null==from||null==to)oHistoryData=data.clone();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ChangeHyperlink,oThis.getId(),oHistoryRange,new AscCommonExcel.UndoRedoData_FromToHyperlink(from,to,oHistoryData))}if(null!= +to)data.Ref=oThis.getRange3(to.r1,to.c1,to.r2,to.c2);else if(oChangeParam&&oChangeParam.removeStyle&&null!=data.Ref)data.Ref.cleanFormat();if(null!=to){var maxRow=gc_nMaxRow0!==to.r2?to.r2:to.r1;var maxCol=gc_nMaxCol0!==to.c2?to.c2:to.c1;if(maxRow>=oThis.nRowsCount)oThis.nRowsCount=maxRow+1;if(maxCol>=oThis.nColsCount)oThis.nColsCount=maxCol+1}});this.hyperlinkManager.setDependenceManager(this.mergeManager);this.DrawingDocument=new AscCommon.CDrawingDocument;this.sheetViews=[];this.aConditionalFormattingRules= +[];this.updateConditionalFormattingRange=null;this.dataValidations=null;this.sheetPr=null;this.aFormulaExt=null;this.autoFilters=AscCommonExcel.AutoFilters!==undefined?new AscCommonExcel.AutoFilters(this):null;this.oDrawingOjectsManager=new DrawingObjectsManager(this);this.contentChanges=new AscCommon.CContentChanges;this.aSparklineGroups=[];this.selectionRange=new AscCommonExcel.SelectionRange(this);this.sheetMergedStyles=new AscCommonExcel.SheetMergedStyles;this.pivotTables=[];this.headerFooter= +new Asc.CHeaderFooter(this);this.rowBreaks=null;this.colBreaks=null;this.legacyDrawingHF=null;this.picture=null;this.PagePrintOptions=new Asc.asc_CPageOptions(this);this.formulaArrayLink=null;this.lastFindOptions=null;this.bExcludeCollapsed=false;this.handlers=null}Worksheet.prototype.getCompiledStyle=function(row,col,opt_cell,opt_styleComponents){return getCompiledStyle(this.sheetMergedStyles,this.hiddenManager,row,col,opt_cell,this,opt_styleComponents)};Worksheet.prototype.getCompiledStyleCustom= +function(row,col,needTable,needCell,needConditional,opt_cell){var res;var styleComponents=this.sheetMergedStyles.getStyle(this.hiddenManager,row,col,this);var ws=this;if(!needTable)styleComponents.table=[];if(!needConditional)styleComponents.conditional=[];if(!needCell)res=getCompiledStyle(undefined,undefined,row,col,undefined,undefined,styleComponents);else if(opt_cell)res=getCompiledStyle(undefined,undefined,row,col,opt_cell,ws,styleComponents);else this._getCellNoEmpty(row,col,function(cell){res= +getCompiledStyle(undefined,undefined,row,col,cell,ws,styleComponents)});return res};Worksheet.prototype.getColData=function(index){var sheetMemory=this.cellsByCol[index];if(!sheetMemory){sheetMemory=new SheetMemory(g_nCellStructSize,gc_nMaxRow0);this.cellsByCol[index]=sheetMemory}return sheetMemory};Worksheet.prototype.getColDataNoEmpty=function(index){return this.cellsByCol[index]};Worksheet.prototype.getColDataLength=function(){return this.cellsByCol.length};Worksheet.prototype.getSnapshot=function(wb){var ws= +new Worksheet(wb,this.index,this.Id);ws.sName=this.sName;for(var i=0;i0){var drawingObjects=new AscFormat.DrawingObjects;oNewWs.Drawings=[];AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT=oNewWs.DrawingDocument;for(i=0;i=gradient.max)color=gradient.getMaxColor();else if(val<=oGradient1.min)color=oGradient1.getMinColor();else{gradient=oGradient2&&val>oGradient1.max?oGradient2:oGradient1;color=gradient.calculateColor(val)}dxf.fill=new AscCommonExcel.Fill;dxf.fill.fromColor(color);dxf=g_StyleCache.addXf(dxf,true)}return dxf}}(oGradient1,oGradient2)}}else if(AscCommonExcel.ECfType.dataBar===oRule.type)continue;else if(AscCommonExcel.ECfType.top10===oRule.type){if(oRule.rank>0&&oRule.dxf){nc= +0;values=this._getValuesForConditionalFormatting(ranges,false);o=oRule.bottom?Number.MAX_VALUE:-Number.MAX_VALUE;for(cell=0;cell=nc?values[nc-1].v:o;compareFunction= +function(rule,threshold){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getNumberValue():null});return null!==val&&(rule.bottom?val<=threshold:val>=threshold)?rule.dxf:null}}(oRule,threshold)}}else if(AscCommonExcel.ECfType.aboveAverage===oRule.type){if(!oRule.dxf)continue;values=this._getValuesForConditionalFormatting(ranges,false);sum=0;nc=0;for(cell=0;cell0?condition===obj[val]:false)?rule.dxf:null}}(oRule,o,oRule.type===AscCommonExcel.ECfType.duplicateValues);break;case AscCommonExcel.ECfType.containsText:case AscCommonExcel.ECfType.notContainsText:case AscCommonExcel.ECfType.beginsWith:case AscCommonExcel.ECfType.endsWith:var operator;switch(oRule.type){case AscCommonExcel.ECfType.containsText:operator= +AscCommonExcel.ECfOperator.Operator_containsText;break;case AscCommonExcel.ECfType.notContainsText:operator=AscCommonExcel.ECfOperator.Operator_notContains;break;case AscCommonExcel.ECfType.beginsWith:operator=AscCommonExcel.ECfOperator.Operator_beginsWith;break;case AscCommonExcel.ECfType.endsWith:operator=AscCommonExcel.ECfOperator.Operator_endsWith;break}formulaParent=new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true);oRuleElement=oRule.getFormulaCellIs();parsed1=oRuleElement&& +oRuleElement.getFormula&&oRuleElement.getFormula(this,formulaParent);if(parsed1&&parsed1.hasRelativeRefs()){bboxCf=oRule.getBBox();compareFunction=getCacheFunction(oRule,function(rule,operator,formulaParent,rowLT,colLT){return function(row,col){var offset=new AscCommon.CellBase(row-rowLT,col-colLT);var bboxCell=new Asc.Range(col,row,col,row);var v1=rule.getValueCellIs(t,formulaParent,bboxCell,offset,false);var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf: +null});return res}}(oRule,operator,new AscCommonExcel.CConditionalFormattingFormulaParent(this,oRule,true),bboxCf?bboxCf.r1:0,bboxCf?bboxCf.c1:0))}else compareFunction=function(rule,operator,v1){return function(row,col){var res;t._getCellNoEmpty(row,col,function(cell){res=rule.cellIs(operator,cell,v1)?rule.dxf:null});return res}}(oRule,operator,oRule.getValueCellIs(this));break;case AscCommonExcel.ECfType.containsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row, +col,function(cell){val=cell?CellValueType.Error===cell.getType():false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsErrors:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?CellValueType.Error!==cell.getType():true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.containsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val= +""===cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=true});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.notContainsBlanks:compareFunction=function(rule){return function(row,col){var val;t._getCellNoEmpty(row,col,function(cell){if(cell)val=""!==cell.getValueWithoutFormat().replace(/^ +| +$/g,"");else val=false});return val?rule.dxf:null}}(oRule);break;case AscCommonExcel.ECfType.timePeriod:if(oRule.timePeriod)compareFunction=function(rule,period){return function(row, +col){var val;t._getCellNoEmpty(row,col,function(cell){val=cell?cell.getValueWithoutFormat():""});var n=parseFloat(val);return period.start<=n&&n0?this.sName:""};Worksheet.prototype.setName=function(name,bFromUndoRedo){if(name.length<=g_nSheetNameMaxLength){var lastName=this.sName;History.Create_NewPoint();var prepared=this.workbook.dependencyFormulas.prepareChangeSheet(this.getId(),{rename:{from:lastName,to:name}});this.sName=name;this.workbook.dependencyFormulas.changeSheet(prepared);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Rename,this.getId(), +null,new UndoRedoData_FromTo(lastName,name));if(!bFromUndoRedo){var _lastName=parserHelp.getEscapeSheetName(lastName);var _newName=parserHelp.getEscapeSheetName(this.sName);for(var key in this.workbook.aWorksheets){var wsModel=this.workbook.aWorksheets[key];if(wsModel)wsModel.oDrawingOjectsManager.updateChartReferencesWidthHistory(_lastName,_newName,true)}}this.workbook.dependencyFormulas.calcTree()}else console.log(new Error("The sheet name must be less than 31 characters."))};Worksheet.prototype.getTabColor= +function(){return this.sheetPr&&this.sheetPr.TabColor?Asc.colorObjToAscColor(this.sheetPr.TabColor):null};Worksheet.prototype.setTabColor=function(color){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetTabColor,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.TabColor?this.sheetPr.TabColor.clone():null,color?color.clone():null));this.sheetPr.TabColor=color;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.rebuildTabColor=function(){if(this.sheetPr&&this.sheetPr.TabColor)this.workbook.handlers.trigger("asc_onUpdateTabColor",this.getIndex())};Worksheet.prototype.getHidden=function(){return true===this.bHidden};Worksheet.prototype.setHidden=function(hidden){var bOldHidden=this.bHidden,wb=this.workbook,wsActive=wb.getActiveWs(),oVisibleWs=null;this.bHidden=hidden;if(true==this.bHidden&& +this.getIndex()==wsActive.getIndex()){oVisibleWs=wb.findSheetNoHidden(this.getIndex());if(null!=oVisibleWs){var nNewIndex=oVisibleWs.getIndex();wb.setActive(nNewIndex);if(!wb.bUndoChanges&&!wb.bRedoChanges)wb.handlers.trigger("undoRedoHideSheet",nNewIndex)}}if(bOldHidden!=hidden){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_Hide,this.getId(),null,new UndoRedoData_FromTo(bOldHidden,hidden));if(null!=oVisibleWs){History.SetSheetUndo(wsActive.getId()); +History.SetSheetRedo(oVisibleWs.getId())}}};Worksheet.prototype.getSheetView=function(){return this.sheetViews[0]};Worksheet.prototype.getSheetViewSettings=function(){return this.sheetViews[0].clone()};Worksheet.prototype.setDisplayGridlines=function(value){var view=this.sheetViews[0];if(value!==view.showGridLines){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayGridlines,this.getId(),null,new UndoRedoData_FromTo(view.showGridLines,value)); +view.showGridLines=value;if(!this.workbook.bUndoChanges&&!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.setDisplayHeadings=function(value){var view=this.sheetViews[0];if(value!==view.showRowColHeaders){History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetDisplayHeadings,this.getId(),null,new UndoRedoData_FromTo(view.showRowColHeaders,value));view.showRowColHeaders=value;if(!this.workbook.bUndoChanges&& +!this.workbook.bRedoChanges)this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings")}};Worksheet.prototype.getRowsCount=function(){var result=this.nRowsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getRow0());return result};Worksheet.prototype.removeRows=function(start,stop,bExcludeHiddenRows){var removeRowsArr=bExcludeHiddenRows?this._getNoHiddenRowsArr(start,stop):[{start:start,stop:stop}];for(var i= +removeRowsArr.length-1;i>=0;i--){var oRange=this.getRange(new CellAddress(removeRowsArr[i].start,0,0),new CellAddress(removeRowsArr[i].stop,gc_nMaxCol0,0));oRange.deleteCellsShiftUp()}};Worksheet.prototype._getNoHiddenRowsArr=function(start,stop){var res=[];var elem=null;for(var i=start;i<=stop;i++)if(this.getRowHidden(i)){if(elem){res.push(elem);elem=null}}else{if(!elem){elem={};elem.start=i;elem.stop=i}else elem.stop++;if(i===stop)res.push(elem)}return res};Worksheet.prototype._updateFormulasParents= +function(r1,c1,r2,c2,bbox,offset,shiftedShared){var t=this;var cellWithFormula;var shiftedArrayFormula={};this.getRange3(r1,c1,r2,c2)._foreachNoEmpty(function(cell){var newNRow=cell.nRow+offset.row;var newNCol=cell.nCol+offset.col;var bHor=0!==offset.col;var toDelete=offset.col<0||offset.row<0;if(cell.isFormula()){var processed=c_oSharedShiftType.NeedTransform;var parsed=cell.getFormulaParsed();var shared=parsed.getShared();var arrayFormula=parsed.getArrayFormulaRef();var formulaRefObj=null;if(shared){processed= +shiftedShared[parsed.getListenerId()];var isPreProcessed=c_oSharedShiftType.PreProcessed===processed;if(!processed||isPreProcessed){if(!processed){var bboxShift=AscCommonExcel.shiftGetBBox(bbox,bHor);if(bboxShift.containsRange(shared.ref)&&(!toDelete||!bbox.isIntersect(shared.ref)))processed=c_oSharedShiftType.Processed;else processed=c_oSharedShiftType.NeedTransform}else if(isPreProcessed)processed=c_oSharedShiftType.Processed;if(c_oSharedShiftType.Processed===processed){var newRef=shared.ref.clone(); +newRef.forShift(bbox,offset,t.workbook.bUndoChanges);parsed.setSharedRef(newRef,!isPreProcessed);t.workbook.dependencyFormulas.addToChangedRange2(t.getId(),newRef)}shiftedShared[parsed.getListenerId()]=processed}}else if(arrayFormula)if(!shiftedArrayFormula[parsed.getListenerId()]&&parsed.checkFirstCellArray(cell)){shiftedArrayFormula[parsed.getListenerId()]=1;var newArrayRef=arrayFormula.clone();newArrayRef.setOffset(offset);parsed.setArrayFormulaRef(newArrayRef)}else processed=c_oSharedShiftType.Processed; +if(c_oSharedShiftType.NeedTransform===processed){var isTransform=cell.transformSharedFormula();parsed=cell.getFormulaParsed();if(isTransform)parsed.buildDependencies();cellWithFormula=parsed.getParent();cellWithFormula.nRow=newNRow;cellWithFormula.nCol=newNCol;t.workbook.dependencyFormulas.addToChangedCell(cellWithFormula)}}t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,newNRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);t.nColsCount=Math.max(t.nColsCount,newNCol+1)})};Worksheet.prototype._removeRows= +function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1);var oActualRange=new Asc.Range(0,start,gc_nMaxCol0,stop);var offset=new AscCommon.CellBase(nDif,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("delCell",oActualRange,c_oAscDeleteOptions.DeleteRows);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefRowPr=new AscCommonExcel.UndoRedoData_RowProp; +this.getRange3(start,0,stop,gc_nMaxCol0)._foreachRowNoEmpty(function(row){var oOldProps=row.getHeightProp();lastRowIndex=row.index;if(false===oOldProps.isEqual(oDefRowPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,t.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.getIndex(),true,oOldProps,oDefRowPr));row.setStyle(null);if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0?-1:0;var offsetCol=!bRow&&bbox.c1>0?-1:0;var r2=bRow?bbox.r1:bbox.r2;var c2=!bRow?bbox.c1:bbox.c2;if(0!==offsetRow||0!==offsetCol)this.getRange3(bbox.r1,bbox.c1,r2,c2)._foreachNoEmpty(function(cell){if(cell.xfs&&cell.xfs.border)t._getCellNoEmpty(cell.nRow+offsetRow,cell.nCol+offsetCol,function(neighbor){if(neighbor&&neighbor.xfs&&neighbor.xfs.border){var newBorder=neighbor.xfs.border.clone();newBorder.intersect(cell.xfs.border, +g_oDefaultFormat.BorderAbs,true);borders[bRow?cell.nCol:cell.nRow]=newBorder}})});return borders};Worksheet.prototype._insertRowsBefore=function(index,count){var t=this;this.workbook.dependencyFormulas.lockRecal();var oActualRange=new Asc.Range(0,index,gc_nMaxCol0,index+count-1);History.Create_NewPoint();var offset=new AscCommon.CellBase(count,0);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertRows("insCell",oActualRange,c_oAscInsertOptions.InsertColumns); +this.updatePivotOffset(oActualRange,offset);this._updateFormulasParents(index,0,gc_nMaxRow0,gc_nMaxCol0,oActualRange,offset,renameRes.shiftedShared);var borders;if(index>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,true);this.rowsData.insertRange(index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.insertRange(index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}); +this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(index>0&&!this.workbook.bUndoChanges){this.rowsData.copyRangeByChunk(index-1,1,index,count);this.nRowsCount=Math.max(this.nRowsCount,this.rowsData.getSize());this._forEachColData(function(sheetMemory){sheetMemory.copyRangeByChunk(index-1,1,index,count);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())});this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(index,0,index+count- +1,gc_nMaxCol0)._foreachRowNoEmpty(function(row){row.setHidden(false)},function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_AddRows,this.getId(),new Asc.Range(0,index,gc_nMaxCol0,gc_nMaxRow0),new UndoRedoData_FromToRowCol(true,index,index+count-1));this.autoFilters.redrawStylesTables(redrawTablesArr);this.workbook.dependencyFormulas.unlockRecal();return true}; +Worksheet.prototype.insertRowsAfter=function(index,count){return this.insertRowsBefore(index+1,count)};Worksheet.prototype.getColsCount=function(){var result=this.nColsCount;var pane=this.sheetViews.length&&this.sheetViews[0].pane;if(pane&&pane.topLeftFrozenCell)result=Math.max(result,pane.topLeftFrozenCell.getCol0());return result};Worksheet.prototype.removeCols=function(start,stop){var oRange=this.getRange(new CellAddress(0,start,0),new CellAddress(gc_nMaxRow0,stop,0));oRange.deleteCellsShiftLeft()}; +Worksheet.prototype._removeCols=function(start,stop){var t=this;this.workbook.dependencyFormulas.lockRecal();History.Create_NewPoint();var nDif=-(stop-start+1),i,j,length;var oActualRange=new Asc.Range(start,0,stop,gc_nMaxRow0);var offset=new AscCommon.CellBase(0,nDif);var renameRes=this.renameDependencyNodes(offset,oActualRange);var redrawTablesArr=this.autoFilters.insertColumn(oActualRange,nDif);this.updatePivotOffset(oActualRange,offset);var collapsedInfo=null,lastRowIndex;var oDefColPr=new AscCommonExcel.UndoRedoData_ColProp; +this.getRange3(0,start,gc_nMaxRow0,stop)._foreachColNoEmpty(function(col){var nIndex=col.getIndex();var oOldProps=col.getWidthProp();if(false===oOldProps.isEqual(oDefColPr))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ColProp,t.getId(),new Asc.Range(nIndex,0,nIndex,gc_nMaxRow0),new UndoRedoData_IndexSimpleProp(nIndex,false,oOldProps,oDefColPr));col.setStyle(null);lastRowIndex=col.index;if(!t.workbook.bRedoChanges){if(collapsedInfo!==null&&collapsedInfo0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oActualRange,false);this.cellsByCol.splice(gc_nMaxCol0-count+1,count);for(var i=this.cellsByCol.length-1;i>=index;--i){this.cellsByCol[i+count]=this.cellsByCol[i];this.cellsByCol[i]=undefined}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.aCols.splice(gc_nMaxCol0-count+1,count);for(var i=this.aCols.length-1;i>=index;--i){this.aCols[i+ +count]=this.aCols[i];this.aCols[i]=undefined;if(this.aCols[i+count])this.aCols[i+count].moveHor(count)}this.nColsCount=Math.max(this.nColsCount,this.aCols.length);if(!this.workbook.bUndoChanges){var oPrevCol=null;if(index>0)oPrevCol=this.aCols[index-1];if(null==oPrevCol&&null!=this.oAllCol)oPrevCol=this.oAllCol;if(null!=oPrevCol){History.LocalChange=true;for(var i=index;i0?this.cellsByCol[index-1]:null;if(prevCellsByCol){for(var i=index;i0)prevCol=this._getCol(start-1);for(var i=start;i<=stop;i++){var col=this._getCol(i);fProcessCol(col)}if(_summaryRight&&!bNotAddCollapsed&&prevCol){col=this._getCol(stop+1);if(col.getCollapsed())this.setCollapsedCol(false,null,col)}}};Worksheet.prototype.getColHidden= +function(index){var col=this._getColNoEmptyWithAll(index);return col?col.getHidden():false};Worksheet.prototype.setColHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryRight=this.sheetPr?this.sheetPr.SummaryRight:true;var fProcessCol=function(col){if(col&&!bNotAddCollapsed&&outlineLevel!== +undefined&&outlineLevel!==col.getOutlineLevel())if(!_summaryRight)oThis.setCollapsedCol(bHidden,col.index-1);else oThis.setCollapsedCol(bHidden,null,col);outlineLevel=col?col.getOutlineLevel():null;if(col.getHidden()!=bHidden){var oOldProps=col.getWidthProp();if(bHidden){col.setHidden(bHidden);if(null==col.width||true!=col.CustomWidth)col.width=0;col.CustomWidth=true;col.BestFit=null}else{col.setHidden(null);if(0>=col.width)col.width=null}var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))}};if(!bNotAddCollapsed&&!_summaryRight&&start>0){col=this._getCol(start-1);outlineLevel=col.getOutlineLevel()}if(0!=start&&gc_nMaxCol0==stop){var col=null;if(false==bHidden)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col= +null;if(false==bHidden)col=this._getColNoEmpty(i);else col=this._getCol(i);if(null!=col)fProcessCol(col)}if(!bNotAddCollapsed&&outlineLevel&&_summaryRight){col=this._getCol(stop+1);if(col&&outlineLevel!==col.getOutlineLevel())oThis.setCollapsedCol(bHidden,null,col)}};Worksheet.prototype.setCollapsedCol=function(bCollapse,colIndex,curCol){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getCollapsed();col.setCollapsed(bCollapse);var oNewProps=col.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_CollapsedCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};if(curCol)fProcessCol(curCol);else this.getRange3(0,colIndex,0,colIndex)._foreachCol(fProcessCol)};Worksheet.prototype.setSummaryRight=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryRight,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryRight, +val));this.sheetPr.SummaryRight=val};Worksheet.prototype.setSummaryBelow=function(val){if(!this.sheetPr)this.sheetPr=new AscCommonExcel.asc_CSheetPr;History.Create_NewPoint();History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_SetSummaryBelow,this.getId(),null,new UndoRedoData_FromTo(this.sheetPr.SummaryBelow,val));this.sheetPr.SummaryBelow=val};Worksheet.prototype.setGroupCol=function(bDel,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel(); +col.setOutlineLevel(null,bDel);var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.setOutlineCol=function(val,start,stop){var oThis=this;var fProcessCol=function(col){var oOldProps=col.getOutlineLevel();col.setOutlineLevel(val); +var oNewProps=col.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupCol,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,true,oOldProps,oNewProps))};this.getRange3(0,start,0,stop)._foreachCol(fProcessCol)};Worksheet.prototype.getColCustomWidth=function(index){var isBestFit;var column=this._getColNoEmptyWithAll(index);if(!column)isBestFit=true;else if(column.getHidden())isBestFit=false;else isBestFit= +!!(column.BestFit||null===column.BestFit&&null===column.CustomWidth);return!isBestFit};Worksheet.prototype.setColBestFit=function(bBestFit,width,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this;var fProcessCol=function(col){var oOldProps=col.getWidthProp();if(bBestFit){col.BestFit=bBestFit;col.setHidden(null)}else col.BestFit=null;col.width=width;oThis.initColumn(col);var oNewProps=col.getWidthProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet, +AscCH.historyitem_Worksheet_ColProp,oThis.getId(),col._getUpdateRange(),new UndoRedoData_IndexSimpleProp(col.index,false,oOldProps,oNewProps))};if(0!=start&&gc_nMaxCol0==stop){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this.oAllCol;else col=this.getAllCol();if(null!=col)fProcessCol(col);for(var i in this.aCols){var col=this.aCols[i];if(null!=col)fProcessCol(col)}}else for(var i=start;i<=stop;i++){var col=null;if(bBestFit&&oDefaultMetrics.ColWidthChars==width)col=this._getColNoEmpty(i); +else col=this._getCol(i);if(null!=col)fProcessCol(col)}};Worksheet.prototype.isDefaultHeightHidden=function(){return null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getHidden()};Worksheet.prototype.isDefaultWidthHidden=function(){return null!=this.oAllCol&&this.oAllCol.getHidden()};Worksheet.prototype.setDefaultHeight=function(h){if(this.oSheetFormatPr.oAllRow&&!this.oSheetFormatPr.oAllRow.getCustomHeight())this.oSheetFormatPr.oAllRow.h=h};Worksheet.prototype.getDefaultHeight=function(){var dRes= +null;if(null!=this.oSheetFormatPr.oAllRow&&this.oSheetFormatPr.oAllRow.getCustomHeight())dRes=this.oSheetFormatPr.oAllRow.h;return dRes};Worksheet.prototype.getRowHeight=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHeight():-1});return res};Worksheet.prototype.setRowHeight=function(height,start,stop,isCustom){if(0==height)return this.setRowHidden(true,start,stop);if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var oSelection= +History.GetSelection();if(null!=oSelection){oSelection=oSelection.clone();oSelection.assign(0,start,gc_nMaxCol0,stop);History.SetSelection(oSelection);History.SetSelectionRedo(oSelection)}var prevRow;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr?this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row){if(_summaryBelow&&!bNotAddCollapsed&&row.getCollapsed())oThis.setCollapsedRow(false,null, +row);else if(!_summaryBelow&&!bNotAddCollapsed&&prevRow&&prevRow.getCollapsed())oThis.setCollapsedRow(false,null,prevRow);prevRow=row;var oOldProps=row.getHeightProp();row.setHeight(height);if(isCustom)row.setCustomHeight(true);row.setCalcHeight(true);row.setHidden(false);var oNewProps=row.getHeightProp();if(false===oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index, +true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(this.getAllRow());this._forEachRow(fProcessRow)}else{if(!_summaryBelow)if(!bNotAddCollapsed&&start>0)this._getRow(start-1,function(row){prevRow=row});this.getRange3(start,0,stop,0)._foreachRow(fProcessRow);if(_summaryBelow)if(!bNotAddCollapsed&&prevRow)this._getRow(stop+1,function(row){if(row.getCollapsed())oThis.setCollapsedRow(false,null,row)})}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()}; +Worksheet.prototype.getRowHidden=function(index){var res;this._getRowNoEmptyWithAll(index,function(row){res=row?row.getHidden():false});return res};Worksheet.prototype.setRowHidden=function(bHidden,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var startIndex=null,endIndex=null,updateRange,outlineLevel;var bNotAddCollapsed=true==this.workbook.bUndoChanges||true==this.workbook.bRedoChanges||this.bExcludeCollapsed;var _summaryBelow=this.sheetPr? +this.sheetPr.SummaryBelow:true;var fProcessRow=function(row){if(row&&!bNotAddCollapsed&&outlineLevel!==undefined&&outlineLevel!==row.getOutlineLevel())if(!_summaryBelow)oThis.setCollapsedRow(bHidden,row.index-1);else oThis.setCollapsedRow(bHidden,null,row);outlineLevel=row?row.getOutlineLevel():null;if(row&&bHidden!=row.getHidden()){row.setHidden(bHidden);if(row.index===endIndex+1&&startIndex!==null)endIndex++;else{if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}startIndex=row.index;endIndex=row.index}}};if(0==start&&gc_nMaxRow0==stop);else{if(!_summaryBelow&&start>0&&!bNotAddCollapsed)this._getRow(start-1,function(row){if(row)outlineLevel=row.getOutlineLevel()});for(i=start;i<=stop;++i)false==bHidden?this._getRowNoEmpty(i,fProcessRow):this._getRow(i,fProcessRow);if(_summaryBelow&&outlineLevel&& +!bNotAddCollapsed)this._getRow(stop+1,function(row){if(row&&outlineLevel!==row.getOutlineLevel())oThis.setCollapsedRow(bHidden,null,row)});if(startIndex!==null){updateRange=new Asc.Range(0,startIndex,gc_nMaxCol0,endIndex);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowHide,oThis.getId(),updateRange,new UndoRedoData_FromToRowCol(bHidden,startIndex,endIndex))}}if(this.needRecalFormulas(start,stop))this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.setCollapsedRow= +function(bCollapse,rowIndex,curRow){var oThis=this;var fProcessRow=function(row,bSave){var oOldProps=row.getCollapsed();row.setCollapsed(bCollapse);var oNewProps=row.getCollapsed();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_CollapsedRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps));if(bSave)row.saveContent(true)};if(curRow)fProcessRow(curRow,true);else this.getRange3(rowIndex,0,rowIndex, +0)._foreachRow(fProcessRow)};Worksheet.prototype.setGroupRow=function(bDel,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(null,bDel);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)}; +Worksheet.prototype.setOutlineRow=function(val,start,stop){var oThis=this;var fProcessRow=function(row){var oOldProps=row.getOutlineLevel();row.setOutlineLevel(val);var oNewProps=row.getOutlineLevel();if(oOldProps!==oNewProps)History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_GroupRow,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))};this.getRange3(start,0,stop,0)._foreachRow(fProcessRow)};Worksheet.prototype.getRowCustomHeight= +function(index){var isCustomHeight=false;this._getRowNoEmptyWithAll(index,function(row){if(!row)isCustomHeight=false;else if(row.getHidden())isCustomHeight=true;else isCustomHeight=row.getCustomHeight()});return isCustomHeight};Worksheet.prototype.setRowBestFit=function(bBestFit,height,start,stop){if(null==start)return;if(null==stop)stop=start;History.Create_NewPoint();var oThis=this,i;var isDefaultProp=true==bBestFit&&oDefaultMetrics.RowHeight==height;var fProcessRow=function(row){if(row){var oOldProps= +row.getHeightProp();row.setCustomHeight(!bBestFit);row.setCalcHeight(true);row.setHeight(height);var oNewProps=row.getHeightProp();if(false==oOldProps.isEqual(oNewProps))History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RowProp,oThis.getId(),row._getUpdateRange(),new UndoRedoData_IndexSimpleProp(row.index,true,oOldProps,oNewProps))}};if(0==start&&gc_nMaxRow0==stop){fProcessRow(isDefaultProp?this.oSheetFormatPr.oAllRow:this.getAllRow());this._forEachRow(fProcessRow)}else{var range= +this.getRange3(start,0,stop,0);if(isDefaultProp)range._foreachRowNoEmpty(fProcessRow);else range._foreachRow(fProcessRow)}this.workbook.dependencyFormulas.calcTree()};Worksheet.prototype.getCell=function(oCellAdd){return this.getRange(oCellAdd,oCellAdd)};Worksheet.prototype.getCell2=function(sCellAdd){if(sCellAdd.indexOf("$")>-1)sCellAdd=sCellAdd.replace(/\$/g,"");return this.getRange2(sCellAdd)};Worksheet.prototype.getCell3=function(r1,c1){return this.getRange3(r1,c1,r1,c1)};Worksheet.prototype.getRange= +function(cellAdd1,cellAdd2){var nRow1=cellAdd1.getRow0();var nCol1=cellAdd1.getCol0();var nRow2=cellAdd2.getRow0();var nCol2=cellAdd2.getCol0();return this.getRange3(nRow1,nCol1,nRow2,nCol2)};Worksheet.prototype.getRange2=function(sRange){var bbox=AscCommonExcel.g_oRangeCache.getAscRange(sRange);if(null!=bbox)return Range.prototype.createFromBBox(this,bbox);return null};Worksheet.prototype.getRange3=function(r1,c1,r2,c2){var nRowMin=r1;var nRowMax=r2;var nColMin=c1;var nColMax=c2;if(r1>r2){nRowMax= +r1;nRowMin=r2}if(c1>c2){nColMax=c1;nColMin=c2}return new Range(this,nRowMin,nColMin,nRowMax,nColMax)};Worksheet.prototype.getRange4=function(r,c){return new Range(this,r,c,r,c)};Worksheet.prototype.getRowIterator=function(r1,c1,c2,callback){var it=new RowIterator;it.init(this,r1,c1,c2);callback(it);it.release()};Worksheet.prototype._removeCell=function(nRow,nCol,cell){var t=this;var processCell=function(cell){if(null!=cell){var sheetId=t.getId();if(false==cell.isEmpty()){var oUndoRedoData_CellData= +new AscCommonExcel.UndoRedoData_CellData(cell.getValueData(),null);if(null!=cell.xfs)oUndoRedoData_CellData.style=cell.xfs.clone();cell.setFormulaInternal(null);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_RemoveCell,sheetId,new Asc.Range(nCol,nRow,nCol,nRow),new UndoRedoData_CellSimpleData(nRow,nCol,oUndoRedoData_CellData,null))}t.workbook.dependencyFormulas.addToChangedCell(cell);cell.clearData();cell.saveContent(true)}};if(null!=cell){nRow=cell.nRow;nCol=cell.nCol; +processCell(cell)}else this._getCellNoEmpty(nRow,nCol,processCell)};Worksheet.prototype._getCell=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nRowsCount?index+1:this.nRowsCount};Worksheet.prototype._initCell=function(cell,nRow,nCol){var t=this;cell.setChanged(true);this._getRowNoEmpty(nRow,function(row){var oCol=t._getColNoEmptyWithAll(nCol);var xfs=null;if(row&&null!=row.xfs)xfs=row.xfs.clone();else if(null!=oCol&&null!=oCol.xfs)xfs= +oCol.xfs.clone();cell.setStyleInternal(xfs);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,nRow+1);t.nRowsCount=Math.max(t.nRowsCount,t.cellsByColRowsCount);if(nCol>=t.nColsCount)t.nColsCount=nCol+1});var sheetMemory=this.getColData(nCol);sheetMemory.checkSize(nRow)};Worksheet.prototype._getCellNoEmpty=function(row,col,fAction){var wb=this.workbook;var targetCell=null;for(var k=0;k=this.nColsCount?index+1:this.nColsCount}}return oCurCol};Worksheet.prototype._prepareMoveRangeGetCleanRanges=function(oBBoxFrom,oBBoxTo,wsTo){var intersection=oBBoxFrom.intersectionSimple(oBBoxTo);var aRangesToCheck= +[];if(null!=intersection&&this===wsTo){var oThis=this;var fAddToRangesToCheck=function(aRangesToCheck,r1,c1,r2,c2){if(r1<=r2&&c1<=c2)aRangesToCheck.push(oThis.getRange3(r1,c1,r2,c2))};if(intersection.r1==oBBoxTo.r1&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,intersection.c2+1,intersection.r2,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c1==oBBoxTo.c1){fAddToRangesToCheck(aRangesToCheck, +oBBoxTo.r1,oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,intersection.c2+1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r1==oBBoxTo.r1&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1,oBBoxTo.c1,intersection.r2,intersection.c1-1);fAddToRangesToCheck(aRangesToCheck,intersection.r2+1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2)}else if(intersection.r2==oBBoxTo.r2&&intersection.c2==oBBoxTo.c2){fAddToRangesToCheck(aRangesToCheck,oBBoxTo.r1, +oBBoxTo.c1,intersection.r1-1,oBBoxTo.c2);fAddToRangesToCheck(aRangesToCheck,intersection.r1,oBBoxTo.c1,oBBoxTo.r2,intersection.c1-1)}}else aRangesToCheck.push(wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2));return aRangesToCheck};Worksheet.prototype._prepareMoveRange=function(oBBoxFrom,oBBoxTo,wsTo){var res=0;if(!wsTo)wsTo=this;if(oBBoxFrom.isEqual(oBBoxTo)&&this===wsTo)return res;var range=wsTo.getRange3(oBBoxTo.r1,oBBoxTo.c1,oBBoxTo.r2,oBBoxTo.c2);var aMerged=wsTo.mergeManager.get(range.getBBox0()); +if(aMerged.outer.length>0)return-2;var aRangesToCheck=this._prepareMoveRangeGetCleanRanges(oBBoxFrom,oBBoxTo,wsTo);for(var i=0,length=aRangesToCheck.length;i +0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,false);var cellsByColLength=this.getColDataLength();for(var i=cellsByColLength-1;i>=nLeft;--i){var sheetMemoryFrom=this.getColDataNoEmpty(i);if(sheetMemoryFrom){if(i+dif<=gc_nMaxCol0)this.getColData(i+dif).copyRange(sheetMemoryFrom,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);sheetMemoryFrom.clear(oBBox.r1,oBBox.r2+1)}}this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());if(nLeft>0&&!this.workbook.bUndoChanges){var prevSheetMemory= +this.getColDataNoEmpty(nLeft-1);if(prevSheetMemory){for(var i=nLeft;i<=nRight;++i)this.getColData(i).copyRange(prevSheetMemory,oBBox.r1,oBBox.r1,oBBox.r2-oBBox.r1+1);this.nColsCount=Math.max(this.nColsCount,this.getColDataLength());this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nRow])})}}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed);History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsRight, +this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._shiftCellsBottom=function(oBBox,displayNameFormatTable){var t=this;var nTop=oBBox.r1;var nBottom=oBBox.r2;var dif=nBottom-nTop+1;var oActualRange=new Asc.Range(oBBox.c1,oBBox.r1,oBBox.c2,gc_nMaxRow0);var offset=new AscCommon.CellBase(dif,0);var renameRes=this.renameDependencyNodes(offset,oBBox);var redrawTablesArr;if(!this.workbook.bUndoChanges&&undefined===displayNameFormatTable)redrawTablesArr= +this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);this._updateFormulasParents(oActualRange.r1,oActualRange.c1,oActualRange.r2,oActualRange.c2,oBBox,offset,renameRes.shiftedShared);var borders;if(nTop>0&&!this.workbook.bUndoChanges)borders=this._getBordersForInsert(oBBox,true);for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.insertRange(nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount, +sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);if(nTop>0&&!this.workbook.bUndoChanges){for(var i=oBBox.c1;i<=oBBox.c2;++i){var sheetMemory=this.getColDataNoEmpty(i);if(sheetMemory){sheetMemory.copyRangeByChunk(nTop-1,1,nTop,dif);t.cellsByColRowsCount=Math.max(t.cellsByColRowsCount,sheetMemory.getSize())}}this.nRowsCount=Math.max(this.nRowsCount,this.cellsByColRowsCount);this.getRange3(oBBox.r1,oBBox.c1,oBBox.r2,oBBox.c2)._foreachNoEmpty(function(cell){cell.clearDataKeepXf(borders[cell.nCol])})}this.workbook.dependencyFormulas.notifyChanged(renameRes.changed); +History.Add(AscCommonExcel.g_oUndoRedoWorksheet,AscCH.historyitem_Worksheet_ShiftCellsBottom,this.getId(),oActualRange,new UndoRedoData_BBox(oBBox));if(!this.workbook.bUndoChanges&&undefined!==displayNameFormatTable)redrawTablesArr=this.autoFilters.insertRows("insCell",oBBox,c_oAscInsertOptions.InsertCellsAndShiftDown,displayNameFormatTable);if(!this.workbook.bUndoChanges)this.autoFilters.redrawStylesTables(redrawTablesArr)};Worksheet.prototype._setIndex=function(ind){this.index=ind};Worksheet.prototype._BuildDependencies= +function(cellRange){var ca;for(var i in cellRange){if(null===cellRange[i]){cellRange[i]=i;continue}ca=g_oCellAddressUtils.getCellAddress(i);this._getCellNoEmpty(ca.getRow0(),ca.getCol0(),function(c){if(c)c._BuildDependencies(true)})}};Worksheet.prototype._setHandlersTablePart=function(){if(!this.TableParts)return;for(var i=0;i0?4:0,c=e>=200&&e<300||304===e,n&&(_=Q(u,x,n)),_=tt(u,_,x,c),c?(u.ifModified&&(y=x.getResponseHeader("Last-Modified"),y&&(ut.lastModified[s]=y),(y=x.getResponseHeader("etag"))&&(ut.etag[s]=y)),204===e||"HEAD"===u.type?w="nocontent":304===e?w="notmodified":(w=_.state,p=_.data,m=_.error,c=!m)):(m=w,!e&&w||(w="error",e<0&&(e=0))),x.status=e,x.statusText=(i||w)+"",c?f.resolveWith(g,[p,w,x]):f.rejectWith(g,[x,w,m]),x.statusCode(v),v=void 0,h&&b.trigger(c?"ajaxSuccess":"ajaxError",[x,u,c?p:m]),C.fireWith(g,[x,w]),h&&(b.trigger("ajaxComplete",[x,u]),--ut.active||ut.event.trigger("ajaxStop")))}"object"==typeof e&&(i=e,e=void 0),i=i||{};var o,s,a,r,l,c,d,h,p,m,u=ut.ajaxSetup({},i),g=u.context||u,b=u.context&&(g.nodeType||g.jquery)?ut(g):ut.event,f=ut.Deferred(),C=ut.Callbacks("once memory"),v=u.statusCode||{},_={},y={},w="canceled",x={readyState:0,getResponseHeader:function(t){var e;if(d){if(!r)for(r={};e=Ve.exec(a);)r[e[1].toLowerCase()]=e[2];e=r[t.toLowerCase()]}return null==e?null:e},getAllResponseHeaders:function(){return d?a:null},setRequestHeader:function(t,e){return null==d&&(t=y[t.toLowerCase()]=y[t.toLowerCase()]||t,_[t]=e),this},overrideMimeType:function(t){return null==d&&(u.mimeType=t),this},statusCode:function(t){var e;if(t)if(d)x.always(t[x.status]);else for(e in t)v[e]=[v[e],t[e]];return this},abort:function(t){var e=t||w;return o&&o.abort(e),n(0,e),this}};if(f.promise(x),u.url=((e||u.url||xe.href)+"").replace(Re,xe.protocol+"//"),u.type=i.method||i.type||u.method||u.type,u.dataTypes=(u.dataType||"*").toLowerCase().match(Pt)||[""],null==u.crossDomain){c=it.createElement("a");try{c.href=u.url,c.href=c.href,u.crossDomain=Ne.protocol+"//"+Ne.host!=c.protocol+"//"+c.host}catch(t){u.crossDomain=!0}}if(u.data&&u.processData&&"string"!=typeof u.data&&(u.data=ut.param(u.data,u.traditional)),J(Fe,u,i,x),d)return x;h=ut.event&&u.global,h&&0==ut.active++&&ut.event.trigger("ajaxStart"),u.type=u.type.toUpperCase(),u.hasContent=!De.test(u.type),s=u.url.replace(Be,""),u.hasContent?u.data&&u.processData&&0===(u.contentType||"").indexOf("application/x-www-form-urlencoded")&&(u.data=u.data.replace(Me,"+")):(m=u.url.slice(s.length),u.data&&(s+=(Ae.test(s)?"&":"?")+u.data,delete u.data),!1===u.cache&&(s=s.replace(Ue,"$1"),m=(Ae.test(s)?"&":"?")+"_="+Se+++m),u.url=s+m),u.ifModified&&(ut.lastModified[s]&&x.setRequestHeader("If-Modified-Since",ut.lastModified[s]),ut.etag[s]&&x.setRequestHeader("If-None-Match",ut.etag[s])),(u.data&&u.hasContent&&!1!==u.contentType||i.contentType)&&x.setRequestHeader("Content-Type",u.contentType),x.setRequestHeader("Accept",u.dataTypes[0]&&u.accepts[u.dataTypes[0]]?u.accepts[u.dataTypes[0]]+("*"!==u.dataTypes[0]?", "+He+"; q=0.01":""):u.accepts["*"]);for(p in u.headers)x.setRequestHeader(p,u.headers[p]);if(u.beforeSend&&(!1===u.beforeSend.call(g,x,u)||d))return x.abort();if(w="abort",C.add(u.complete),x.done(u.success),x.fail(u.error),o=J(Le,u,i,x)){if(x.readyState=1,h&&b.trigger("ajaxSend",[x,u]),d)return x;u.async&&u.timeout>0&&(l=t.setTimeout(function(){x.abort("timeout")},u.timeout));try{d=!1,o.send(_,n)}catch(t){if(d)throw t;n(-1,t)}}else n(-1,"No Transport");return x},getJSON:function(t,e,i){return ut.get(t,e,i,"json")},getScript:function(t,e){return ut.get(t,void 0,e,"script")}}),ut.each(["get","post"],function(t,e){ut[e]=function(t,i,n,o){return ut.isFunction(i)&&(o=o||n,n=i,i=void 0),ut.ajax(ut.extend({url:t,type:e,dataType:o,data:i,success:n},ut.isPlainObject(t)&&t))}}),ut._evalUrl=function(t){return ut.ajax({url:t,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},ut.fn.extend({wrapAll:function(t){var e;return this[0]&&(ut.isFunction(t)&&(t=t.call(this[0])),e=ut(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map(function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t}).append(this)),this},wrapInner:function(t){return ut.isFunction(t)?this.each(function(e){ut(this).wrapInner(t.call(this,e))}):this.each(function(){var e=ut(this),i=e.contents();i.length?i.wrapAll(t):e.append(t)})},wrap:function(t){var e=ut.isFunction(t);return this.each(function(i){ut(this).wrapAll(e?t.call(this,i):t)})},unwrap:function(t){return this.parent(t).not("body").each(function(){ut(this).replaceWith(this.childNodes)}),this}}),ut.expr.pseudos.hidden=function(t){return!ut.expr.pseudos.visible(t)},ut.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},ut.ajaxSettings.xhr=function(){try{return new t.XMLHttpRequest}catch(t){}};var Oe={0:200,1223:204},ze=ut.ajaxSettings.xhr();mt.cors=!!ze&&"withCredentials"in ze,mt.ajax=ze=!!ze,ut.ajaxTransport(function(e){var i,n;if(mt.cors||ze&&!e.crossDomain)return{send:function(o,s){var a,r=e.xhr();if(r.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)r[a]=e.xhrFields[a];e.mimeType&&r.overrideMimeType&&r.overrideMimeType(e.mimeType),e.crossDomain||o["X-Requested-With"]||(o["X-Requested-With"]="XMLHttpRequest");for(a in o)r.setRequestHeader(a,o[a]);i=function(t){return function(){i&&(i=n=r.onload=r.onerror=r.onabort=r.onreadystatechange=null,"abort"===t?r.abort():"error"===t?"number"!=typeof r.status?s(0,"error"):s(r.status,r.statusText):s(Oe[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=i(),n=r.onerror=i("error"),void 0!==r.onabort?r.onabort=n:r.onreadystatechange=function(){4===r.readyState&&t.setTimeout(function(){i&&n()})},i=i("abort");try{r.send(e.hasContent&&e.data||null)}catch(t){if(i)throw t}},abort:function(){i&&i()}}}),ut.ajaxPrefilter(function(t){t.crossDomain&&(t.contents.script=!1)}),ut.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(t){return ut.globalEval(t),t}}}),ut.ajaxPrefilter("script",function(t){void 0===t.cache&&(t.cache=!1),t.crossDomain&&(t.type="GET")}),ut.ajaxTransport("script",function(t){if(t.crossDomain){var e,i;return{send:function(n,o){e=ut("