Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat(add force cacultion formula): add forceCaculate parameter
Browse files Browse the repository at this point in the history
default false , if true,formula will force to  refresh when first load sheet
  • Loading branch information
tubiaoge committed Aug 12, 2020
1 parent 10dccec commit 4dd82ad
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ export default {
fireMousedown: null, //单元格数据下钻
lang: 'en', //language
plugins: [], //plugins, e.g. ['chart']
forceCaculation:false,//强制刷新公式,公式较多会有性能问题,慎用
}
3 changes: 2 additions & 1 deletion src/controllers/luckysheetConfigsetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const luckysheetConfigsetting = {
chartConfigChange: null,
beforeCreateDom: null,
fireMousedown: null,
plugins:[]
plugins:[],
forceCaculation:false,//强制刷新公式,公式较多会有性能问题,慎用
}

export default luckysheetConfigsetting;
6 changes: 3 additions & 3 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ const sheetmanage = {
_this.restoreselect();
_this.CacheNotLoadControll = [];
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);

// luckysheetrefreshgrid(0, 0);
Expand Down Expand Up @@ -901,7 +901,7 @@ const sheetmanage = {

setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid();
}, 1);
Expand Down Expand Up @@ -944,7 +944,7 @@ const sheetmanage = {

setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid();
}, 1);
Expand Down
1 change: 1 addition & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.beforeCreateDom = extendsetting.beforeCreateDom;

luckysheetConfigsetting.fireMousedown = extendsetting.fireMousedown;
luckysheetConfigsetting.forceCaculation = extendsetting.forceCaculation;
luckysheetConfigsetting.plugins = extendsetting.plugins;

// Register plugins
Expand Down
22 changes: 19 additions & 3 deletions src/global/formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -4432,7 +4432,15 @@ const luckysheetformula = {
execvertex: {},
execFunctionGroupData: null,
execFunctionExist: null,
execFunctionGroup: function(origin_r, origin_c, value, index, data) {
execFunctionGroupForce:function(isForce){
if(isForce){
this.execFunctionGroup(undefined, undefined, undefined, undefined, undefined,true);
}
else{
this.execFunctionGroup();
}
},
execFunctionGroup: function(origin_r, origin_c, value, index, data, isForce=false) {
let _this = this;

if (data == null) {
Expand Down Expand Up @@ -4489,7 +4497,10 @@ const luckysheetformula = {
vertex1["r" + item.r.toString() + "c" + item.c.toString()] = item;
_this.isFunctionRangeSave = false;

if (origin_r != null && origin_c != null) {
if(isForce){
_this.isFunctionRangeSave = true;
}
else if (origin_r != null && origin_c != null) {
_this.isFunctionRange(item.func[2], origin_r, origin_c);
}
else {
Expand Down Expand Up @@ -4522,7 +4533,12 @@ const luckysheetformula = {

vertex1["r" + item.r.toString() + "c" + item.c.toString()] = item;
_this.isFunctionRangeSave = false;
_this.isFunctionRange(item.func[2], cell.r, cell.c);
if(isForce){
_this.isFunctionRangeSave = true;
}
else{
_this.isFunctionRange(item.func[2], cell.r, cell.c);
}

if (_this.isFunctionRangeSave) {
stack.push(item);
Expand Down
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
container: 'luckysheet',
lang: 'en',
allowEdit:true,
forceCaculation:false,
plugins: ['chart'],
data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart]
})
Expand Down

0 comments on commit 4dd82ad

Please sign in to comment.