16 KiB
Table Operation
Cell refresh
-
Format:
{ "t": "v", "i": 3, "v": "asdf", "r": 5, "c": 7 } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v Cell value r Row number of cell c The column number of the cell -
Backend update:
The cell update is mainly to update the
luckysheetfile[i].celldataparameter, which is an array:[ {r:0, c:1, v: "value1"}, {r:10, c:11, v:"value2"}, {r:10, c:11, v:{f:"=sum", v:"100"}} ]Store the values in all the cells in the sheet, Luckysheet will create a new table data according to the number of rows and columns in
luckysheetfile[i].rowandluckysheetfile[i].columnwhen it is created, and then usedata[ r][c]=vto fill the table data, empty data cells are represented by null.When saving the data posted by the frontend, the backend needs to convert the parameters to the format of
{r:0, c:1:v:100}first, and then update the field ofluckysheetfile[i].celldata, if the cell exists the cell is updated, if not, it is added, and if the cell exists butvis null, the cell is deleted. -
Frontend view:
You can modify the value of any cell, and then go to the chrome console to view the operation of
"t"=="v".
Config operation
-
Format:
{ "t": "cg", "i": 3, "v": { "7": 192 }, "k": "rowlen" } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v The internal key-value that needs to be updated k Operation key name -
Backend update:
Update
luckysheetfile[i].config.[k][v.key] = v.value, ifkdoes not exist inconfig, then create a newkattribute and set it to empty, If there is nov.keyink, create a newv.keyand updatev.value.-
Examples of modifying row height:
- Enter:
{"t":"cg","i":3,"v":{"3":10, "5":70, "10":100},"k":" rowlen"} - Update:
luckysheetfile[3].config.["rowlen"]["3"] = 10
- Enter:
-
Examples of modifying column width:
- Enter:
{"t":"cg","i":1,"v":{"20":74, "15":170, "6":40},"k":" columnlen"} - Update:
luckysheetfile[1].config.["columnlen"]["20"] = 74
- Enter:
-
Examples of merged cells:
- Enter:
{"t":"cg","i":1,"v":{"5_10":{row:[1,3], column:[3,5]},"k":" merge "} - Update:
luckysheetfile[1].config.["merge"]["5_10"] = {row:[1,3], column:[3,5]}
- Enter:
-
General save
-
Format:
{ "t": "all", "i": 3, "v": { "v": 1, "m":1, }, "k": "freezen", "s": false } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v The internal key-value that needs to be updated k The valuein the key-value that needs to be saveds If it is truethenvis saved as a string, otherwise it is saved according to the object -
Backend update:
luckysheetfile[3].[k]= vIfsistrue, it isluckysheetfile[3].[k]= JSON.stringify(v)-
Pivot table:
- Enter:
{"t":"all","i":1,"v":{………},"k":"pivotTable", "s": false} - Update:
luckysheetfile[1].["pivotTable"] = {………}
- Enter:
-
Freeze rows and columns:
- Enter:
{"t":"all","i":3,"v":{………},"k":"freezen", "s": false} - Update:
luckysheetfile[3].["freezen"] = {………}
- Enter:
-
Filter range:
- Enter:
{"t":"all","i":3,"v":{………},"k":"filter_select", "s": true } - Update:
luckysheetfile[3].["filter_select"] = JSON.stringify ({………})
- Enter:
-
Sheet name:
- Enter:
{"t":"all","i":1,"v":"doc","k":"name", "s": false} - Update:
luckysheetfile[1].["name"] = "doc"
- Enter:
-
Sheet color:
- Enter:
{"t":"all","i":2,"v":"#FFF000","k":"color", "s": false} - Update:
luckysheetfile[2].["color"] = "#FFF000"
- Enter:
-
Function chain operation
-
Format:
{ "t": "fc", "i": 0, "v": { "r": 3, "c": 7, "index": 0, "func": [ true, 187282, "=SUM(E4:G4)" ] }, "op": "add", "pos": 0 } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v Object value, the internal fields of the object do not need to be updated separately, so save as text op Operation type, addis add,updateis update, anddelis deletepos Updated or deleted function location -
Backend update:
calcChain is an array
- If the value of
opisaddthen add to the endluckysheetfile[i].calcChain.push (v), - If the value of
opisupdatethen updateluckysheetfile[i].calcChain[pos]= v, - If the value of
opisdelthen deleteluckysheetfile[i].calcChain.splice(pos, 1)。
- If the value of
-
Frontend view:
You can modify the value of any cell, and then go to the chrome console to view the operation of
"t"=="v".
Row and column operations
Delete rows or columns
-
Format:
{ "t": "drc", "i": 3, "v": { "index": 6, "len": 2 }, "rc": "r" } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet rc Row operation or column operation, the value `r` stands for row, and `c` stands for column v index Delete from which row or column len Number of rows or columns deleted -
Backend update:
If the value of
rcis'r'then delete the row, if the value ofrcis'c'then delete the column, egrc='r',index=4,len= 5, means to delete the next 5 lines (4, 5, 6, 7, 8) from the 4th line.Mainly operate on the cells in
luckysheetfile[i].celldata, delete the qualified cells described in the parameters and update the row and column values of other cells. Taking the above as an example, first find therin the cell Delete all the cells with values from 4 to 8, and then subtract the value of 5 from the original cell number 9 and later, and finally subtract 5 fromluckysheetfile[i].row. If thevvalue is"#__qkdelete#"(without quotes), then this is the cell to be deleted. -
Front view:
You can delete rows or columns, and then go to the chrome console to view the operation of
"t"=="drc".
Add rows or columns
-
Format:
{ "t": "arc", "i": 0, "v": { "index": 5, "len": 10, "data": [] }, "rc": "c" } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet rc Row operation or column operation, the value `r` stands for row, and `c` stands for column v index Start from which row or column len How many rows or columns to add data New row or column content -
Backend update:
If the value of
rcisr, add a new row. If the value ofrcisc, add a new column. For example,rc=r, index=4, len=5then it means increase 5 lines from line 4. Ifdatais empty, add an empty line. Ifdatais not empty, use the array indatato add a new line.Mainly operate on the cells in
luckysheetfile[i].celldata. Taking the above as an example, first add 5 toluckysheetfile[i].row, and then addrgreater than 4 to the entire cellrValue +5, ifdatais empty, add an empty line to end, ifdatais not empty, convert the two-dimensional arraydatato{r:0,c:0,v:100}Format and added tocelldata, the pseudo code for conversion is as follows:var ret = []; for(var r=0;r<data.length;r++){ for(var c=0;c<data[0].length;c++){ if(d[r][c]==null){ continue; } ret.push({r:r+5, c:c, v: data[r][c]}); } } return ret; -
Front view: You can add rows or columns, and then go to the chrome console to view the operation of
"t"=="arc". If you want to view the operation with the value ofdata, you can delete some rows or columns, and then undelete (Ctrl+Z), you can see.
Filter operating
Select filter condition
-
Format:
{ "t": "f", "i": 0, "v": "{\"caljs\":{},\"selected\":{\"Qingdao\":\"1\",\"Guangxi\":\"1\",\"Chongqing\":\"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 } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v Object value, the internal fields of the object do not need to be updated separately, so save as text op The operation type upOrAddis update, if it does not exist, it is added, anddelis deletepos Updated or deleted optionlocation -
Backend update:
Update
luckysheetfile[i].filter = {pos: v }, the value ofvis a string in JSON format.filteris a key-value pair,keyis the index value (in characters) of the option position, andvis a json string parameter.filterrepresents a set of filter conditions.
Clear filter
-
Format:
{ "t": "fsc", "i": 0, "v": null } -
Backend update:
Clear
luckysheetfile[i]. filter = null,luckysheetfile[i]. filter_select = null。
Restore filter
-
Format:
{ "t": "fsr", "i": 0, "v": { "filter": [], "filter_select": {} } } -
Backend update:
Clear
luckysheetfile[i]. filter = v.filter,luckysheetfile[i]. filter_select = v. filter_select。
Sheet operation
New sheet
-
Format:
{ "t": "sha", "i": null, "v": { "name": "Sheet4", "color": "", "status": "0", "order": 3, "index": 3, "data": [], "config": {}, "pivotTable": null, "isPivotTable": false } } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet v name The index value of the sheet jumped after hiding color Sheet color status Active state order Sheet order index Sheet Index celldata Cell dataset config Setting pivotTable Pivot table settings isPivotTable Whether the pivot table -
Backend update:
Add a line (a document) to the database.
Copy sheet
-
Format:
{ "t": "shc", "i": "New sheet location", "v": { "copyindex": "copyindex" } } -
Backend update:
Copy the sheet index value in the table, set it to
copyindexand add it to the database, set theindexof the new document to the value corresponding toi.
Delete sheet
-
Format:
{ "t": "shd", "i": null, "v": { "deleIndex": 0 } } -
Explanation:
Parameter Explanation t Operation type symbol v deleIndex The sheet index to be deleted -
Backend update:
Delete the sheet whose index is the value corresponding to
deleIndex.
Position
-
Format:
{ "t": "shr", "v": { "index": "positon" } } -
Explanation:
Parameter Explanation t Operation type symbol v Set the sorting of Sheet as a key-value pair, keyrepresents the index of the sheet, andvaluerepresents the order value. The format is:{"1": 3, "2":1, "0": 2, "3":0} -
Backend update:
For the page where the
indexof the sheet is equal to thekey, set itsorderattribute to thevalue. Examples:luckysheetfile[key1].order = value1luckysheetfile[key2].order = value2luckysheetfile[key3].order = value3
Sheet attributes (hide or show)
-
Format:
{ "t": "sh", "i": 0, "v": 1, "op": " hide", "cur": 2 } -
Explanation:
Parameter Explanation t Operation type symbol i The index value of the current sheet op Operation options include hide and show v Hide if hideis1, show if0or emptycur After hiding, set sheet which index corresponding to the curto the active state -
Backend update:
The
hidefield of the root path of the sheet corresponding toiis updated tov. When hidden, thestatusvalue is0. When displayed, it is1. If hidden, the sheet whichcurcorresponds toindex, itsstatusis updated to1.
Table information change
Table name
-
Format:
{ "t": "na", "i": null, "v": "Data" } -
Explanation:
Parameter Explanation t Operation type symbol v The name of the table -
Backend update:
Update the table name in the database according to gridkey.
Thumbnail
-
Format:
{ "t": "thumb", "img": "base64", "curindex": "curindx" } -
Explanation:
Parameter Explanation t Operation type symbol img Thumbnail of current table, base64 string curindex The current sheet opened by default -
Backend update:
According to gridkey, update the thumbnail field of the table in mysql to the img value, and update the status field of the sheet whose index is the curindex value to 1, and set the status value of other sheets to 0.