Browse Source

feat(api add): api add

getRangeHtml getRangeArray setRangeShow setRangeFilter
master
wpxp123456 5 years ago
parent
commit
e4198fa5bd
  1. 14
      docs/zh/guide/api.md
  2. 8
      src/controllers/conditionformat.js
  3. 59
      src/controllers/selection.js
  4. 920
      src/global/api.js

14
docs/zh/guide/api.md

@ -634,8 +634,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getRangeHtml([setting])
[todo]
- **参数**
@ -731,7 +729,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### getRangeArray(dimensional [,setting])
[todo]
- **参数**
@ -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]: 工作表下标;默认值为当前工作表下标
- **说明**
@ -936,8 +930,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### setRangeShow(range [,setting])<div id='setRangeShow'></div>
[todo]
- **参数**
@ -1084,8 +1076,6 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
### setRangeFilter(type [,setting])
[todo]
- **参数**
@ -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]: 操作结束的回调函数

8
src/controllers/conditionformat.js

@ -1434,7 +1434,7 @@ const conditionformat = {
}
else{
if(formula.iscelldata(txt)){
range.push(formula.getcellrange(txt.tos));
range.push(formula.getcellrange(txt));
}
}
@ -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"];

59
src/controllers/selection.js

@ -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];
}
let r1 = range.row[0],
r2 = range.row[1];
let c1 = range.column[0],
c2 = range.column[1];
if(range.row[1] > maxR){
maxR = range.row[1];
for(let copyR = r1; copyR <= r2; copyR++){
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) {
continue;
}
if(range.column[0] < minC){
minC = range.column[0];
if(!rowIndexArr.includes(copyR)){
rowIndexArr.push(copyR);
}
if(range.column[1] > maxC){
maxC = range.column[1];
if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){
RowlChange = true;
}
for(let copyR = range.row[0]; copyR <= range.row[1]; copyR++){
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][copyR] != null) {
for(let copyC = c1; copyC <= c2; copyC++){
if (Store.config["colhidden"] != null && Store.config["colhidden"][copyC] != null) {
continue;
}
if (Store.config["rowlen"] != null && (copyR in Store.config["rowlen"])){
RowlChange = true;
if(!colIndexArr.includes(copyC)){
colIndexArr.push(copyC);
}
for(let copyC = range.column[0]; copyC <= range.column[1]; copyC++){
let cell = Store.flowdata[copyR][copyC];
if(getObjType(cell) == "object" && ("mc" in cell) && cell.mc.rs != null){
@ -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>';
}
@ -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;';
}
@ -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>';
}
@ -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;';
}

920
src/global/api.js

File diff suppressed because it is too large
Loading…
Cancel
Save