wbfsa 5 years ago
parent
commit
019225fb5c
  1. 670
      docs/zh/guide/operate.md
  2. 78
      docs/zh/guide/sheet.md
  3. 59
      src/controllers/constant.js
  4. 27
      src/controllers/controlHistory.js
  5. 4
      src/controllers/filter.js
  6. 138
      src/controllers/rowColumnOperation.js
  7. 4
      src/controllers/server.js
  8. 160
      src/global/draw.js
  9. 478
      src/global/extend.js
  10. 157
      src/global/refresh.js
  11. 29
      src/global/rhchInit.js
  12. 5
      src/locale/en.js
  13. 3
      src/locale/zh.js

670
docs/zh/guide/operate.md

@ -10,6 +10,8 @@
## 单元格刷新
### 单个单元格刷新
- **格式**
```json
@ -48,6 +50,43 @@
```
后台在保存前台推送的数据时,会更新 `luckysheetfile[i].celldata` 字段,如果存在该单元格则更新,如果没有则添加,如果存在该单元格但是`v`为null则删除该单元格。
### 范围单元格刷新
- **格式**
```json
{
"t": "rv",
"i": "Sheet_ahKdzaNC65iL_1598343160744",
"v": [
[
{ "v": 3, "ct": { "fa": "General", "t": "n" }, "m": "3" }
],
[
{ "v": 4, "ct": { "fa": "General", "t": "n" }, "m": "4" }
]
],
"range": {
"row": [ 1, 2 ],
"column": [ 1, 1 ]
}
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的索引值|
|v|范围二维数组,单元格对象参考 [单元格属性表](/zh/guide/cell.html#基本单元格)|
|range|范围行列数|
- **后台更新**
前端维护luckysheetfile[i].data,而单元格更新到后台,继续维护`luckysheetfile[i].celldata` 参数,需要将指定位置`range`的所有单元格数据替换为新的数据
## config操作
- **格式**
@ -78,7 +117,7 @@
- **后台更新**
更新 `luckysheetfile[i].config.[k] = v` ,如果`config`中不存在`k`,则新建一个`k`属性并设置为空。
更新 `luckysheetfile[i].config[k] = v` ,如果`config`中不存在`k`,则新建一个`k`属性并设置为空。
注意一点,修改config中的某个配置时,会把这个配置全部传输到后台,比如修改borderInfo,本来已经有一个含边框的单元格了,再新设置一个单元格边框,这时候会把这两个单元格边框信息都传输到后台,而不做更细颗粒的操作。
@ -92,7 +131,7 @@
"k": "rowhidden"
}
```
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config.["rowhidden"] = { "5": 0, "6": 0, "13": 0, "14": 0 }`
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config["rowhidden"] = { "5": 0, "6": 0, "13": 0, "14": 0 }`
2. 修改行高:
- 发送到后台:
@ -104,7 +143,7 @@
"k": "rowlen"
}
```
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config.["rowlen"] = { "9": 20, "11": 71, "15": 58 }`
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config["rowlen"] = { "9": 20, "11": 71, "15": 58 }`
3. 修改列宽:
- 发送到后台:
@ -116,7 +155,7 @@
"k": "columnlen"
}
```
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config.["columnlen"] = { "2": 135 }`
- 后台更新:`luckysheetfile["Sheet_0554kKiKl4M7_1597974810804"].config["columnlen"] = { "2": 135 }`
## 通用保存
@ -128,10 +167,7 @@
"i": 0,
"v": {
"type": "rangeRow",
"range": {
"row_focus": 1,
"column_focus": 1
}
"range": { "row_focus": 1, "column_focus": 1 }
},
"k": "frozen"
}
@ -148,50 +184,370 @@
- **后台更新**
`luckysheetfile[3].[k]= v`
如果`s`为`true`,则为 `luckysheetfile[3].[k]= JSON.stringify(v)`
更新 `luckysheetfile[i][k] = v` ,如果`luckysheetfile[i]`中不存在`k`,则新建一个`k`属性并设置为空。
1. 数据透视表:
- 输入:`{"t":"all","i":1,"v":{………},"k":"pivotTable", "s": false}`
- 更新:`luckysheetfile[1].["pivotTable"] = {………}`
1. 冻结行列:
- 发送到后台:
```json
{
"t": "all",
"i": 0,
"v": {
"type": "rangeRow",
"range": { "row_focus": 1, "column_focus": 1 }
},
"k": "frozen"
}
```
- 后台更新:
```js
luckysheetfile[0]["frozen"] = {
"type": "rangeRow",
"range": { "row_focus": 1, "column_focus": 1 }
}
```
2. 冻结行列:
- 输入:`{"t":"all","i":3,"v":{………},"k":"freezen", "s": false}`
- 更新:`luckysheetfile[3].["freezen"] = {………}`
2. 修改工作表名称:
- 发送到后台:
```json
{
"t": "all",
"i": 0,
"v": "Cell22",
"k": "name"
}
```
- 后台更新:`luckysheetfile[0]["name"] = "Cell22"`
3. 筛选范围:
- 输入:`{"t":"all","i":3,"v":{………},"k":"filter_select", "s": true }`
- 更新:`luckysheetfile[3].["filter_select"] = JSON.stringify ({………})`
3. 修改工作表颜色:
- 发送到后台:
```json
{
"t": "all",
"i": 0,
"v": "#f02323",
"k": "color"
}
```
- 后台更新:`luckysheetfile[0]["color"] = "#f02323"`
4. Sheet名称:
- 输入:`{"t":"all","i":1,"v":"文档","k":"name", "s": false}`
- 更新:`luckysheetfile[1].["name"] = "文档"`
4. 合并单元格:
- 发送到后台:
```json
{
"t": "all",
"i": "Sheet_aheLt0Waf1lk_1598248231626",
"v": {
"merge": {
"0_0": { "r": 0, "c": 0, "rs": 2, "cs": 1 }
},
"rowlen": {}
},
"k": "config"
}
```
- 后台更新:
```js
luckysheetfile["Sheet_aheLt0Waf1lk_1598248231626"]["config"] = {
"merge": {
"0_0": { "r": 0, "c": 0, "rs": 2, "cs": 1 }
},
"rowlen": {}
}
```
5. Sheet颜色:
- 输入: `{"t":"all","i":2,"v":"#FFF000","k":"color", "s": false}`
- 更新:`luckysheetfile[2].["color"] = "#FFF000"`
注意,合并单元格的更新比较特殊,要求把整个config传输到后台,因为合并单元格可能会影响到其他参数。
5. 筛选范围:
- 发送到后台:
```json
{
"t": "all",
"i": 0,
"v": {
"row": [ 16, 21 ],
"column": [ 2, 3 ]
},
"k": "filter_select"
}
```
- 后台更新:
```js
luckysheetfile[0]["filter_select"] = {
"row": [ 16, 21 ],
"column": [ 2, 3 ]
}
```
6. 筛选的具体设置:
- 发送到后台:
```json
{
"t": "all",
"i": "0",
"v": {
"0": {
"caljs": {
"value": "textinclude",
"text": "Text contains",
"type": "1",
"value1": "Lucky"
},
"rowhidden": {
"18": 0
},
"optionstate": true,
"str": 17,
"edr": 19,
"cindex": 2,
"stc": 2,
"edc": 3
}
},
"k": "filter"
}
```
- 后台更新:
```js
luckysheetfile[0]["filter"] = {
"0": {
"caljs": {
"value": "textinclude",
"text": "Text contains",
"type": "1",
"value1": "Lucky"
},
"rowhidden": {
"18": 0
},
"optionstate": true,
"str": 17,
"edr": 19,
"cindex": 2,
"stc": 2,
"edc": 3
}
}
```
7. 交替颜色:
- 发送到后台:
```json
{
"t": "all",
"i": "Sheet_4N45tpMd0ni4_1598250591760",
"v": [
{
"cellrange": {
"row": [ 2, 6 ],
"column": [ 1, 4 ]
},
"format": {
"head": {
"fc": "#000",
"bc": "#f6cb4b"
},
"one": {
"fc": "#000",
"bc": "#ffffff"
},
"two": {
"fc": "#000",
"bc": "#fff9e7"
},
"foot": {
"fc": "#000",
"bc": "#ffebac"
}
},
"hasRowHeader": true,
"hasRowFooter": true
}
],
"k": "luckysheet_alternateformat_save"
}
```
- 后台更新:
```js
luckysheetfile["Sheet_4N45tpMd0ni4_1598250591760"]["luckysheet_alternateformat_save"] = [
{
"cellrange": {
"row": [ 2, 6 ],
"column": [ 1, 4 ]
},
"format": {
"head": {
"fc": "#000",
"bc": "#f6cb4b"
},
"one": {
"fc": "#000",
"bc": "#ffffff"
},
"two": {
"fc": "#000",
"bc": "#fff9e7"
},
"foot": {
"fc": "#000",
"bc": "#ffebac"
}
},
"hasRowHeader": true,
"hasRowFooter": true
}
]
```
8. 条件格式:
- 发送到后台:
```json
{
"t": "all",
"i": "Sheet_545W7w03kLkC_1598251927583",
"v": [
{
"type": "default",
"cellrange": [
{
"row": [ 2, 6 ],
"column": [ 1, 3 ]
}
],
"format": {
"textColor": "#9c0006",
"cellColor": "#ffc7ce"
},
"conditionName": "greaterThan",
"conditionRange": [],
"conditionValue": [ "3" ]
}
],
"k": "luckysheet_conditionformat_save"
}
```
- 后台更新:
```js
luckysheetfile["Sheet_545W7w03kLkC_1598251927583"]["luckysheet_conditionformat_save"] = [
{
"type": "default",
"cellrange": [
{
"row": [ 2, 6 ],
"column": [ 1, 3 ]
}
],
"format": {
"textColor": "#9c0006",
"cellColor": "#ffc7ce"
},
"conditionName": "greaterThan",
"conditionRange": [],
"conditionValue": [ "3" ]
}
]
```
9. 数据透视表:
- 发送到后台:
```json
{
"t": "all",
"i": "Sheet_r3Cz5bbxipL3_1598252547290",
"v": {
"pivot_select_save": {
"row": [ 0, 2 ],
"column": [ 0, 2 ]
},
"pivotDataSheetIndex": "Sheet_31ikLMip330K_1598252536645",
"column": [],
"row": [],
"filter": [],
"values": [],
"showType": "column"
},
"k": "pivotTable"
}
```
- 后台更新:
```js
luckysheetfile["Sheet_r3Cz5bbxipL3_1598252547290"]["pivotTable"] = {
"pivot_select_save": {
"row": [ 0, 2 ],
"column": [ 0, 2 ]
},
"pivotDataSheetIndex": "Sheet_31ikLMip330K_1598252536645",
"column": [],
"row": [],
"filter": [],
"values": [],
"showType": "column"
}
```
注意,虽然数据透视表的格式是这个,但是当你选择一个范围之后,点击生产数据透视表时,Luckysheet会先执行新建sheet页和切换到该sheet页的操作,才能在新建的sheet页加上数据透视表。
10. 动态数组:
- 发送到后台:
```json
{
"t": "all",
"i": "Sheet_r3Cz5bbxipL3_1598252547290",
"v": [
{
"r": 4,
"c": 5,
"f": "=UNIQUE(B2:E9)",
"data": [
[ 1, 2, 3, 4 ],
[ 2, 3, 4, 5 ],
[ 3, 4, 5, 6 ],
[ 4, 5, 6, 7 ],
[ 5, 6, 7, 8 ],
[ 6, 7, 8, 9 ],
[ 7, 8, 9, 10 ],
[ 8, 9, 10, 11 ]
]
}
],
"k": "dynamicArray"
}
```
- 后台更新:
```js
luckysheetfile["Sheet_r3Cz5bbxipL3_1598252547290"]["dynamicArray"] = [
{
"r": 4,
"c": 5,
"f": "=UNIQUE(B2:E9)",
"data": [
[ 1, 2, 3, 4 ],
[ 2, 3, 4, 5 ],
[ 3, 4, 5, 6 ],
[ 4, 5, 6, 7 ],
[ 5, 6, 7, 8 ],
[ 6, 7, 8, 9 ],
[ 7, 8, 9, 10 ],
[ 8, 9, 10, 11 ]
]
}
]
```
## 函数链操作
- **格式**
```json
{
"t": "fc",
"i": 0,
"v": {
"r": 3,
"c": 7,
"index": 0,
"func": [
true,
187282,
"=SUM(E4:G4)"
]
},
"i": "0",
"v": "{\"r\":1,\"c\":1,\"index\":\"0\",\"func\":[true,3,\"=sum(A1:B1)\"]}",
"op": "add",
"pos": 0
"pos": 1
}
```
- **说明**
@ -207,13 +563,29 @@
- **后台更新**
calcChain为一个数组
- 如果`op`的值为`add`则添加到末尾 `luckysheetfile[i].calcChain.push (v)`
- 如果`op`的值为`update`则更新 `luckysheetfile[i].calcChain[pos]= v`
- 如果`op`的值为`del`则删除 `luckysheetfile[i].calcChain.splice(pos, 1)`
- **前台查看**
可以修改任意单元格的数值,然后到chrome控制台中查看`"t"=="v"`的操作。
- 如果`op`的值为`add`则添加到末尾 `luckysheetfile[0].calcChain.push(v)`
- 如果`op`的值为`update`,格式为:
```json
{
"t": "fc",
"i": "0",
"v": "{\"r\":0,\"c\":3,\"index\":\"0\",\"func\":[true,1,\"=Formula!A1+Formula!B1+1\"],\"color\":\"w\",\"parent\":null,\"chidren\":{},\"times\":0}",
"op": "update",
"pos": 0
}
```
更新 `luckysheetfile[0].calcChain[pos] = v`
- 如果`op`的值为`del`则删除,格式为:
```json
{
"t": "fc",
"i": 0,
"v": null,
"op": "del",
"pos": 0
}
```
`luckysheetfile[0].calcChain.splice(pos, 1)`
## 行列操作
@ -271,10 +643,6 @@
主要是对 `luckysheetfile[i].celldata` 中的单元格进行操作,删除参数中所描述符合条件的单元格并且更新其他单元格的行列值,以上述为例,首先查找单元格中`r`值在4到8的所有单元格并删除,然后把本来行号9以后的单元格的`r`值减去5,最后把 `luckysheetfile[i].row` 减去5。
如果`v`值为 `"#__qkdelete#"`(不含引号),则此处为需要删除的单元格。
- **前台查看**
可以删除行或者列,然后到chrome控制台中查看`"t"=="drc"`的操作。
### 增加行或列
- **格式**
@ -282,13 +650,14 @@
```json
{
"t": "arc",
"i": 0,
"i": "0",
"v": {
"index": 5,
"len": 10,
"index": 1,
"len": 1,
"direction": "lefttop",
"data": []
},
"rc": "c"
"rc": "r"
}
```
@ -312,7 +681,7 @@
<td>行操作还是列操作,值`r`代表行,`c`代表列</td>
</tr>
<tr>
<td rowspan="3">v</td>
<td rowspan="4">v</td>
<td>index</td>
<td>从第几行或者列开始新增</td>
</tr>
@ -320,6 +689,10 @@
<td>len</td>
<td>增加多少行或者列</td>
</tr>
<tr>
<td>direction</td>
<td>方向</td>
</tr>
<tr>
<td>data</td>
<td>新增行或者列的内容</td>
@ -346,39 +719,8 @@
return ret;
```
- **前台查看**
可以新增行或者列,然后到chrome控制台中查看`"t"=="arc"`的操作。如果想查看具有`data`值的操作,则先删除某几行或几列,然后再撤销删除(Ctrl+Z),就能看到。
## 筛选操作
### 选择筛选条件
- **格式**
```json
{
"t": "f",
"i": 0,
"v": "{\"caljs\":{},\"selected\":{\"青岛\":\"1\",\"广西\":\"1\",\"重庆\":\"1\"},\"rowhidden\":{\"1\":0,\"2\":0,\"3\":0,\"4\":0,\"6\":0,\"7\":0,\"8\":0,\"9\":0,\"10\":0,\"11\":0,\"12\":0,\"13\":0,\"14\":0,\"15\":0,\"16\":0,\"17\":0,\"18\":0,\"19\":0,\"21\":0,\"22\":0,\"24\":0,\"25\":0,\"26\":0,\"27\":0,\"28\":0,\"29\":0,\"30\":0,\"31\":0,\"32\":0,\"33\":0,\"34\":0,\"35\":0}}",
"op": "upOrAdd",
"pos": 1
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|v|对象值,这里对象的内部字段不需要单独更新,所以存为文本即可|
|op|操作类型`upOrAdd`为更新,如果不存在则增加,`del`为删除|
|pos|更新或者删除的`option`位置|
- **后台更新**
更新 `luckysheetfile[i].filter = { pos : v }`, v值为一个JSON格式的字符串。filter为一个键值对,key表示选项位置的索引值(以字符表示),v表示一个json字符串参数。filter代表一个筛选条件的集合。
### 清除筛选
- **格式**
@ -393,7 +735,7 @@
- **后台更新**
清除 `luckysheetfile[i]. filter = null``luckysheetfile[i]. filter_select = null`
清除 `luckysheetfile[0].filter = null``luckysheetfile[i].filter_select = null`
### 恢复筛选
@ -425,12 +767,14 @@
"t": "sha",
"i": null,
"v": {
"name": "Sheet4",
"name": "Sheet11",
"color": "",
"status": "0",
"order": 3,
"index": 3,
"data": [],
"order": 10,
"index": "Sheet_oWlM5pKnwL1s_1598331858653",
"celldata": [],
"row": 84,
"column": 60,
"config": {},
"pivotTable": null,
"isPivotTable": false
@ -454,7 +798,7 @@
<td>当前sheet的index值</td>
</tr>
<tr>
<td rowspan="9">v</td>
<td rowspan="11">v</td>
<td>name</td>
<td>隐藏后跳转的sheet的index值</td>
</tr>
@ -478,6 +822,14 @@
<td>celldata</td>
<td>单元格数据集</td>
</tr>
<tr>
<td>row</td>
<td>行数</td>
</tr>
<tr>
<td>column</td>
<td>列数</td>
</tr>
<tr>
<td>config</td>
<td>设置</td>
@ -496,6 +848,8 @@
- **后台更新**
添加一行(一个文档)到数据库中。
`luckysheetfile.push(json)`
### 复制sheet
@ -504,9 +858,10 @@
```json
{
"t": "shc",
"i": "新建sheet的位置",
"i": "Sheet_e5pKTeloilhe_1598332166630",
"v": {
"copyindex": "copyindex"
"copyindex": 0,
"name": "Cell(Copy)"
}
}
```
@ -552,15 +907,61 @@
删除索引为`deleIndex`对应值的sheet。
### 位置
### 删除sheet后恢复操作
- **格式**
```json
{
"t": "shre",
"i": null,
"v": {
"reIndex": "0"
}
}
```
- **说明**
<table>
<tr>
<td colspan="2">参数</td>
<td>说明</td>
</tr>
<tr>
<td colspan="2">t</td>
<td>操作类型表示符号</td>
</tr>
<tr>
<td rowspan="2">v</td>
<td>deleIndex</td>
<td>需要恢复的sheet索引</td>
</tr>
</table>
- **后台更新**
恢复索引为`reIndex`对应值的sheet。
### 调整sheet位置
- **格式**
```json
{
"t": "shr",
"i": null,
"v": {
"index": "positon"
"0": 1,
"1": 0,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"Sheet_6az6nei65t1i_1596209937084": 8
}
}
```
@ -580,17 +981,15 @@
`luckysheetfile[key2].order = value2`
`luckysheetfile[key3].order = value3`
## sheet属性(隐藏或显示)
### 切换到指定sheet
- **格式**
```json
{
"t": "sh",
"i": 0,
"v": 1,
"op": " hide",
"cur": 2
"t": "shs",
"i": null,
"v": 1
}
```
@ -599,27 +998,27 @@
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|i|当前sheet的index值|
|op|操作选项,有hide、show|
|v|如果`hide`为`1`则隐藏,为`0`或者空则为显示|
|cur|隐藏后设置索引对应`cur`的sheet为激活状态|
|v|要切换到的sheet页索引|
- **后台更新**
更新`i`对应sheet的根路径`hide`字段为`v`,当隐藏时`status`值为`0`,当显示时为`1`,如果为隐藏则更新`index`对应`cur`的sheet的`status`状态为`1`。
对sheet的`index`等于`v`的页,设置其`status`属性为`1`值。示例:
## 表格信息更改
`luckysheetfile[v].status = 1`
### 表格名称
## sheet属性(隐藏或显示)
- **格式**
```json
{
"t": "na",
"i": null,
"v": "数据"
"t": "sh",
"i": 0,
"v": 1,
"op": "hide",
"cur": 1
}
```
- **说明**
@ -627,32 +1026,57 @@
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|v|表格的名称|
|i|当前sheet的index值|
|op|操作选项,有hide、show|
|v|如果`hide`为`1`则隐藏,为`0`或者空则为显示|
|cur|隐藏后设置索引对应`cur`的sheet为激活状态|
- **后台更新**
根据gridkey更新数据库中的表格名称。
更新`i`对应sheet的根路径`hide`字段为`v`
### 缩略图
当隐藏时`status`值为`0`,更新`index`对应`cur`的sheet的`status`状态为`1`
`luckysheetfile[0].hide = 1`
`luckysheetfile[0].status = 0`
`luckysheetfile[1].status = 1`
显示某个sheet页时,json为
```json
{
"t": "sh",
"i": 6,
"v": 0,
"op": "show"
}
```
`status`值为`1`,上一个激活sheet的`status`状态为`0`
`luckysheetfile[6].hide = 0`
`luckysheetfile[6].status = 1`
`luckysheetfile[old_cur].status = 0`
## 表格信息更改
### 修改工作簿名称
- **格式**
```json
{
"t": "thumb",
"img": "base64",
"curindex": "curindx"
}
```
```json
{
"t": "na",
"i": null,
"v": "Luckysheet Demo1"
}
```
- **说明**
|参数|说明|
| ------------ | ------------ |
|t|操作类型表示符号|
|img|当前表格的缩略图,为base64字符串|
|curindex|当前表格默认打开的sheet|
|v|工作簿名称|
- **后台更新**
根据gridkey更新mysql中表格的缩略图字段为img值,同时更新index为curindex值的sheet的status字段为1,设置其他sheet的status值为0。
Luckysheet配置,修改title为`"Luckysheet Demo1"`

78
docs/zh/guide/sheet.md

@ -416,18 +416,8 @@ options.data示例如下:
```js
{
"pivot_select_save": {
"left": 0,
"width": 73,
"top": 0,
"height": 19,
"left_move": 0,
"width_move": 369,
"top_move": 0,
"height_move": 259,
"row": [0, 12],
"column": [0, 4],
"row_focus": 0,
"column_focus": 0
"column": [0, 4]
},
"pivotDataSheetIndex": 6, //The sheet index where the source data is located
"column": [{
@ -469,24 +459,9 @@ options.data示例如下:
- 示例:
```js
{
"left": 74,
"width": 73,
"top": 40,
"height": 19,
"left_move": 74,
"width_move": 221,
"top_move": 40,
"height_move": 99,
"row": [
2,
6
],
"column": [
1,
3
],
"row_focus": 2,
"column_focus": 1
"row": [ 2, 6 ],
"column": [ 1, 3 ]
}
```
@ -499,23 +474,22 @@ options.data示例如下:
```js
{
"0": {
"caljs": {},
"rowhidden": {
"3": 0,
"4": 0
"caljs": { // 条件筛选类型
"value": "cellnull",
"text": "Is empty",
"type": "0"
},
"optionstate": true,
"str": 2,
"edr": 6,
"cindex": 1,
"stc": 1,
"edc": 3
"rowhidden": { "3": 0, "4": 0 }, // 隐藏行
"optionstate": true, //是否开启配置
"str": 2, // 范围,起始行
"edr": 6, // 范围,结束行
"cindex": 1, // 当前范围列索引
"stc": 1, // 范围,起始列
"edc": 3 // 范围,结束列
},
"1": {
"caljs": {},
"rowhidden": {
"6": 0
},
"rowhidden": { "6": 0 },
"optionstate": true,
"str": 2,
"edr": 6,
@ -619,13 +593,13 @@ options.data示例如下:
- 默认值:[]
- 作用: 条件格式配置信息,包含多个条件格式配置对象的一维数组,
type: "default": 突出显示单元格规则和项目选区规则,
type: "default": 突出显示单元格规则和项目选区规则,
"dataBar":数据条,
"dataBar":数据条,
"icons":图标集,
"icons":图标集,
"colorGradation": 色阶
"colorGradation": 色阶
- 示例:
```js
@ -687,18 +661,8 @@ type: "default": 突出显示单元格规则和项目选区规则,
"type": "colorGradation",
"cellrange": [
{
"left": 422,
"width": 100,
"top": 210,
"height": 20,
"left_move": 422,
"width_move": 100,
"top_move": 210,
"height_move": 125,
"row": [ 10, 15 ],
"column": [ 6, 6 ],
"row_focus": 10,
"column_focus": 6
"column": [ 6, 6 ]
}
],
"format": [

59
src/controllers/constant.js

File diff suppressed because one or more lines are too long

27
src/controllers/controlHistory.js

@ -14,6 +14,7 @@ import {
jfrefreshrange,
jfrefreshgrid_rhcw,
jfrefreshgrid_adRC,
jfrefreshgrid_deleteCell,
jfrefreshgrid_pastcut,
luckysheetrefreshgrid
} from '../global/refresh';
@ -140,6 +141,9 @@ const controlHistory = {
jfrefreshgrid_adRC(ctr.data, ctr.config, "addRC", ctrlValue, ctr.calc, ctr.filterObj, ctr.cf, ctr.af, ctr.freezen);
}
else if (ctr.type == "deleteCell") { //删除单元格撤销操作
jfrefreshgrid_deleteCell(ctr.data, ctr.config, ctr.ctrl, ctr.calc, ctr.filterObj, ctr.cf);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 撤销操作
//config
Store.config = ctr.config;
@ -150,6 +154,16 @@ const controlHistory = {
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
else if (ctr.type == "showHidCols") { // 隐藏、显示列 撤销操作
//config
Store.config = ctr.config;
Store.luckysheetfile[getSheetIndex(ctr.sheetIndex)].config = ctr.config;
server.saveParam("cg", ctr.sheetIndex, ctr.config["colhidden"], { "k": "colhidden" });
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
else if (ctr.type == "datachangeAll") {
formula.execFunctionGroup();
jfrefreshgridall(ctr.data[0].length, ctr.data.length, ctr.data, null, ctr.range, "datachangeAll", ctr.ctrlValue);
@ -388,6 +402,9 @@ const controlHistory = {
else if (ctr.type == "delRC") { //删除行列重做操作
jfrefreshgrid_adRC(ctr.curData, ctr.curConfig, "delRC", ctr.ctrlValue, ctr.curCalc, ctr.curFilterObj, ctr.curCf, ctr.curAf, ctr.curFreezen);
}
else if (ctr.type == "deleteCell") { //删除单元格重做操作
jfrefreshgrid_deleteCell(ctr.curData, ctr.curConfig, ctr.ctrl, ctr.curCalc, ctr.curFilterObj, ctr.curCf);
}
else if (ctr.type == "showHidRows") { // 隐藏、显示行 重做操作
//config
Store.config = ctr.curconfig;
@ -398,6 +415,16 @@ const controlHistory = {
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
else if (ctr.type == "showHidCols") { // 隐藏、显示列 重做操作
//config
Store.config = ctr.curconfig;
Store.luckysheetfile[getSheetIndex(ctr.sheetIndex)].config = ctr.curconfig;
server.saveParam("cg", ctr.sheetIndex, ctr.curconfig["colhidden"], { "k": "colhidden" });
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
else if (ctr.type == "datachangeAll") {
formula.execFunctionGroup();
jfrefreshgridall(ctr.curdata[0].length, ctr.curdata.length, ctr.curdata, null, ctr.currange, "datachangeAll", ctr.ctrlValue);

4
src/controllers/filter.js

@ -746,6 +746,10 @@ function initialFilterHandler(){
//单元格颜色
let bg = menuButton.checkstatus(Store.flowdata, r, cindex , "bg");
if(bg == null){
bg = "#ffffff";
}
let checksAF = alternateformat.checksAF(r, cindex, af_compute);
if(checksAF != null){//若单元格有交替颜色
bg = checksAF[1];

138
src/controllers/rowColumnOperation.js

@ -21,7 +21,7 @@ import {
import { isRealNull, isRealNum, hasPartMC, isEditMode } from '../global/validate';
import { countfunc } from '../global/count';
import formula from '../global/formula';
import { luckysheetextendtable, luckysheetdeletetable } from '../global/extend';
import { luckysheetextendtable, luckysheetdeletetable, luckysheetDeleteCell } from '../global/extend';
import {
jfrefreshgrid,
jfrefreshgridall,
@ -1295,9 +1295,7 @@ export function rowColumnOperationInitial(){
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let r1 = Store.luckysheet_select_save[s].row[0],
r2 = Store.luckysheet_select_save[s].row[1],
c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];
r2 = Store.luckysheet_select_save[s].row[1];
for(let r = r1; r <= r2; r++){
cfg["rowhidden"][r] = 0;
@ -1336,9 +1334,7 @@ export function rowColumnOperationInitial(){
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let r1 = Store.luckysheet_select_save[s].row[0],
r2 = Store.luckysheet_select_save[s].row[1],
c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];
r2 = Store.luckysheet_select_save[s].row[1];
for(let r = r1; r <= r2; r++){
delete cfg["rowhidden"][r];
@ -1367,6 +1363,134 @@ export function rowColumnOperationInitial(){
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
})
//隐藏、显示列
$("#luckysheet-hidCols").click(function (event) {
$("#luckysheet-rightclick-menu").hide();
luckysheetContainerFocus();
let cfg = $.extend(true, {}, Store.config);
if(cfg["colhidden"] == null){
cfg["colhidden"] = {};
}
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];
for(let c = c1; c <= c2; c++){
cfg["colhidden"][c] = 0;
}
}
//保存撤销
if(Store.clearjfundo){
let redo = {};
redo["type"] = "showHidCols";
redo["sheetIndex"] = Store.currentSheetIndex;
redo["config"] = $.extend(true, {}, Store.config);
redo["curconfig"] = cfg;
Store.jfundo = [];
Store.jfredo.push(redo);
}
//config
Store.config = cfg;
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
server.saveParam("cg", Store.currentSheetIndex, cfg["colhidden"], { "k": "colhidden" });
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
})
$("#luckysheet-showHidCols").click(function (event) {
$("#luckysheet-rightclick-menu").hide();
luckysheetContainerFocus();
let cfg = $.extend(true, {}, Store.config);
if(cfg["colhidden"] == null){
return;
}
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];
for(let c = c1; c <= c2; c++){
delete cfg["colhidden"][c];
}
}
//保存撤销
if(Store.clearjfundo){
let redo = {};
redo["type"] = "showHidCols";
redo["sheetIndex"] = Store.currentSheetIndex;
redo["config"] = $.extend(true, {}, Store.config);
redo["curconfig"] = cfg;
Store.jfundo = [];
Store.jfredo.push(redo);
}
//config
Store.config = cfg;
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
server.saveParam("cg", Store.currentSheetIndex, cfg["colhidden"], { "k": "colhidden" });
//行高、列宽 刷新
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
})
//删除单元格(左移、上移)
$("#luckysheet-delCellsMoveLeft").click(function (event) {
$("#luckysheet-rightclick-menu").hide();
luckysheetContainerFocus();
const locale_drag = locale().drag;
if(Store.luckysheet_select_save.length > 1){
if(isEditMode()){
alert(locale_drag.noMulti);
}
else{
tooltip.info(locale_drag.noMulti, "");
}
return;
}
let str = Store.luckysheet_select_save[0].row[0],
edr = Store.luckysheet_select_save[0].row[1],
stc = Store.luckysheet_select_save[0].column[0],
edc = Store.luckysheet_select_save[0].column[1];
luckysheetDeleteCell('moveLeft', str, edr, stc, edc);
});
$("#luckysheet-delCellsMoveUp").click(function (event) {
$("#luckysheet-rightclick-menu").hide();
luckysheetContainerFocus();
const locale_drag = locale().drag;
if(Store.luckysheet_select_save.length > 1){
if(isEditMode()){
alert(locale_drag.noMulti);
}
else{
tooltip.info(locale_drag.noMulti, "");
}
return;
}
let str = Store.luckysheet_select_save[0].row[0],
edr = Store.luckysheet_select_save[0].row[1],
stc = Store.luckysheet_select_save[0].column[0],
edc = Store.luckysheet_select_save[0].column[1];
luckysheetDeleteCell('moveUp', str, edr, stc, edc);
});
//清除单元格内容
$("#luckysheet-delete-text").click(function(){
$("#luckysheet-rightclick-menu").hide();

4
src/controllers/server.js

@ -315,10 +315,10 @@ const server = {
let k = item.k;
file[k] = value;
if(k == "name"){ //表
if(k == "name"){ //工作表名
$("#luckysheet-sheet-container-c #luckysheet-sheets-item" + index).find("span.luckysheet-sheets-item-name").html(value);
}
else if(k == "color"){ //表颜色
else if(k == "color"){ //工作表颜色
let currentSheetItem = $("#luckysheet-sheet-container-c #luckysheet-sheets-item" + index);
currentSheetItem.find(".luckysheet-sheets-item-color").remove();

160
src/global/draw.js

@ -224,27 +224,32 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
// break;
// }
luckysheetTableContent.fillStyle = "#ffffff";
luckysheetTableContent.fillRect(
(start_c + offsetLeft - 1) ,
0,
(end_c - start_c) ,
Store.columeHeaderHeight -1
)
luckysheetTableContent.fillStyle = "#000000";
if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
//列标题栏序列号
luckysheetTableContent.save();//save scale before draw text
luckysheetTableContent.scale(Store.zoomRatio,Store.zoomRatio);
let abc = chatatABC(c);
let textMetrics = getMeasureText(abc, luckysheetTableContent);
//luckysheetTableContent.measureText(abc);
}
else {
luckysheetTableContent.fillStyle = "#ffffff";
luckysheetTableContent.fillRect(
(start_c + offsetLeft - 1) ,
0,
(end_c - start_c) ,
Store.columeHeaderHeight -1
)
luckysheetTableContent.fillStyle = "#000000";
let horizonAlignPos = Math.round((start_c + (end_c - start_c) / 2 + offsetLeft) - textMetrics.width / 2);
let verticalAlignPos = Math.round(Store.columeHeaderHeight / 2 );
//列标题栏序列号
luckysheetTableContent.save();//save scale before draw text
luckysheetTableContent.scale(Store.zoomRatio,Store.zoomRatio);
let abc = chatatABC(c);
let textMetrics = getMeasureText(abc, luckysheetTableContent);
//luckysheetTableContent.measureText(abc);
luckysheetTableContent.fillText(abc, horizonAlignPos/Store.zoomRatio, verticalAlignPos/Store.zoomRatio);
luckysheetTableContent.restore();//restore scale after draw text
let horizonAlignPos = Math.round((start_c + (end_c - start_c) / 2 + offsetLeft) - textMetrics.width / 2);
let verticalAlignPos = Math.round(Store.columeHeaderHeight / 2 );
luckysheetTableContent.fillText(abc, horizonAlignPos/Store.zoomRatio, verticalAlignPos/Store.zoomRatio);
luckysheetTableContent.restore();//restore scale after draw text
}
//列标题栏竖线 vertical
luckysheetTableContent.beginPath();
@ -466,6 +471,10 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let end_r = Store.visibledatarow[r] - scrollHeight;
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
continue;
}
for (let c = dataset_col_st; c <= dataset_col_ed; c++) {
let start_c;
if (c == 0) {
@ -477,78 +486,77 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
let end_c = Store.visibledatacolumn[c] - scrollWidth;
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
if (Store.config["colhidden"] != null && Store.config["colhidden"][c] != null) {
continue
}
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
firstcolumnlen = Store.config["columnlen"][c];
}
else {
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
firstcolumnlen = Store.config["columnlen"][c];
}
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null) {
let value = Store.flowdata[r][c];
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null) {
let value = Store.flowdata[r][c];
if(getObjType(value) == "object" && ("mc" in value)){
borderOffset[r + "_" + c] = {
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
};
if(getObjType(value) == "object" && ("mc" in value)){
borderOffset[r + "_" + c] = {
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
};
if("rs" in value["mc"]){
let key = "r"+ r + "c" + c;
mergeCache[key] = cellupdate.length;
}
else{
let key = "r"+ value["mc"].r + "c" + value["mc"].c;
let margeMain = cellupdate[mergeCache[key]];
if("rs" in value["mc"]){
let key = "r"+ r + "c" + c;
if(margeMain == null){
mergeCache[key] = cellupdate.length;
cellupdate.push({
"r": r,
"c": c,
"start_c": start_c,
"start_r": start_r,
"end_r": end_r,
"end_c": end_c,
"firstcolumnlen": firstcolumnlen,
});
}
else{
let key = "r"+ value["mc"].r + "c" + value["mc"].c;
let margeMain = cellupdate[mergeCache[key]];
if(margeMain == null){
mergeCache[key] = cellupdate.length;
cellupdate.push({
"r": r,
"c": c,
"start_c": start_c,
"start_r": start_r,
"end_r": end_r,
"end_c": end_c,
"firstcolumnlen": firstcolumnlen,
});
}
else{
if(margeMain.c == c){
margeMain.end_r += (end_r - start_r - 1);
}
if(margeMain.r == r){
margeMain.end_c += (end_c - start_c);
margeMain.firstcolumnlen += firstcolumnlen;
}
if(margeMain.c == c){
margeMain.end_r += (end_r - start_r - 1);
}
continue;
if(margeMain.r == r){
margeMain.end_c += (end_c - start_c);
margeMain.firstcolumnlen += firstcolumnlen;
}
}
continue;
}
}
cellupdate.push({
"r": r,
"c": c,
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c,
"firstcolumnlen": firstcolumnlen,
});
borderOffset[r + "_" + c] = {
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
};
}
cellupdate.push({
"r": r,
"c": c,
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c,
"firstcolumnlen": firstcolumnlen,
});
borderOffset[r + "_" + c] = {
"start_r": start_r,
"start_c": start_c,
"end_r": end_r,
"end_c": end_c
};
}
}

478
src/global/extend.js

@ -1,8 +1,9 @@
import editor from './editor';
import formula from './formula';
import { jfrefreshgrid_adRC, jfrefreshgrid_rhcw } from './refresh';
import { jfrefreshgrid_adRC, jfrefreshgrid_deleteCell, jfrefreshgrid_rhcw } from './refresh';
import { datagridgrowth } from './getdata';
import { setcellvalue } from './setdata';
import conditionformat from '../controllers/conditionformat';
import luckysheetFreezen from '../controllers/freezen';
import { selectHightlightShow } from '../controllers/select';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
@ -808,6 +809,7 @@ function luckysheetextendData(rowlen, newData) {
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
//删除行列
function luckysheetdeletetable(type, st, ed) {
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
@ -1481,8 +1483,482 @@ function luckysheetdeletetable(type, st, ed) {
);
}
//删除单元格
function luckysheetDeleteCell(type, str, edr, stc, edc) {
let d = editor.deepCopyFlowData(Store.flowdata);
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
let rlen = edr - str + 1;
let clen = edc - stc + 1;
let cfg = $.extend(true, {}, Store.config);
//合并单元格配置变动
if(cfg["merge"] == null){
cfg["merge"] = {};
}
let merge_new = {};
for(let m in cfg["merge"]){
let mc = cfg["merge"][m];
let r = mc.r,
c = mc.c,
rs = mc.rs,
cs = mc.cs;
if(type == "moveLeft"){
if(str > r + rs - 1 || edr < r || stc > c + cs - 1){
merge_new[r + "_" + c] = { "r": r, "c": c, "rs": rs, "cs": cs };
}
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 if(type == "moveUp"){
if(stc > c + cs - 1 || edc < c || str > r + rs - 1){
merge_new[r + "_" + c] = { "r": r, "c": c, "rs": rs, "cs": cs };
}
else if(stc <= c && edc >= c + cs - 1 && edr < r){
merge_new[(r - rlen) + "_" + c] = { "r": r - rlen, "c": c, "rs": rs, "cs": cs };
}
}
}
cfg["merge"] = merge_new;
//公式配置变动
let calcChain = file.calcChain;
let newCalcChain = [];
if(calcChain != null && calcChain.length > 0){
for(let i = 0; i < calcChain.length; i++){
let calc = $.extend(true, {}, calcChain[i]);
let calc_r = calc.r, calc_c = calc.c, calc_i = calc.index, calc_funcStr = calc.func[2];
if((calc_r < str || calc_r > edr) && (calc_c < stc || calc_c > edc)){
let functionStr;
if(type == 'moveLeft'){
functionStr = "=" + formula.functionStrChange(calc_funcStr, "del", "col", null, stc, clen);
if(calc_c > edc){
calc.c = calc_c - clen;
}
}
else if(type == 'moveUp'){
functionStr = "=" + formula.functionStrChange(calc_funcStr, "del", "row", null, str, rlen);
if(calc_r > edr){
calc.r = calc_r - rlen;
}
}
if(d[calc_r][calc_c].f == calc_funcStr){
d[calc_r][calc_c].f = functionStr;
}
calc.func[2] = functionStr;
newCalcChain.push(calc);
}
}
}
//筛选配置变动
let filter_select = file.filter_select;
let filter = file.filter;
let newFilterObj = null;
if(filter_select != null && JSON.stringify(filter_select) != "{}"){
newFilterObj = { "filter_select": null, "filter": null };
let f_r1 = filter_select.row[0], f_r2 = filter_select.row[1];
let f_c1 = filter_select.column[0], f_c2 = filter_select.column[1];
if(type == 'moveUp'){
if(f_c1 >= stc && f_c2 <= edc){
if(f_r1 > edr){
newFilterObj.filter_select = {
"row": [f_r1 - rlen, f_r2 - rlen],
"column": [f_c1, f_c2]
}
}
else if(f_r2 < str){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
}
else if(f_r1 < str){
if(f_r2 > edr){
newFilterObj.filter_select = {
"row": [f_r1, f_r2 - rlen],
"column": [f_c1, f_c2]
}
}
else{
newFilterObj.filter_select = {
"row": [f_r1, str - 1],
"column": [f_c1, f_c2]
}
}
}
if(newFilterObj.filter_select != null && filter != null){
for(let k in filter){
let f_rowhidden = filter[k].rowhidden;
let f_rowhidden_new = {};
for(let n in f_rowhidden){
if(n < str){
f_rowhidden_new[n] = 0;
}
else if(n > edr){
f_rowhidden_new[n - slen] = 0;
}
}
if(newFilterObj.filter == null){
newFilterObj.filter = {};
}
newFilterObj.filter[k] = $.extend(true, {}, filter[k]);
if(JSON.stringify(f_rowhidden_new) != "{}"){
newFilterObj.filter[k].rowhidden = f_rowhidden_new;
}
newFilterObj.filter[k].str = newFilterObj.filter_select.row[0];
newFilterObj.filter[k].edr = newFilterObj.filter_select.row[1];
}
}
}
else if(f_r1 >= str && f_r2 <= edr){
if(f_c1 > edc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
}
else if(f_c1 >= stc){
if(f_c2 > edc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [stc, f_c2 - clen]
}
}
}
else{
if(f_c2 < stc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
}
else if(f_c2 <= edc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, stc - 1]
}
}
else{
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2 - clen]
}
}
}
if(newFilterObj.filter_select != null && filter != null){
for(let k in filter){
let f_stc = newFilterObj.filter_select.column[0];
let f_edc = newFilterObj.filter_select.column[1];
let f_cindex = filter[k].cindex;
if(f_cindex < stc || f_cindex > edc){
if(newFilterObj.filter == null){
newFilterObj.filter = {};
}
if(f_cindex > edc){
f_cindex -= clen;
}
let k2 = f_cindex - f_stc;
newFilterObj.filter[k2] = $.extend(true, {}, filter[k]);
newFilterObj.filter[k2].cindex = f_cindex;
newFilterObj.filter[k2].stc = f_stc;
newFilterObj.filter[k2].edc = f_edc;
}
}
}
}
else{
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
if(filter != null){
newFilterObj.filter = filter;
}
}
}
else if(type == 'moveLeft'){
if(f_r1 >= str && f_r2 <= edr){
if(f_c1 > edc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1 - clen, f_c2 - clen]
}
}
else if(f_c2 < stc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
}
else if(f_c1 < stc){
if(f_c2 > edc){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2 - clen]
}
}
else{
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, stc - 1]
}
}
}
if(newFilterObj.filter_select != null && filter != null){
for(let k in filter){
let f_stc = newFilterObj.filter_select.column[0];
let f_edc = newFilterObj.filter_select.column[1];
let f_cindex = filter[k].cindex;
if(f_cindex < stc || f_cindex > edc){
if(newFilterObj.filter == null){
newFilterObj.filter = {};
}
if(f_cindex > edc){
f_cindex -= clen;
}
let k2 = f_cindex - f_stc;
newFilterObj.filter[k2] = $.extend(true, {}, filter[k]);
newFilterObj.filter[k2].cindex = f_cindex;
newFilterObj.filter[k2].stc = f_stc;
newFilterObj.filter[k2].edc = f_edc;
}
}
}
}
else if(f_c1 >= stc && f_c2 <= edc){
if(f_r1 < str || f_r1 > edr){
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
if(filter != null){
newFilterObj.filter = filter;
}
}
}
else{
newFilterObj.filter_select = {
"row": [f_r1, f_r2],
"column": [f_c1, f_c2]
}
if(filter != null){
newFilterObj.filter = filter;
}
}
}
}
if(newFilterObj != null && newFilterObj.filter != null){
cfg["rowhidden"] = {};
for(let k in newFilterObj.filter){
let f_rowhidden = newFilterObj.filter[k].rowhidden;
for(let n in f_rowhidden){
cfg["rowhidden"][n] = 0;
}
}
}
else{
delete cfg["rowhidden"];
}
//条件格式配置变动
let CFarr = file.luckysheet_conditionformat_save;
let newCFarr = [];
if(CFarr != null && CFarr.length > 0){
for(let i = 0; i < CFarr.length; i++){
let cf_range = CFarr[i].cellrange;
let cf_new_range = [];
for(let j = 0; j < cf_range.length; j++){
let CFr1 = cf_range[j].row[0],
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(cf_new_range.length > 0){
let cf = $.extend(true, {}, CFarr[i]);
cf.cellrange = cf_new_range;
newCFarr.push(cf);
}
}
}
//边框配置变动
if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){
let borderInfo = [];
for(let i = 0; i < cfg["borderInfo"].length; i++){
let rangeType = cfg["borderInfo"][i].rangeType;
if(rangeType == "range"){
let borderRange = cfg["borderInfo"][i].range;
let emptyRange = [];
for(let j = 0; j < borderRange.length; j++){
let bd_r1 = borderRange[j].row[0],
bd_r2 = borderRange[j].row[1],
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(emptyRange.length > 0){
let bd_obj = {
"rangeType": "range",
"borderType": cfg["borderInfo"][i].borderType,
"style": cfg["borderInfo"][i].style,
"color": cfg["borderInfo"][i].color,
"range": emptyRange
}
borderInfo.push(bd_obj);
}
}
else if(rangeType == "cell"){
let row_index = cfg["borderInfo"][i].value.row_index;
let col_index = cfg["borderInfo"][i].value.col_index;
if(row_index < str || col_index < stc){
borderInfo.push(cfg["borderInfo"][i]);
}
else if(row_index > edr || col_index > edc){
if(row_index > edr){
row_index -= rlen;
cfg["borderInfo"][i].value.row_index = row_index;
}
if(col_index > edc){
col_index -= clen;
cfg["borderInfo"][i].value.col_index = col_index;
}
borderInfo.push(cfg["borderInfo"][i]);
}
}
}
cfg["borderInfo"] = borderInfo;
}
//空白列模板
let addcol = [];
for (let c = stc; c <= edc; c++) {
addcol.push(null);
}
if(type == 'moveUp'){//上移
let data = [];
for(let r = str; r <= d.length - 1; r++){
let row = [];
for(let c = stc; c <= edc; c++){
row.push(d[r][c]);
}
data.push(row);
}
data.splice(0, rlen);
//空白行模板
let addrow = [];
for (let r = str; r <= edr; r++) {
addrow.push(addcol);
}
data = data.concat(addrow);
for(let r = str; r <= d.length - 1; r++){
for(let c = stc; c <= edc; c++){
d[r][c] = data[r - str][c - stc];
}
}
}
else if(type == 'moveLeft'){//左移
for(let r = str; r <= edr; r++){
d[r].splice(stc, clen);
d[r] = d[r].concat(addcol);
}
}
jfrefreshgrid_deleteCell(
d,
cfg,
{ type: type, 'str': str, 'edr': edr, 'stc': stc, 'edc': edc },
newCalcChain,
newFilterObj,
newCFarr
);
}
export {
luckysheetextendtable,
luckysheetextendData,
luckysheetdeletetable,
luckysheetDeleteCell,
}

157
src/global/refresh.js

@ -519,6 +519,162 @@ function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf,
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}
//删除单元格 刷新表格
function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf){
let file = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)];
//merge改变对应的单元格值改变
let mcData = [];
if(JSON.stringify(cfg["merge"]) == "{}"){
for(let r = 0; r < data.length; r++){
for(let c = 0; c < data[0].length; c++){
let cell = data[r][c];
if(cell != null && cell.mc != null){
delete cell.mc;
mcData.push({ "r": r, "c": c });
}
}
}
}
else{
for(let m in cfg["merge"]){
let mc = cfg["merge"][m];
for(let r = mc.r; r <= mc.r + mc.rs - 1; r++){
for(let c = mc.c; c <= mc.c + mc.cs - 1; c++){
if(data[r][c] == null){
data[r][c] = {};
}
if(r == mc.r && c == mc.c){
data[r][c].mc = mc;
}
else{
data[r][c].mc = { "r": mc.r, "c": mc.c };
}
mcData.push({ "r": r, "c": c });
}
}
}
}
//公式链中公式范围改变对应单元格值的改变
let funcData = [];
if(calc.length > 0){
formula.execFunctionGroupData = data;
for(let i = 0; i < calc.length; i++){
let clc = calc[i];
let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = clc.func[2];
let clc_result = formula.execfunction(clc_funcStr, clc_r, clc_c, null, true);
clc.func = clc_result;
if(data[clc_r][clc_c].f == clc_funcStr){
setcellvalue(clc_r, clc_c, data, clc_result[1]);
funcData.push({ "r": clc_r, "c": clc_c });
}
}
}
if(Store.clearjfundo){
Store.jfundo = [];
Store.jfredo.push({
"type": "deleteCell",
"sheetIndex": Store.currentSheetIndex,
"ctrl": ctrl,
"data": Store.flowdata,
"curData": data,
"config": $.extend(true, {}, Store.config),
"curConfig": cfg,
"mcData": mcData,
"calc": $.extend(true, [], file.calcChain),
"curCalc": calc,
"funcData": funcData,
"filterObj": { "filter_select": $.extend(true, {}, file.filter_select), "filter": $.extend(true, {}, file.filter) },
"curFilterObj": filterObj,
"cf": $.extend(true, [], file.luckysheet_conditionformat_save),
"curCf": cf,
});
}
//Store.flowdata
Store.flowdata = data;
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
file.data = data;
//共享编辑模式
if(server.allowUpdate){
let type = ctrl.type,
str = ctrl.str,
edr = ctrl.edr,
stc = ctrl.stc,
edc = ctrl.edc;
let range;
if(type == 'moveUp'){
range = {
"row": [str, data.length - 1],
"column": [stc, edc]
}
}
else if(type == 'moveLeft'){
range = {
"row": [str, edr],
"column": [stc, data[0].length - 1]
};
}
server.historyParam(Store.flowdata, Store.currentSheetIndex, range);
}
//config
Store.config = cfg;
file.config = Store.config;
server.saveParam("all", Store.currentSheetIndex, cfg, { "k": "config" });
//mcData
for(let i = 0; i < mcData.length; i++){
let mcData_r = mcData[i].r,
mcData_c = mcData[i].c;
server.saveParam("v", Store.currentSheetIndex, Store.flowdata[mcData_r][mcData_c], { "r": mcData_r, "c": mcData_c });
}
//calc函数链
file.calcChain = calc;
server.saveParam("all", Store.currentSheetIndex, calc, { "k": "calcChain" });
for(let i = 0; i < funcData.length; i++){
let funcData_r = funcData[i].r,
funcData_c = funcData[i].c;
server.saveParam("v", Store.currentSheetIndex, Store.flowdata[funcData_r][funcData_c], { "r": funcData_r, "c": funcData_c });
}
//筛选配置
if(filterObj != null){
file.filter_select = filterObj.filter_select;
file.filter = filterObj.filter;
}
else{
file.filter_select = null;
file.filter = null;
}
createFilterOptions(file.filter_select, file.filter);
server.saveParam("all", Store.currentSheetIndex, file.filter_select, { "k": "filter_select" });
server.saveParam("all", Store.currentSheetIndex, file.filter, { "k": "filter" });
//条件格式配置
file.luckysheet_conditionformat_save = cf;
server.saveParam("all", Store.currentSheetIndex, file.luckysheet_conditionformat_save, { "k": "luckysheet_conditionformat_save" });
setTimeout(function () {
luckysheetrefreshgrid();
}, 1);
}
//复制剪切 刷新表格
function jfrefreshgrid_pastcut(source, target, RowlChange){
//单元格数据更新联动
@ -1002,6 +1158,7 @@ export {
jfrefreshgridall,
jfrefreshrange,
jfrefreshgrid_adRC,
jfrefreshgrid_deleteCell,
jfrefreshgrid_pastcut,
jfrefreshgrid_rhcw,
luckysheetrefreshgrid,

29
src/global/rhchInit.js

@ -8,21 +8,19 @@ export default function rhchInit(rowheight, colwidth) {
Store.visibledatarow = [];
Store.rh_height = 0;
for (let i = 0; i < rowheight; i++) {
for (let r = 0; r < rowheight; r++) {
let rowlen = Store.defaultrowlen;
if (Store.config["rowlen"] != null && Store.config["rowlen"][i] != null) {
rowlen = Store.config["rowlen"][i];
if (Store.config["rowlen"] != null && Store.config["rowlen"][r] != null) {
rowlen = Store.config["rowlen"][r];
}
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][i] != null) {
rowlen = Store.config["rowhidden"][i];
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
Store.visibledatarow.push(Store.rh_height);
continue;
}
else {
Store.rh_height += Math.round((rowlen + 1)*Store.zoomRatio);
}
Store.rh_height += Math.round((rowlen + 1) * Store.zoomRatio);
Store.visibledatarow.push(Store.rh_height); //行的临时长度分布
}
@ -37,14 +35,14 @@ export default function rhchInit(rowheight, colwidth) {
let maxColumnlen = 120;
for (let i = 0; i < colwidth; i++) {
for (let c = 0; c < colwidth; c++) {
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][i] != null) {
firstcolumnlen = Store.config["columnlen"][i];
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
firstcolumnlen = Store.config["columnlen"][c];
}
else {
if (Store.flowdata[0] != null && Store.flowdata[0][i] != null) {
if (Store.flowdata[0] != null && Store.flowdata[0][c] != null) {
if (firstcolumnlen > 300) {
firstcolumnlen = 300;
}
@ -57,11 +55,16 @@ export default function rhchInit(rowheight, colwidth) {
Store.config["columnlen"] = {};
}
Store.config["columnlen"][i] = firstcolumnlen;
Store.config["columnlen"][c] = firstcolumnlen;
}
}
}
if(Store.config["colhidden"] != null && Store.config["colhidden"][c] != null){
Store.visibledatacolumn.push(Store.ch_width);
continue;
}
Store.ch_width += Math.round((firstcolumnlen + 1)*Store.zoomRatio);
Store.visibledatacolumn.push(Store.ch_width);//列的临时长度分布

5
src/locale/en.js

@ -492,15 +492,18 @@ export default {
paste: 'Paste',
insert: 'Insert',
delete: 'Delete',
deleteCell: 'Delete cell',
deleteSelected: 'Delete selected ',
hide: 'Hide',
hideSelected: 'Hide selected ',
showHide: 'Show hide',
showHide: 'Show hide ',
to: 'Towards',
left: 'Left',
right: 'Right',
top: 'Top',
bottom: 'Bottom',
moveLeft: 'Move left',
moveUp: 'Move up',
add: 'Add',
row: 'Row',
column: 'Column',

3
src/locale/zh.js

@ -509,6 +509,7 @@ export default {
paste: '粘贴',
insert: '插入',
delete: '删除',
deleteCell: '删除单元格',
deleteSelected: '删除选中',
hide: '隐藏',
hideSelected: '隐藏选中',
@ -518,6 +519,8 @@ export default {
right: '右',
top: '上',
bottom: '下',
moveLeft: '左移',
moveUp: '上移',
add: '增加',
row: '行',
column: '列',

Loading…
Cancel
Save