diff --git a/docs/zh/guide/api.md b/docs/zh/guide/api.md index 10bed91c9..58117f82e 100644 --- a/docs/zh/guide/api.md +++ b/docs/zh/guide/api.md @@ -1444,9 +1444,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### deleteRangeConditionalFormat(itemIndex [,setting]) -[todo] - - - **参数**: - {Number} [itemIndex]: 条件格式规则索引 @@ -1469,9 +1466,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### clearRange([setting]) -[todo] - - - **参数**: - {PlainObject} [setting]: 可选参数 @@ -1481,7 +1475,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 - **说明**: - 清除指定工作表指定单元格区域的内容,返回清除掉的数据,不同于删除选区的功能,不需要设定单元格移动情况 + 清除指定工作表指定单元格区域的内容,不同于删除选区的功能,不需要设定单元格移动情况 - **示例**: @@ -1492,9 +1486,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### deleteRange(move [,setting]) -[todo] - - - **参数**: - {String} [move]: 删除后,右侧还是下方的单元格移动 @@ -1505,13 +1496,13 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 + `"up"`: 下方单元格上移 - {PlainObject} [setting]: 可选参数 - + {Array | Object | String} [range]: 要删除的选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,允许多个选区组成的数组;默认为当前选区 + + {Object | String} [range]: 要删除的选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`;默认为当前选区 + {Number} [order]: 工作表下标;默认值为当前工作表下标 + {Function} [success]: 操作结束的回调函数 - **说明**: - 删除指定工作表指定单元格区域,返回删除掉的数据,同时,指定是右侧单元格左移还是下方单元格上移 + 删除指定工作表指定单元格区域,同时,指定是右侧单元格左移还是下方单元格上移 - **示例**: @@ -1558,9 +1549,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### matrixOperation(type [,setting]) -[todo] - - - **参数**: - {String} [type]: 矩阵操作的类型 @@ -1603,9 +1591,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### matrixCalculation(type, number [,setting]) -[todo] - - - **参数**: - {String} [type]: 计算方式 @@ -1678,8 +1663,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### getSheet([setting]) -[todo] - - **参数**: - {PlainObject} [setting]: 可选参数 @@ -1695,9 +1678,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### getSheetData([setting]) -[todo] - - - **参数**: - {PlainObject} [setting]: 可选参数 @@ -1711,9 +1691,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ### getConfig([setting]) -[todo] - - - **参数**: - {PlainObject} [setting]: 可选参数 @@ -1725,20 +1702,17 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 ------------ -### setConfig([setting]) - -[todo] - +### setConfig(cfg, [setting]) - **参数**: - + - {Object} [cfg]: config配置 - {PlainObject} [setting]: 可选参数 + {Number} [order]: 工作表下标;默认值为当前工作表下标 + {Function} [success]: 操作结束的回调函数 - **说明**: - 快捷设置当前工作表config配置 + 快捷设置指定工作表config配置 ------------ diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index 7dd6965d6..652d03257 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -1574,6 +1574,10 @@ export function rowColumnOperationInitial(){ delete d[r][c]["spl"]; } + + if(d[r][c]["ct"] != null && d[r][c]["ct"].t == 'inlineStr'){ + delete d[r][c]["ct"]; + } } else{ d[r][c] = null; diff --git a/src/global/api.js b/src/global/api.js index 81d1631c9..9f9713880 100644 --- a/src/global/api.js +++ b/src/global/api.js @@ -1136,6 +1136,10 @@ export function getRangeHtml(options = {}) { }]; } + if(getObjType(range) != 'array'){ + return tooltip.info("The range parameter is invalid.", ""); + } + let file = Store.luckysheetfile[order]; if(file == null){ @@ -3040,6 +3044,10 @@ export function setRangeConditionalFormatDefault(conditionName, conditionValue, cellrange = [cellrange]; } + if(getObjType(cellrange) != 'array'){ + return tooltip.info('The cellrange parameter is invalid.', ''); + } + let rule = { "type": "default", "cellrange": cellrange, @@ -3309,6 +3317,10 @@ export function setRangeConditionalFormat(type, options = {}) { cellrange = [cellrange]; } + if(getObjType(cellrange) != 'array'){ + return tooltip.info('The cellrange parameter is invalid.', ''); + } + let rule = { "type": type, "cellrange": cellrange, @@ -3342,14 +3354,247 @@ export function setRangeConditionalFormat(type, options = {}) { /** - * - * @param {String} move 删除后,右侧还是下方的单元格移动 + * 为指定下标的工作表,删除条件格式规则,返回被删除的条件格式规则 + * @param {Number} itemIndex 条件格式规则索引 * @param {Object} options 可选参数 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + * @param {Function} options.success 操作结束的回调函数 */ -function deleteRange(move, options = {}) { +export function deleteRangeConditionalFormat(itemIndex, options = {}) { + if(!isRealNum(itemIndex)){ + return tooltip.info('The itemIndex parameter is invalid.', ''); + } + + itemIndex = Number(itemIndex); + + let { + order = getSheetIndex(Store.currentSheetIndex), + success + } = {...options} + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info('The order parameter is invalid.', ''); + } + + let cdformat = $.extend(true, [], file.luckysheet_conditionformat_save); + + if(cdformat.length == 0){ + return tooltip.info('This worksheet has no conditional format to delete', ''); + } + else if(cdformat[itemIndex] == null){ + return tooltip.info('The conditional format of the index cannot be found', ''); + } + + let cdformatItem = cdformat.splice(itemIndex, 1); + + //保存之前的规则 + let fileH = $.extend(true, [], Store.luckysheetfile); + let historyRules = conditionformat.getHistoryRules(fileH); + //保存当前的规则 + file["luckysheet_conditionformat_save"] = cdformat; + + let fileC = $.extend(true, [], Store.luckysheetfile); + let currentRules = conditionformat.getCurrentRules(fileC); + + //刷新一次表格 + conditionformat.ref(historyRules, currentRules); + + //发送给后台 + if(server.allowUpdate){ + server.saveParam("all", file.index, ruleArr, { "k": "luckysheet_conditionformat_save" }); + } + + setTimeout(() => { + if (success && typeof success === 'function') { + success(); + } + }, 1); + + return cdformatItem; } + +/** + * 清除指定工作表指定单元格区域的内容,不同于删除选区的功能,不需要设定单元格移动情况 + * @param {Object} options 可选参数 + * @param {Array | Object | String} options.range 要清除的选区范围 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + * @param {Function} options.success 操作结束的回调函数 + */ +export function clearRange(options = {}) { + let { + range = Store.luckysheet_select_save, + order = getSheetIndex(Store.currentSheetIndex), + success + } = {...options} + + if(getObjType(range) == 'string'){ + if(!formula.iscelldata(range)){ + return tooltip.info("The range parameter is invalid.", ""); + } + + let cellrange = formula.getcellrange(range); + range = [{ + "row": cellrange.row, + "column": cellrange.column + }] + } + else if(getObjType(range) == 'object'){ + if(range.row == null || range.column == null){ + return tooltip.info("The range parameter is invalid.", ""); + } + + range = [{ + "row": range.row, + "column": range.column + }]; + } + + if(getObjType(range) != 'array'){ + return tooltip.info("The range parameter is invalid.", ""); + } + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info("The order parameter is invalid.", ""); + } + + let cfg = $.extend(true, {}, file.config); + let has_PartMC = false; + + for(let s = 0; s < range.length; s++){ + let r1 = range[s].row[0], + r2 = range[s].row[1]; + let c1 = range[s].column[0], + c2 = range[s].column[1]; + + has_PartMC = hasPartMC(cfg, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + return tooltip.info('Cannot perform this operation on partially merged cells', ''); + } + + let d = $.extend(true, [], file.data); + + if(d.length == 0){ + d = $.extend(true, [], sheetmanage.buildGridData(file)); + } + + for(let s = 0; s < range.length; s++){ + let r1 = range[s].row[0], + r2 = range[s].row[1]; + let c1 = range[s].column[0], + c2 = range[s].column[1]; + + for(let r = r1; r <= r2; r++){ + for(let c = c1; c <= c2; c++){ + let cell = d[r][c]; + + if(getObjType(cell) == "object"){ + delete cell["m"]; + delete cell["v"]; + + if(cell["f"] != null){ + delete cell["f"]; + formula.delFunctionGroup(r, c, file.index); + + delete cell["spl"]; + } + + if(cell["ct"] != null && cell["ct"].t == 'inlineStr'){ + delete cell["ct"]; + } + } + else{ + d[r][c] = null; + } + } + } + } + + if(file.index == Store.currentSheetIndex){ + jfrefreshgrid(d, range); + } + else{ + file.data = d; + } + + if (success && typeof success === 'function') { + success(); + } +} + + +/** + * 删除指定工作表指定单元格区域,返回删除掉的数据,同时,指定是右侧单元格左移还是下方单元格上移 + * @param {String} move 删除后,单元格左移/上移 + * @param {Object} options 可选参数 + * @param {Object | String} options.range 要删除的选区范围 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + * @param {Function} options.success 操作结束的回调函数 + */ +export function deleteRange(move, options = {}) { + let moveList = ['left', 'up']; + + if(!moveList.includes(move)){ + return tooltip.info("The move parameter is invalid.", ""); + } + + let { + range = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1], + order = getSheetIndex(Store.currentSheetIndex), + success + } = {...options} + + if(getObjType(range) == 'string'){ + if(!formula.iscelldata(range)){ + return tooltip.info("The range parameter is invalid.", ""); + } + + let cellrange = formula.getcellrange(range); + range = { + "row": cellrange.row, + "column": cellrange.column + }; + } + + if(getObjType(range) != 'object' || range.row == null || range.column == null){ + return tooltip.info("The range parameter is invalid.", ""); + } + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info("The order parameter is invalid.", ""); + } + + let str = range.row[0], + edr = range.row[1], + stc = range.column[0], + edc = range.column[1]; + + if(move == 'left'){ + luckysheetDeleteCell('moveLeft', str, edr, stc, edc, order); + } + else if(move == 'up'){ + luckysheetDeleteCell('moveUp', str, edr, stc, edc, order); + } + + if (success && typeof success === 'function') { + success(); + } +} + + /** * 指定工作表指定单元格区域的数据进行矩阵操作,返回操作成功后的结果数据 * @param {String} type 矩阵操作的类型 @@ -4033,6 +4278,93 @@ export function getSheet(options = {}){ } +/** + * 快捷返回指定工作表的数据 + * @param {Object} options 可选参数 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + */ +export function getSheetData(options = {}) { + let { + order = getSheetIndex(Store.currentSheetIndex) + } = {...options}; + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info("The order parameter is invalid.", ""); + } + + let data = $.extend(true, [], file.data); + + if(data == null || data.length == 0){ + data = $.extend(true, [], sheetmanage.buildGridData(file)); + } + + return data; +} + +/** + * 快捷返回指定工作表的config配置 + * @param {Object} options 可选参数 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + */ +export function getConfig(options = {}) { + let { + order = getSheetIndex(Store.currentSheetIndex) + } = {...options}; + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info("The order parameter is invalid.", ""); + } + + let config = $.extend(true, {}, file.config); + + return config; +} + +/** + * 快捷设置指定工作表config配置 + * @param {Object} options 可选参数 + * @param {Number} options.order 工作表下标;默认值为当前工作表下标 + * @param {Function} options.success 操作结束的回调函数 + */ +export function setConfig(cfg, options = {}) { + if(getObjType(cfg) != 'object'){ + return tooltip.info("The cfg parameter is invalid.", ""); + } + + let { + order = getSheetIndex(Store.currentSheetIndex), + success + } = {...options}; + + let file = Store.luckysheetfile[order]; + + if(file == null){ + return tooltip.info("The order parameter is invalid.", ""); + } + + file.config = cfg; + + if(file.index == Store.currentSheetIndex){ + Store.config = cfg; + + if("rowhidden" in cfg || "colhidden" in cfg || "rowlen" in cfg || "columnlen" in cfg){ + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + } + + setTimeout(function () { + luckysheetrefreshgrid(); + }, 1); + } + + if (success && typeof success === 'function') { + success(); + } +} + /** * 返回所有表格数据结构的一维数组luckysheetfile */ diff --git a/src/global/extend.js b/src/global/extend.js index 960ea3767..70b8aea84 100644 --- a/src/global/extend.js +++ b/src/global/extend.js @@ -1612,6 +1612,13 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) { else if(str <= r && edr >= r + rs - 1 && edc < c){ merge_new[r + "_" + (c - clen)] = { "r": r, "c": c - clen, "rs": rs, "cs": cs }; } + else{ + for(let r_i = r; r_i <= r + rs - 1; r_i++){ + for(let c_i = c; c_i <= c + cs - 1; c_i++){ + delete d[r_i][c_i].mc; + } + } + } } else if(type == "moveUp"){ if(stc > c + cs - 1 || edc < c || str > r + rs - 1){ @@ -1620,6 +1627,13 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) { else if(stc <= c && edc >= c + cs - 1 && edr < r){ merge_new[(r - rlen) + "_" + c] = { "r": r - rlen, "c": c, "rs": rs, "cs": cs }; } + else{ + for(let r_i = r; r_i <= r + rs - 1; r_i++){ + for(let c_i = c; c_i <= c + cs - 1; c_i++){ + delete d[r_i][c_i].mc; + } + } + } } } cfg["merge"] = merge_new; @@ -1905,19 +1919,9 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) { CFr2 = cf_range[j].row[1], CFc1 = cf_range[j].column[0], CFc2 = cf_range[j].column[1]; - - if(!(str > CFr2 || edr < CFr1) || !(stc > CFc2 || edc < CFc1)){ - let range = conditionformat.CFSplitRange( - cf_range[j], - { "row": [str, edr], "column": [stc, edc] }, - { "row": [str, edr], "column": [stc, edc] }, - "restPart" - ); - - cf_new_range.concat(range); - } - else{ - cf_new_range.push(cf_range[j]); + + if(!(str <= CFr1 && edr >= CFr2 && stc <= CFc1 && edc >= CFc2)){ + cf_new_range = getMoveRange(type, str, edr, stc, edc, CFr1, CFr2, CFc1, CFc2, rlen, clen); } } @@ -1978,18 +1982,8 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) { bd_c1 = borderRange[j].column[0], bd_c2 = borderRange[j].column[1]; - if(!(str > bd_r2 || edr < bd_r1) || !(stc > bd_c2 || edc < bd_c1)){ - let range = conditionformat.CFSplitRange( - borderRange[j], - { "row": [str, edr], "column": [stc, edc] }, - { "row": [str, edr], "column": [stc, edc] }, - "restPart" - ); - - emptyRange.concat(range); - } - else{ - emptyRange.push(borderRange[j]); + if(!(str <= bd_r1 && edr >= bd_r2 && stc <= bd_c1 && edc >= bd_c2)){ + emptyRange = getMoveRange(type, str, edr, stc, edc, bd_r1, bd_r2, bd_c1, bd_c2, rlen, clen); } } @@ -2095,6 +2089,315 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, order) { } } +function getMoveRange(type, str, edr, stc, edc, r1, r2, c1, c2, rlen, clen) { + let newRange = []; + + if(type == "moveLeft"){ + if(str > r2 || edr < r1 || stc > c2){ + newRange.push({ + "row": [r1, r2], + "column": [c1, c2] + }); + } + else if(edc < c1){ + if(str <= r1 && edr >= r2){ + newRange.push({ + "row": [r1, r2], + "column": [c1 - clen, c2 - clen] + }); + } + else if(str > r1 && edr < r2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + { "row": [str, edr], "column": [c1 - clen, c2 - clen] } + ]; + newRange = newRange.concat(range); + } + else if(str > r1){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [str, r2], "column": [c1 - clen, c2 - clen] }, + ]; + newRange = newRange.concat(range); + } + else if(edr < r2){ + let range= [ + { "row": [r1, edr], "column": [c1 - clen, c2 - clen] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(edc >= c1){ + if(stc <= c1 && edc >= c2){ + if(str > r1 && edr < r2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(str > r1){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(edr < r2){ + let range= [ + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(stc > c1 && edc < c2){ + if(str <= r1 && edr >= r2){ + newRange.push({ + "row": [r1, r2], + "column": [c1, c2 - clen] + }); + } + else if(str > r1 && edr < r2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + { "row": [str, edr], "column": [c1, c2 - clen] } + ]; + newRange = newRange.concat(range); + } + else if(str > r1){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [str, r2], "column": [c1, c2 - clen] }, + ]; + newRange = newRange.concat(range); + } + else if(edr < r2){ + let range= [ + { "row": [r1, edr], "column": [c1, c2 - clen] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(stc > c1){ + if(str <= r1 && edr >= r2){ + newRange.push({ + "row": [r1, r2], + "column": [c1, stc - 1] + }); + } + else if(str > r1 && edr < r2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + { "row": [str, edr], "column": [c1, stc - 1] } + ]; + newRange = newRange.concat(range); + } + else if(str > r1){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [str, r2], "column": [c1, stc - 1] }, + ]; + newRange = newRange.concat(range); + } + else if(edr < r2){ + let range= [ + { "row": [r1, edr], "column": [c1, stc - 1] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(edc < c2){ + if(str <= r1 && edr >= r2){ + newRange.push({ + "row": [r1, r2], + "column": [c1 - clen, c2 - clen] + }); + } + else if(str > r1 && edr < r2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + { "row": [str, edr], "column": [c1 - clen, c2 - clen] } + ]; + newRange = newRange.concat(range); + } + else if(str > r1){ + let range= [ + { "row": [r1, str - 1], "column": [c1, c2] }, + { "row": [str, r2], "column": [c1 - clen, c2 - clen] }, + ]; + newRange = newRange.concat(range); + } + else if(edr < r2){ + let range= [ + { "row": [r1, edr], "column": [c1 - clen, c2 - clen] }, + { "row": [edr + 1, r2], "column": [c1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + } + } + else if(type == "moveUp"){ + if(stc > c2 || edc < c1 || str > r2){ + newRange.push({ + "row": [r1, r2], + "column": [c1, c2] + }); + } + else if(edr < r1){ + if(stc <= c1 && edc >= c2){ + newRange.push({ + "row": [r1 - rlen, r2 - rlen], + "column": [c1, c2] + }); + } + else if(stc > c1 && edc < c2){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + { "row": [r1 - rlen, r2 - rlen], "column": [stc, edc] } + ]; + newRange = newRange.concat(range); + } + else if(stc > c1){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1 - rlen, r2 - rlen], "column": [stc, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(edc < c2){ + let range= [ + { "row": [r1 - rlen, r2 - rlen], "column": [c1, edc] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(edr >= r1){ + if(str <= r1 && edr >= r2){ + if(stc > c1 && edc < c2){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(stc > c1){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + ]; + newRange = newRange.concat(range); + } + else if(edc < c2){ + let range= [ + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(str > r1 && edr < r2){ + if(stc <= c1 && edc >= c2){ + newRange.push({ + "row": [r1, r2 - rlen], + "column": [c1, c2] + }); + } + else if(stc > c1 && edc < c2){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + { "row": [r1, r2 - rlen], "column": [stc, edc] } + ]; + newRange = newRange.concat(range); + } + else if(stc > c1){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2 - rlen], "column": [stc, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(edc < c2){ + let range= [ + { "row": [r1, r2 - rlen], "column": [c1, edc] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(str > r1){ + if(stc <= c1 && edc >= c2){ + newRange.push({ + "row": [r1, str - 1], + "column": [c1, c2] + }); + } + else if(stc > c1 && edc < c2){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + { "row": [r1, str - 1], "column": [stc, edc] } + ]; + newRange = newRange.concat(range); + } + else if(stc > c1){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, str - 1], "column": [stc, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(edc < c2){ + let range= [ + { "row": [r1, str - 1], "column": [c1, edc] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + else if(edr < r2){ + if(stc <= c1 && edc >= c2){ + newRange.push({ + "row": [r1 - rlen, r2 - rlen], + "column": [c1, c2] + }); + } + else if(stc > c1 && edc < c2){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + { "row": [r1 - rlen, r2 - rlen], "column": [stc, edc] } + ]; + newRange = newRange.concat(range); + } + else if(stc > c1){ + let range= [ + { "row": [r1, r2], "column": [c1, stc - 1] }, + { "row": [r1 - rlen, r2 - rlen], "column": [stc, c2] }, + ]; + newRange = newRange.concat(range); + } + else if(edc < c2){ + let range= [ + { "row": [r1 - rlen, r2 - rlen], "column": [c1, edc] }, + { "row": [r1, r2], "column": [edc + 1, c2] }, + ]; + newRange = newRange.concat(range); + } + } + } + } + + return newRange; +} + export { luckysheetextendtable, luckysheetextendData,