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

Commit

Permalink
feat(api add): api add
Browse files Browse the repository at this point in the history
getRangeHtml getRangeArray setRangeShow setRangeFilter
  • Loading branch information
wpxp123456 committed Sep 27, 2020
1 parent 5412721 commit e4198fa
Show file tree
Hide file tree
Showing 4 changed files with 773 additions and 236 deletions.
14 changes: 2 additions & 12 deletions docs/zh/guide/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

### getRangeHtml([setting])

[todo]


- **参数**

Expand Down Expand Up @@ -731,7 +729,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

### getRangeArray(dimensional [,setting])

[todo]

- **参数**

Expand All @@ -741,11 +738,8 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ `"oneDimensional"`: 一维数组
+ `"twoDimensional"`: 二维数组
+ `"custom"`: 自定义行列数的二维数组
- {PlainObject} [setting]: 可选参数
+ {Number} [row]: `dimensional`为`custom`的时候设置,多维数组的行数
+ {Number} [column]: `dimensional`为`custom`的时候设置,多维数组的列数
+ {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]: 工作表下标;默认值为当前工作表下标

- **说明**
Expand Down Expand Up @@ -936,8 +930,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

### setRangeShow(range [,setting])<div id='setRangeShow'></div>

[todo]


- **参数**

Expand Down Expand Up @@ -1084,8 +1076,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

### setRangeFilter(type [,setting])

[todo]


- **参数**

Expand All @@ -1096,7 +1086,7 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
+ `"open"`: 打开筛选功能,返回当前筛选的范围对象
+ `"close"`: 关闭筛选功能,返回关闭前筛选的范围对象
- {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]: 操作结束的回调函数

Expand Down
8 changes: 6 additions & 2 deletions src/controllers/conditionformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ const conditionformat = {
}
else{
if(formula.iscelldata(txt)){
range.push(formula.getcellrange(txt.tos));
range.push(formula.getcellrange(txt));
}
}

Expand Down Expand Up @@ -2825,9 +2825,13 @@ const conditionformat = {
return null;
}
},
getComputeMap: function(){
getComputeMap: function(sheetIndex){
let index = getSheetIndex(Store.currentSheetIndex);

if(sheetIndex != null){
index = getSheetIndex(sheetIndex);
}

let ruleArr = Store.luckysheetfile[index]["luckysheet_conditionformat_save"];
let data = Store.luckysheetfile[index]["data"];

Expand Down
65 changes: 37 additions & 28 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,39 @@ const selection = {

Store.luckysheet_selection_range = [];
//copy范围
let minR = Store.luckysheet_select_save[0].row[0],
maxR = Store.luckysheet_select_save[0].row[1];
let minC = Store.luckysheet_select_save[0].column[0],
maxC = Store.luckysheet_select_save[0].column[1];

let rowIndexArr = [], colIndexArr = [];
let copyRange = [], RowlChange = false, HasMC = false;

for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let range = Store.luckysheet_select_save[s];

if(range.row[0] < minR){
minR = range.row[0];
}

if(range.row[1] > maxR){
maxR = range.row[1];
}
let r1 = range.row[0],
r2 = range.row[1];
let c1 = range.column[0],
c2 = range.column[1];

if(range.column[0] < minC){
minC = range.column[0];
}

if(range.column[1] > maxC){
maxC = range.column[1];
}

for(let copyR = range.row[0]; copyR <= range.row[1]; copyR++){
for(let copyR = r1; copyR <= r2; copyR++){
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) {
continue;
}

if(!rowIndexArr.includes(copyR)){
rowIndexArr.push(copyR);
}

if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){
RowlChange = true;
}

for(let copyC = range.column[0]; copyC <= range.column[1]; copyC++){
for(let copyC = c1; copyC <= c2; copyC++){
if (Store.config["colhidden"] != null && Store.config["colhidden"][copyC] != null) {
continue;
}

if(!colIndexArr.includes(copyC)){
colIndexArr.push(copyC);
}

let cell = Store.flowdata[copyR][copyC];

if(getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null){
Expand Down Expand Up @@ -169,20 +167,31 @@ const selection = {
d = editor.deepCopyFlowData(Store.flowdata);
let colgroup = "";

for (let r = minR; r <= maxR; r++) {
rowIndexArr = rowIndexArr.sort();
colIndexArr = colIndexArr.sort();

for (let i = 0; i < rowIndexArr.length; i++) {
let r = rowIndexArr[i];

if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
continue;
}

cpdata += '<tr>';

for (let c = minC; c <= maxC; c++) {
for (let j = 0; j < colIndexArr.length; j++) {
let c = colIndexArr[j];

if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
continue;
}

let column = '<td ${span} style="${style}">';

if (d[r] != null && d[r][c] != null) {
let style = "", span = "";

if(r == minR){
if(r == rowIndexArr[0]){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>';
}
Expand All @@ -191,7 +200,7 @@ const selection = {
}
}

if(c == minC){
if(c == colIndexArr[0]){
if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){
style += 'height:19px;';
}
Expand Down Expand Up @@ -470,7 +479,7 @@ const selection = {

column += "";

if(r == minR){
if(r == rowIndexArr[0]){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>';
}
Expand All @@ -479,7 +488,7 @@ const selection = {
}
}

if(c == minC){
if(c == colIndexArr[0]){
if(Store.config == null || Store.config["rowlen"] == null || Store.config["rowlen"][r.toString()] == null){
style += 'height:19px;';
}
Expand Down
Loading

0 comments on commit e4198fa

Please sign in to comment.