You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.8 KiB
152 lines
5.8 KiB
5 years ago
|
# API
|
||
|
|
||
|
::: danger
|
||
|
The new API is being sorted out, please use it with caution!
|
||
|
:::
|
||
5 years ago
|
|
||
5 years ago
|
## luckysheet.create(options)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Object} [options]:All configuration information of the table
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Initialize a luckysheet, which can contain multiple worksheets, refer to [Configuration List](https://mengshukeji.github.io/LuckysheetDocs/guide/config.html)
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.getcellvalue([r] [,c] [,data] [,type])
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Number} [r]:The row number of the cell; optional value; an integer starting from 0, 0 means the first row
|
||
|
- {Number} [c]:The column number of the cell; optional value; an integer starting from 0, 0 means the first column
|
||
|
- {Array} [data]:Table data, two-dimensional array; optional value; default value is the current table data
|
||
|
- {String} [type]:Cell attribute value; optional value; the default value is'v', which means to get the actual value of the cell
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
|
This method is to get the value of the cell.
|
||
|
1. `luckysheet.getcellvalue()`:Return all data in the current worksheet;
|
||
|
2. `luckysheet.getcellvalue(0)`:Return the first row data of the current worksheet;
|
||
|
3. `luckysheet.getcellvalue(null,0)`:Return the data in the first column of the current worksheet;
|
||
|
4. `luckysheet.getcellvalue(0,0)`:Return the v value of the data in the first row and first column of the current worksheet;
|
||
|
5. `luckysheet.getcellvalue(1,1,null,'m')`: Returns the original value of the cell in the second row and second column of the specified data.
|
||
|
|
||
|
Special case: the cell format is `yyyy-MM-dd`, when the type is'v', the display value of'm' will be mandatory
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.getluckysheetfile()
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Returns a one-dimensional array of all table data structures[luckysheetfile](https://mengshukeji.github.io/LuckysheetDocs/guide/data.html), `luckysheet.getluckysheetfile()[0]` can get all the information of the first worksheet.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.getconfig()
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Quickly return to the current sheet config configuration, the config information of each worksheet is still contained in the luckysheetfile.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.getluckysheet_select_save()
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Returns an array of current selection objects, there may be multiple selections.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.getdatabyselection([range] [,sheetIndex])
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Object} [range]:Selection object, `object: {row: [r1, r2], column: [c1, c2] }`; optional value; the default is the current first selection.
|
||
|
- {Number} [sheetIndex]:Table subscript, an integer starting from 0, 0 means the first table; optional value; the default is the current table subscript.
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Returns the data of the first selection in a table.
|
||
|
- `luckysheet.getdatabyselection()`: Returns the data of the current selection of the current worksheet
|
||
|
- `luckysheet.getdatabyselection(null,1)`: Returns the data of the current selection of the second worksheet
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.luckysheetrefreshgrid(scrollWidth, scrollHeight)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Number} [scrollWidth]:Horizontal scroll value. The default is the current horizontal scroll position.
|
||
|
- {Number} [scrollHeight]:Vertical scroll value. The default is the current vertical scroll position.
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Refresh the canvas display data according to scrollWidth and scrollHeight.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.setcellvalue(r, c, d, v)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Number} [r]:The row number of the cell; an integer starting from 0, 0 means the first row.
|
||
|
- {Number} [c]:The column number of the cell; an integer starting from 0, 0 means the first column.
|
||
|
- {Array} [d]:Table data; optional value; two-dimensional array.
|
||
|
- {Object | String | Number} [v]:The value to be set; it can be an object, and the object is to conform to the cell object format.
|
||
5 years ago
|
- **Usage**:
|
||
|
|
||
5 years ago
|
Set the value of a cell. Can be used with `luckysheet.luckysheetrefreshgrid()` to refresh and view cell value changes.
|
||
5 years ago
|
```js
|
||
5 years ago
|
luckysheet.setcellvalue(0, 0, luckysheet.flowdata(), 'abc');
|
||
|
luckysheet.jfrefreshgrid();
|
||
5 years ago
|
```
|
||
5 years ago
|
|
||
|
------------
|
||
|
## luckysheet.jfrefreshgrid()
|
||
|
- **Usage**:
|
||
|
|
||
|
Refresh canvas
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.setluckysheet_select_save(v)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Array} [v]:The selection value (array) to be set. Comply with selection format rules, such as `[{ row: [r1, r2], column: [c1, c2] }]`.
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Set the value of the current table selection area. With `luckysheet.selectHightlightShow()`, you can view the selection changes in the interface.
|
||
5 years ago
|
```js
|
||
5 years ago
|
luckysheet.setluckysheet_select_save([{ row: [0, 1], column: [0, 1] }]);
|
||
|
luckysheet.selectHightlightShow();
|
||
5 years ago
|
```
|
||
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.selectHightlightShow()
|
||
|
- **Usage**:
|
||
|
|
||
|
Highlight the current selection
|
||
|
|
||
|
------------
|
||
|
## luckysheet.setSheetHide(index)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Number} [index]:Table index; an integer starting from 0, 0 means the first table; the default is the current table index.
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Hide a table.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.setSheetShow(index)
|
||
5 years ago
|
- **Parameter**:
|
||
5 years ago
|
- {Number} [index]:Table index; an integer starting from 0, 0 means the first table; the default is the current table index.
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Display a table.
|
||
5 years ago
|
|
||
|
------------
|
||
5 years ago
|
## luckysheet.flowdata()
|
||
|
- **Usage**:
|
||
|
|
||
|
Quickly get the data of the current table
|
||
|
|
||
|
------------
|
||
|
## luckysheet.buildGridData(file)
|
||
|
- **Parameter**:
|
||
|
- {Object} [file]:[luckysheetfile](https://mengshukeji.github.io/LuckysheetDocs/zh/guide/data.html#%E8%8E%B7%E5%8F%96%E8%A1%A8%E6%A0%BC%E6%95%B0%E6%8D%AE)
|
||
|
- **Usage**:
|
||
|
|
||
|
Generate a two-dimensional array that the table can recognize
|
||
|
|
||
|
------------
|
||
|
## luckysheet.getGridData(data)
|
||
|
- **Parameter**:
|
||
|
- {Array} [data]:Two-dimensional array data of worksheet
|
||
|
- **Usage**:
|
||
|
|
||
|
Convert two-dimensional array data into `{r, c, v}` format one-dimensional array
|
||
|
|
||
|
------------
|
||
|
## luckysheet.destroy()
|
||
5 years ago
|
- **Usage**:
|
||
5 years ago
|
|
||
5 years ago
|
Delete and release table
|