From abd44e882e39bfb85c0e213e049325754bc3ba4f Mon Sep 17 00:00:00 2001 From: Dushusir <1414556676@qq.com> Date: Wed, 29 Jul 2020 21:15:20 +0800 Subject: [PATCH] fix(from github): github github --- docs/.vuepress/config.js | 14 +- docs/guide/FAQ.md | 24 + docs/guide/data.md | 2 +- docs/guide/feature.md | 138 +- docs/guide/format.md | 319 +- docs/zh/guide/FAQ.md | 24 + docs/zh/guide/data.md | 2 +- docs/zh/guide/feature.md | 129 +- docs/zh/guide/format.md | 320 +- src/controllers/conditionformat.js | 469 +- src/controllers/constant.js | 37 +- src/controllers/filter.js | 1512 +++- src/controllers/formulaBar.js | 293 + src/controllers/handler.js | 6904 +----------------- src/controllers/insertFormula.js | 23 +- src/controllers/keyboard.js | 917 +++ src/controllers/matrixOperation.js | 1241 ++++ src/controllers/menuButton.js | 502 +- src/controllers/orderBy.js | 273 + src/controllers/pivotTable.js | 2 +- src/controllers/rowColumnOperation.js | 1620 +++++ src/controllers/searchReplace.js | 6 +- src/controllers/select.js | 10 +- src/controllers/sheetBar.js | 454 ++ src/controllers/sheetmanage.js | 26 +- src/core.js | 78 +- src/demoData/sheetFormula.js | 2 +- src/function/functionImplementation.js | 2 +- src/function/functionlist.js | 9201 +++++++++++++++++++++++- src/global/count.js | 13 +- src/global/createdom.js | 19 +- src/global/draw.js | 3125 +++----- src/global/formula.js | 52 +- src/global/getdata.js | 6 +- src/global/method.js | 4 +- src/global/refresh.js | 10 +- src/global/setdata.js | 6 +- src/global/tooltip.js | 2 +- src/index.html | 2 +- src/locale/en.js | 192 +- src/locale/zh.js | 206 +- src/store/index.js | 5 +- 42 files changed, 18703 insertions(+), 9483 deletions(-) create mode 100644 docs/guide/FAQ.md create mode 100644 docs/zh/guide/FAQ.md create mode 100644 src/controllers/formulaBar.js create mode 100644 src/controllers/keyboard.js create mode 100644 src/controllers/matrixOperation.js create mode 100644 src/controllers/orderBy.js create mode 100644 src/controllers/rowColumnOperation.js create mode 100644 src/controllers/sheetBar.js diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 75e9f095b..65962bb95 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -40,8 +40,8 @@ module.exports = { } }, nav: [ - { text: 'Home', link: '/en/' }, - { text: 'Guide', link: '/en/guide/' }, + { text: 'Home', link: '/' }, + { text: 'Guide', link: '/guide/' }, { text: 'Demo', link: 'https://mengshukeji.github.io/LuckysheetDemo/' } ], // 侧边栏 @@ -52,7 +52,8 @@ module.exports = { 'feature', 'data', 'operate', - 'format' + 'format', + 'FAQ' ], }, }, @@ -74,8 +75,8 @@ module.exports = { }, // 导航栏 nav: [ - { text: '首页', link: '/' }, - { text: '指南', link: '/guide/' }, + { text: '首页', link: '/zh/' }, + { text: '指南', link: '/zh/guide/' }, { text: '演示', link: 'https://mengshukeji.github.io/LuckysheetDemo/' } ], // 侧边栏 @@ -86,7 +87,8 @@ module.exports = { 'feature', 'data', 'operate', - 'format' + 'format', + 'FAQ' ], }, }, diff --git a/docs/guide/FAQ.md b/docs/guide/FAQ.md new file mode 100644 index 000000000..eed5db56f --- /dev/null +++ b/docs/guide/FAQ.md @@ -0,0 +1,24 @@ +# FAQ + +## What is the difference between data and celldata in luckysheetfile? + +**A**: Use one-dimensional array format [celldata](https://mengshukeji.github.io/LuckysheetDocs/guide/data.html), after the initialization is completed, the data converted into a two-dimensional array format is used for storage and update, and celldata is no longer used. + +If you need to take out data as initial data, you need to execute `luckysheet.getGridData(data)` to convert it to celldata data. +Among them, the celldata in `{ r, c, v }` format is converted to a two-dimensional array using `luckysheet.buildGridData(luckysheetfile)`, and the input parameter is the table data object `luckysheetfile` + +Summarized as follows: +```js +// data => celldata two-dimensional array data is converted into {r, c, v} format one-dimensional array, the input parameter is two-dimensional data +luckysheet.getGridData(data) + +// celldata => data The two-dimensional array required to generate the table, the input parameter is the table data object file +luckysheet.buildGridData(luckysheetfile) +``` + +------------ +## What are the cell types? + +**A**: Refer to [Cell Format List](https://mengshukeji.github.io/LuckysheetDocs/guide/format.html), with examples of available cell formats + +------------ \ No newline at end of file diff --git a/docs/guide/data.md b/docs/guide/data.md index b936cfb00..fdd65c085 100644 --- a/docs/guide/data.md +++ b/docs/guide/data.md @@ -282,7 +282,7 @@ ## celldata - Type:Array - Default:[] - - Usage: The original cell data set is a set containing `{r:0,c:0,v:{m:"value",v:"value",ct: {fa: "General", t: "g"}} }`The one-dimensional array of format cell information is only used during initialization. After the table is initialized with celldata, the data is converted to the same level field data in the luckysheetfile, such as `luckysheetfile[0].data`, the subsequent operation of the table Data update will be updated to this data field, and celldata is no longer used. If you need to take out data as initial data, you need to execute `luckysheet.getGridData(data)` to convert it to celldata data. One-dimensional array of `rcv` is converted to two-dimensional array using `luckysheet.buildGridData(luckysheetfile)`, and the input parameter is the table data object `luckysheetfile`, example: + - Usage: The original cell data set is a set containing `{r:0,c:0,v:{m:"value",v:"value",ct: {fa: "General", t: "g"}} }`The one-dimensional array of format cell information is only used during initialization. After the table is initialized with celldata, the data is converted to the same level field data in the luckysheetfile, such as `luckysheetfile[0].data`, the subsequent operation of the table Data update will be updated to this data field, and celldata is no longer used. Example: ```js [{ "r": 0, diff --git a/docs/guide/feature.md b/docs/guide/feature.md index d3e90473b..9bb1a6549 100644 --- a/docs/guide/feature.md +++ b/docs/guide/feature.md @@ -1,125 +1,147 @@ # Advanced Features -## luckysheet.getcellvalue(r, c, data, type) +## luckysheet.create(options) - **Parameter**: - - r: the number of rows in which the cell is located; optional values; integers starting at 0, 0 representing the first row. - - c: the number of columns in which the cell is located; optional values; integers starting at 0, 0 indicating the first column. - - data: table data; two-dimensional array; the default value is the current table data. - - type: cell attribute value; optional value; the default value is'v', which means to get the cell value. + - {Object} [options]:All configuration information of the table - **Usage**: - This method is to get the cell value. When `r` and `c` have no value, return `data`; when `r`, `c` has only one value, return the entire row or column of data; + Initialize a luckysheet, which can contain multiple worksheets, refer to [Configuration List](https://mengshukeji.github.io/LuckysheetDocs/guide/config.html) ------------ -## luckysheet.getluckysheetfile() -- **Usage**: - - Return all table data structures. - ------------- -## luckysheet.sheetmanage.getSheetByIndex(index) -- **Parameter**: - - index: table subscript; integer starting from 0, 0 means the first table; default is the current table subscript. -- **Usage**: - - Returns a table data structure. - ------------- -## luckysheet.getconfig() -- **Usage**: - - Returns the current table configuration. - ------------- -## luckysheet.getSheetConfig(sheetIndex) +## luckysheet.getcellvalue([r] [,c] [,data] [,type]) - **Parameter**: - - sheetIndex: table index; an integer starting from 0, 0 means the first table; the default is the current table index. + - {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 - **Usage**: - - Return to a table configuration. + + 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 ------------ -## luckysheet.getvisibledatarow() +## luckysheet.getluckysheetfile() - **Usage**: - Returns the current table row height. + 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. ------------ -## luckysheet.getvisibledatacolumn() +## luckysheet.getconfig() - **Usage**: - Returns the current table column width. + Quickly return to the current sheet config configuration, the config information of each worksheet is still contained in the luckysheetfile. ------------ ## luckysheet.getluckysheet_select_save() - **Usage**: - Returns the current selection. + Returns an array of current selection objects, there may be multiple selections. ------------ -## luckysheet.getdatabyselection(range, sheetIndex) +## luckysheet.getdatabyselection([range] [,sheetIndex]) - **Parameter**: - - range: selection object; `object: {row: [r1, r2], column: [c1, c2] }`; the default is the current selection. - - sheetIndex: table index; an integer starting from 0, 0 means the first table; the default is the current table index. + - {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. - **Usage**: - Returns the cell data of a range in a table. + 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 ------------ ## luckysheet.luckysheetrefreshgrid(scrollWidth, scrollHeight) - **Parameter**: - - scrollWidth: horizontal scroll value. The default is the current horizontal scroll position. - - scrollHeight: vertical scroll value. The default is the current vertical scroll position. + - {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. - **Usage**: - Refresh canvas display data according to scrollWidth, scrollHeight. + Refresh the canvas display data according to scrollWidth and scrollHeight. ------------ ## luckysheet.setcellvalue(r, c, d, v) - **Parameter**: - - - r: the number of rows in which the cell is located; an integer starting from 0, 0 means the first row. - - c: the number of columns in which the cell is located; an integer starting from 0, 0 means the first column. - - d: table data; two-dimensional array. - - v: The value to be set; it can be an object, and the object should conform to the cell object format. + - {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. - **Usage**: - Set the value of a cell. Cooperate with `luckysheet.luckysheetrefreshgrid()` to refresh to see the cell value changes. + Set the value of a cell. Can be used with `luckysheet.luckysheetrefreshgrid()` to refresh and view cell value changes. ```js - luckysheet.setcellvalue(0, 0, luckysheet.flowdata, 'abc'); - luckysheet.luckysheetrefreshgrid(); + luckysheet.setcellvalue(0, 0, luckysheet.flowdata(), 'abc'); + luckysheet.jfrefreshgrid(); ``` + +------------ +## luckysheet.jfrefreshgrid() +- **Usage**: + + Refresh canvas ------------ ## luckysheet.setluckysheet_select_save(v) - **Parameter**: - - v: The selection value (array) to be set. It conforms to the selection format rules, such as `[{ row: [r1, r2], column: [c1, c2] }]`. + - {Array} [v]:The selection value (array) to be set. Comply with selection format rules, such as `[{ row: [r1, r2], column: [c1, c2] }]`. - **Usage**: - Set the value of the current table selection. With `luckysheet.selectHightlightShow()`, you can view the selection changes on the interface. + Set the value of the current table selection area. With `luckysheet.selectHightlightShow()`, you can view the selection changes in the interface. ```js luckysheet.setluckysheet_select_save([{ row: [0, 1], column: [0, 1] }]); luckysheet.selectHightlightShow(); ``` ------------ -## luckysheet.sheetmanage.setSheetHide(index) +## luckysheet.selectHightlightShow() +- **Usage**: + + Highlight the current selection + +------------ +## luckysheet.setSheetHide(index) - **Parameter**: - - index: table subscript; integer starting from 0, 0 means the first table; default is the current table subscript. + - {Number} [index]:Table index; an integer starting from 0, 0 means the first table; the default is the current table index. - **Usage**: Hide a table. ------------ -## luckysheet.sheetmanage.setSheetShow(index) +## luckysheet.setSheetShow(index) - **Parameter**: - - index: table subscript; integer starting from 0, 0 means the first table; default is the current table subscript. + - {Number} [index]:Table index; an integer starting from 0, 0 means the first table; the default is the current table index. - **Usage**: Display a table. ------------ -## luckysheet.method.destroy() +## 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() - **Usage**: - Release table + Delete and release table diff --git a/docs/guide/format.md b/docs/guide/format.md index 3c794dbd8..61d2425fa 100644 --- a/docs/guide/format.md +++ b/docs/guide/format.md @@ -64,13 +64,7 @@ cancelline Cancelline 0 Regular, 1 Cancelline - Style.Font object's Underline property - - - ul - underline - Underline - 0 Regular, 1 Underline + Style.Font object's Underline property vt @@ -100,13 +94,6 @@ 0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90 setRotationAngle - - fl - floatlenght - Decimal places - 3 - - tb textbeak @@ -115,15 +102,15 @@ 2: setTextWrapped
0和1: IsTextWrapped = true - ov - originvalue + v + value Original value - v - value + m + monitor Display value @@ -141,9 +128,33 @@ The following is the storage of 3 cells: ```json [ - {r:0, c:1, v: { v:"display", f:"=SUM(A2)", bg:"#fff000", bs:"1",bc:"#000"}}, - {r:10, c:11, v:"value2"}, - {r:10, c:11, v:{f:"=sum", v:"100"}} + { + "r": 10, + "c": 11, + "v": { + "f": "=MAX(A7:A9)", + "ct": { + "fa": "General", + "t": "n" + }, + "v": 100, + "m": "100" + } + }, + { + "r": 0, + "c": 1, + "v": { + "v": 12, + "f": "=SUM(A2)", + "bg": "#fff000" + } + }, + { + "r": 10, + "c": 11, + "v": "值2" + } ] ``` @@ -155,60 +166,226 @@ The format is set to: ```json { - "v": "", - "f": "", "ct": { - "v": 1, - "f": "#,##0.00", - "t": " Decimal" - } + "fa": "General", + "t": "g" + }, + "m": "2424", + "v": 2424 } ``` -|Parameter|Explanation|Usage| +|Parameter|Explanation|Value| | ------------ | ------------ | ------------ | -|v|value, shortcut setting value in Aspose|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Number = 8;`| -|f|Format: format definition string `$#,##0;$-#,##0`|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Custom  = "#,##0 SEK";`| -|t|Type:
0: General
1: Decimal
2: Currency
3: Percentage
4: Scientific
5: Fraction
6: Date
7: Time
8: Accounting
9: Text
10: DateTime|The type is the format distinguished by the front end. When importing excel, the type is distinguished according to the keyword of the format character:
1. YYYY, MM, DD is 6| +|fa|Format definition string| such as "General"| +|t|Type|Such as "g"| -Aspose is set as follows: -| Value | Type | Format String | -|-------|------------|---------------------------------------------| -| 0 | General | General | -| 1 | Decimal | 0 | -| 2 | Decimal | 0\.00 | -| 3 | Decimal | \#,\#\#0 | -| 4 | Decimal | \#,\#\#0\.00 | -| 5 | Currency | $\#,\#\#0;$\-\#,\#\#0 | -| 6 | Currency | $\#,\#\#0;$\-\#,\#\#0 | -| 7 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | -| 8 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | -| 9 | Percentage | 0% | -| 10 | Percentage | 0\.00% | -| 11 | Scientific | 0\.00E\+00 | -| 12 | Fraction | \# ?/? | -| 13 | Fraction | \# / | -| 14 | Date | m/d/yy | -| 15 | Date | d\-mmm\-yy | -| 16 | Date | d\-mmm | -| 17 | Date | mmm\-yy | -| 18 | Time | h:mm AM/PM | -| 19 | Time | h:mm:ss AM/PM | -| 20 | Time | h:mm | -| 21 | Time | h:mm:ss | -| 22 | Time | m/d/yy h:mm | -| 37 | Currency | \#,\#\#0;\-\#,\#\#0 | -| 38 | Currency | \#,\#\#0;\-\#,\#\#0 | -| 39 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | -| 40 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | -| 41 | Accounting | \_ \* \#,\#\#0\_ ;\_ \* "\_ ;\_ @\_ | -| 42 | Accounting | \_ $\* \#,\#\#0\_ ;\_ $\* "\_ ;\_ @\_ | -| 43 | Accounting | \_ \* \#,\#\#0\.00\_ ;\_ \* "??\_ ;\_ @\_ | -| 44 | Accounting | \_ $\* \#,\#\#0\.00\_ ;\_ $\* "??\_ ;\_ @\_ | -| 45 | Time | mm:ss | -| 46 | Time | h :mm:ss | -| 47 | Time | mm:ss\.0 | -| 48 | Scientific | \#\#0\.0E\+00 | -| 49 | Text | @ | +The available settings are as follows: +| Format | ct.fa | ct.t | Example of m value | Remarks | +|----------|----------|-------------------------|------------------------- |------------------------- | +| Automatic | General | g | Luckysheet || +| Plain text | @ | s | Luckysheet || +|


**Number Format** | | | | | +| Integer | 0 | n | 1235 | 0 decimal places | +| One decimal place of the number | 0.0 | n | 1234.6 | The number of 0 after the dot represents the number of decimal places. If the original number is large, the number of digits will be rounded to the nearest hour | +| Two decimal places | 0.00 | n | 1234.56 || +| Percentage integer | 0% | n | 123456% |The usage of #0% is also supported| +| Percentage | 0.00% | n | 123456.00% |The usage of #0.00% is also supported. The number of 0 after the dot represents the number of decimal places| +| Scientific Notation | 0.00E+00 | n | 1.23E+03 || +| Scientific Notation | ##0.0E+0 | n | 1.2E+3 || +| Fractions | # ?/? | n | 1234 5/9 || +| Score | # ??/?? | n | 1234 14/25 || +| Ten thousand | w | n |123 thousand and 456|| +| Ten thousand two decimal places | w0.00 | n |123 thousand and 3456.00 || +| Accounting | ¥(0.00) | n || +| More number formats | #,##0 | n | 1,235 || +| More number formats | #,##0.00 | n | 1,234.56 || +| More number formats | `#,##0_);(#,##0)` | n | 1,235 || +| More number formats | `#,##0_);[Red](#,##0)` | n | 1,235 || +| More number formats | `#,##0.00_);(#,##0.00)` | n | 1,234.56 || +| More number formats | `#,##0.00_);[Red](#,##0.00)` | n | 1,234.56 || +| More number formats | $#,##0_);($#,##0) | n | $1,235 || +| More number formats | `$#,##0_);[Red]($#,##0)` | n | $1,235 || +| More number formats | $#,##0.00_);($#,##0.00) | n | $1,234.56 || +| More number formats | `$#,##0.00_);[Red]($#,##0.00)` | n | $1,234.56 || +| More number formats | _($* #,##0_);_(...($* "-"_);_(@_) | n | $ 1,235 || +| More number formats | _(* #,##0_);_(*..._(* "-"_);_(@_) | n | 1,235 || +| More number formats | _($* #,##0.00_);_(...($* "-"_);_(@_) | n | $ 1,234.56 || +| More number formats | _(* #,##0.00_);...* "-"??_);_(@_) | n | 1,234.56 || +|


**Time and Date Format** | | | | | +| Time | hh:mm AM/PM | d |10:23 AM|| +| Time 24H | hh:mm | d |10:23|| +| Date Time | yyyy-MM-dd hh:mm AM/PM | d |2020-07-29 10:23 AM|| +| Date Time 24H | yyyy-MM-dd hh:mm | d |2020-07-29 10:23|| +| Date | yyyy-MM-dd | d | 1930-08-05 || +| Date | yyyy/MM/dd | d | 1930/8/5 || +| Date | yyyy "year" M" month "d" day" | d | August 5, 1930 || +| Date | MM-dd | d | 08-05 || +| Date | M-d | d | 8-5 || +| Date | M"Month"d"Day" | d | August 5th || +| Date | h:mm:ss | d | 13:30:30 || +| Date | h:mm | d | 13:30 || +| Date | AM/PM hh:mm | d | 01:30 PM || +| Date | AM/PM h:mm | d | 1:30 PM || +| Date | AM/PM h:mm:ss | d | 1:30:30 PM || +| Date | MM-dd AM/PM hh:mm | d | Next 08-05 01:30 PM || +|


**Currency Format** | | | | | +| Currency: RMB | "¥" 0.00 | n | ¥ 123.00 | Also supports ¥ #.00 or ¥0.00| +| Currency: US Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Euro | "€" 0.00 | n | € 123.00 || +| Currency: British Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Hong Kong Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Japanese Yen | "¥" 0.00 | n | ¥123.00 || +| Currency: Albanian Lek | "Lek" 0.00 | n | Lek 123.00 || +| Currency: Algerian Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Afghani | "Af" 0.00 | n | Af 123.00 || +| Currency: Argentine Peso | "$" 0.00 | n | $ 123.00 || +| Currency: United Arab Emirates Dirham | "dh" 0.00 | n | dh 123.00 || +| Currency: Aruban Florin | "Afl" 0.00 | n | Afl 123.00 || +| Currency: Omani Rial | "Rial" 0.00 | n | Rial 123.00 || +| Currency: Azerbaijani Manat | "?" 0.00 | n |? 123.00 || +| Currency: Egyptian Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Ethiopian Birr | "Birr" 0.00 | n | Birr 123.00 || +| Currency: Angolan Kwanza | "Kz" 0.00 | n | Kz 123.00 || +| Currency: Australian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Macau Patacas | "MOP" 0.00 | n | MOP 123.00 || +| Currency: Barbadian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Papua New Guinea Kina | "PGK" 0.00 | n | PGK 123.00 || +| Currency: Bahamian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Pakistani Rupee | "Rs" 0.00 | n | Rs 123.00 || +| Currency: Paraguayan Guarani | "Gs" 0.00 | n | Gs 123.00 || +| Currency: Bahraini Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Panamanian Balboa | "B/" 0.00 | n | B/ 123.00 || +| Currency: Brazilian Riyal | "R$" 0.00 | n | R$ 123.00 || +| Currency: Belarusian ruble | "р" 0.00 | n | р 123.00 || +| Currency: Bermudian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Bulgarian Lev | "lev" 0.00 | n | lev 123.00 || +| Currency: Iceland Krona | "kr" 0.00 | n | kr 123.00 || +| Currency: Bosnia and Herzegovina convertible mark | "KM" 0.00 | n | KM 123.00 || +| Currency: Polish Zloty | "z?" 0.00 | n | z? 123.00 || +| Currency: Boliviano | "Bs" 0.00 | n | Bs 123.00 || +| Currency: Belize Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Botswana Pula | "P" 0.00 | n | P 123.00 || +| Currency: Bhutan Nusam | "Nu" 0.00 | n | Nu 123.00 || +| Currency: Burundian Franc | "FBu" 0.00 | n | FBu 123.00 || +| Currency: North Korean Won | "?KP" 0.00 | n | ?KP 123.00 || +| Currency: Danish Krone | "kr" 0.00 | n | kr 123.00 || +| Currency: East Caribbean Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Dominican Peso | "RD$" 0.00 | n | RD$ 123.00 || +| Currency: Russian ruble | "?" 0.00 | n |? 123.00 || +| Currency: Eritrean Nakfa | "Nfk" 0.00 | n | Nfk 123.00 || +| Currency: CFA franc | "CFA" 0.00 | n | CFA 123.00 || +| Currency: Philippine Peso | "?" 0.00 | n |? 123.00 || +| Currency: Fijian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Cape Verde Escudo | "CVE" 0.00 | n | CVE 123.00 || +| Currency: Falkland Islands Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Gambia Dalasi | "GMD" 0.00 | n | GMD 123.00 || +| Currency: Congolese Franc | "FrCD" 0.00 | n | FrCD 123.00 || +| Currency: Colombian Peso | "$" 0.00 | n | $ 123.00 || +| Currency: Costa Rican Colon | "?" 0.00 | n |? 123.00 || +| Currency: Cuban Peso | "$" 0.00 | n | $ 123.00 || +| Currency: Cuban Convertible Peso | "$" 0.00 | n | $ 123.00 || +| Currency: Guyana Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Kazakhstan tenge | "?" 0.00 | n |? 123.00 || +| Currency: Haitian Gourde | "HTG" 0.00 | n | HTG 123.00 || +| Currency: Korean Won | "?" 0.00 | n |? 123.00 || +| Currency: Netherlands Antilles Guild | "NAf." 0.00 | n | NAf. 123.00 || +| Currency: Honduras Lalempira | "L" 0.00 | n | L 123.00 || +| Currency: Djiboutian Franc | "Fdj" 0.00 | n | Fdj 123.00 || +| Currency: Kyrgyzstan Som | "KGS" 0.00 | n | KGS 123.00 || +| Currency: Guinean Franc | "FG" 0.00 | n | FG 123.00 || +| Currency: Canadian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Ghanaian Cedi | "GHS" 0.00 | n | GHS 123.00 || +| Currency: Cambodian Riel | "Riel" 0.00 | n | Riel 123.00 || +| Currency: Czech Koruna | "K?" 0.00 | n | K? 123.00 || +| Currency: Zimbabwe dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Qatari Rial | "Rial" 0.00 | n | Rial 123.00 || +| Currency: Cayman Islands Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Comorian Franc | "CF" 0.00 | n | CF 123.00 || +| Currency: Kuwaiti Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Croatian Kuna | "kn" 0.00 | n | kn 123.00 || +| Currency: Kenyan Shilling | "Ksh" 0.00 | n | Ksh 123.00 || +| Currency: Lesotho Loti | "LSL" 0.00 | n | LSL 123.00 || +| Currency: Lao Kip | "?" 0.00 | n |? 123.00 || +| Currency: Lebanese Pound | "L£" 0.00 | n | L£ 123.00 || +| Currency: Lithuanian Litas | "Lt" 0.00 | n | Lt 123.00 || +| Currency: Libyan Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Libyan Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Rwandan franc | "RF" 0.00 | n | RF 123.00 || +| Currency: Romanian Lei | "RON" 0.00 | n | RON 123.00 || +| Currency: Madagascar Ariary | "Ar" 0.00 | n | Ar 123.00 || +| Currency: Maldivian Rufiyaa | "Rf" 0.00 | n | Rf 123.00 || +| Currency: Malawian Kwacha | "MWK" 0.00 | n | MWK 123.00 || +| Currency: Malaysian Ringgit | "RM" 0.00 | n | RM 123.00 || +| Currency: Macedonian Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Mauritian Rupee | "MURs" 0.00 | n | MURs 123.00 || +| Currency: Mauritania Ouguiya | "MRO" 0.00 | n | MRO 123.00 || +| Currency: Mongolian Tugrik | "?" 0.00 | n |? 123.00 || +| Currency: Bangladeshi Taka | "?" 0.00 | n |? 123.00 || +| Currency: Peruvian New Sol | "S/" 0.00 | n | S/ 123.00 || +| Currency: Myanmar Kyat | "K" 0.00 | n | K 123.00 || +| Currency: Moldovan Lei | "MDL" 0.00 | n | MDL 123.00 || +| Currency: Moroccan Dirham | "dh" 0.00 | n | dh 123.00 || +| Currency: Mozambique Metical | "MTn" 0.00 | n | MTn 123.00 || +| Currency: Mexican Peso | "$" 0.00 | n | $ 123.00 || +| Currency: Namibian Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: South African Rand | "R" 0.00 | n | R 123.00 || +| Currency: South Sudanese Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Nicaragua Cordoba | "C$" 0.00 | n | C$ 123.00 || +| Currency: Nepalese Rupee | "Rs" 0.00 | n | Rs 123.00 || +| Currency: Nigerian Naira | "?" 0.00 | n |? 123.00 || +| Currency: Norwegian Krone | "kr" 0.00 | n | kr 123.00 || +| Currency: Georgia Lari | "GEL" 0.00 | n | GEL 123.00 || +| Currency: RMB (Offshore) | "¥" 0.00 | n | ¥123.00 || +| Currency: Swedish Krona | "kr" 0.00 | n | kr 123.00 || +| Currency: Swiss Franc | "CHF" 0.00 | n | CHF 123.00 || +| Currency: Serbian Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Sierra Leone Leone | "SLL" 0.00 | n | SLL 123.00 || +| Currency: Seychelles Rupee | "SCR" 0.00 | n | SCR 123.00 || +| Currency: Saudi Riyal | "Rial" 0.00 | n | Rial 123.00 || +| Currency: Sao Tome Dobra | "Db" 0.00 | n | Db 123.00 || +| Currency: St. Helena Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Sri Lankan Rupee | "Rs" 0.00 | n | Rs 123.00 || +| Currency: Swaziland Lilangeni | "SZL" 0.00 | n | SZL 123.00 || +| Currency: Sudanese Pound | "SDG" 0.00 | n | SDG 123.00 || +| Currency: Surinamese Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Solomon Islands Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Somali Shilling | "SOS" 0.00 | n | SOS 123.00 || +| Currency: Tajikistani Somoni | "Som" 0.00 | n | Som 123.00 || +| Currency: Pacific Franc | "FCFP" 0.00 | n | FCFP 123.00 || +| Currency: Thai Baht | "?" 0.00 | n |? 123.00 || +| Currency: Tanzanian Shilling | "TSh" 0.00 | n | TSh 123.00 || +| Currency: Tongan Paanga | "T$" 0.00 | n | T$ 123.00 || +| Currency: Trinidad and Tobago Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Tunisian Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Turkish Lira | "?" 0.00 | n |? 123.00 || +| Currency: Vanuatu Vatu | "VUV" 0.00 | n | VUV 123.00 || +| Currency: Guatemalan Quetzal | "Q" 0.00 | n | Q 123.00 || +| Currency: Venezuelan Bolivar | "Bs" 0.00 | n | Bs 123.00 || +| Currency: Brunei Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Ugandan Shilling | "UGX" 0.00 | n | UGX 123.00 || +| Currency: Ukrainian Hryvnia | "грн." 0.00 | n | грн. 123.00 || +| Currency: Uruguayan Peso | "$" 0.00 | n | $ 123.00 || +| Currency: Uzbekistani Sum | "so?m" 0.00 | n | so?m 123.00 || +| Currency: Western Samoa Tala | "WST" 0.00 | n | WST 123.00 || +| Currency: Singapore Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: New Taiwan Dollar | "NT$" 0.00 | n | NT$ 123.00 || +| Currency: New Zealand Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Hungarian Forint | "Ft" 0.00 | n | Ft 123.00 || +| Currency: Syrian Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Jamaican Dollar | "$" 0.00 | n | $ 123.00 || +| Currency: Armenian Dram | "Dram" 0.00 | n | Dram 123.00 || +| Currency: Yemeni Rial | "Rial" 0.00 | n | Rial 123.00 || +| Currency: Iraqi Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Iranian Rial | "Rial" 0.00 | n | Rial 123.00 || +| Currency: Israeli New Shekel | "?" 0.00 | n |? 123.00 || +| Currency: Indian Rupee | "?" 0.00 | n |? 123.00 || +| Currency: Indonesian Rupiah | "Rp" 0.00 | n | Rp 123.00 || +| Currency: Jordanian Dinar | "din" 0.00 | n | din 123.00 || +| Currency: Vietnamese Dong | "?" 0.00 | n |? 123.00 || +| Currency: Zambian Kwacha | "ZMW" 0.00 | n | ZMW 123.00 || +| Currency: Gibraltar Pound | "£" 0.00 | n | £ 123.00 || +| Currency: Chilean Peso | "$" 0.00 | n | $ 123.00 || +| Currency: China-Africa Financial Cooperation Franc | "FCFA" 0.00 | n | FCFA 123.00 || -Import/export only considers the data style that the user sees. For example, the way to process the date format in excel is to convert the date into a number: 42736 represents 2017-1-1. \ No newline at end of file +Notice: Import/export only considers the data style that the user sees. For example, the way to process the date format in excel is to convert the date into a number: 42736 represents 2017-1-1. \ No newline at end of file diff --git a/docs/zh/guide/FAQ.md b/docs/zh/guide/FAQ.md new file mode 100644 index 000000000..37f876778 --- /dev/null +++ b/docs/zh/guide/FAQ.md @@ -0,0 +1,24 @@ +# FAQ + +## luckysheetfile中的data和celldata有什么区别? + +**A** : 表格初始化时使用一维数组格式的 [celldata](https://mengshukeji.github.io/LuckysheetDocs/zh/guide/data.html#celldata),初始化完成后转化为二维数组格式的data作为存储更新使用,celldata不再使用。 + +如果需要将data拿出来作为初始化数据,则需要执行 `luckysheet.getGridData(data)`转换为celldata数据。 +其中`{ r, c, v }`格式的celldata转换为二维数组使用的是`luckysheet.buildGridData(luckysheetfile)`,传入参数为表格数据对象`luckysheetfile` + +总结如下: +```js +// data => celldata 二维数组数据 转化成 {r, c, v}格式 一维数组,传入参数为二维数据data +luckysheet.getGridData(data) + +// celldata => data 生成表格所需二维数组,传入参数为表格数据对象file +luckysheet.buildGridData(luckysheetfile) +``` + +------------ +## 单元格的类型有哪些? + +**A** : 参考[单元格格式列表](https://mengshukeji.github.io/LuckysheetDocs/zh/guide/format.html#%E5%8D%95%E5%85%83%E6%A0%BC%E6%A0%BC%E5%BC%8F),例举了可用的单元格格式 + +------------ \ No newline at end of file diff --git a/docs/zh/guide/data.md b/docs/zh/guide/data.md index 58ed98d9c..bdebe7589 100644 --- a/docs/zh/guide/data.md +++ b/docs/zh/guide/data.md @@ -282,7 +282,7 @@ ## celldata - 类型:Array - 默认值:[] - - 作用: 原始单元格数据集,是一个包含`{r:0,c:0,v:{m:"value",v:"value",ct: {fa: "General", t: "g"}}}`格式单元格信息的一维数组,只在初始化的时候使用,使用celldata初始化完表格后,数据转换为luckysheetfile中的同级字段data,如`luckysheetfile[0].data`,后续操作表格的数据更新,会更新到这个data字段中,celldata不再使用。如果需要将data拿出来作为初始化数据,则需要执行 `luckysheet.getGridData(data)`转换为celldata数据。其中`rcv`一维数组转换为二维数组使用的是`luckysheet.buildGridData(luckysheetfile)`,传入参数为表格数据对象`luckysheetfile`,示例: + - 作用: 原始单元格数据集,是一个包含`{r:0,c:0,v:{m:"value",v:"value",ct: {fa: "General", t: "g"}}}`格式单元格信息的一维数组,只在初始化的时候使用,使用celldata初始化完表格后,数据转换为luckysheetfile中的同级字段data,如`luckysheetfile[0].data`,后续操作表格的数据更新,会更新到这个data字段中,celldata不再使用。示例: ```js [{ "r": 0, diff --git a/docs/zh/guide/feature.md b/docs/zh/guide/feature.md index e25ba634b..14085f252 100644 --- a/docs/zh/guide/feature.md +++ b/docs/zh/guide/feature.md @@ -1,75 +1,64 @@ # 高级功能 -## luckysheet.getcellvalue(r, c, data, type) +## luckysheet.create(options) - **参数**: - - r:单元格所在行数;可选值;从0开始的整数,0表示第一行。 - - c:单元格所在列数;可选值;从0开始的整数,0表示第一列。 - - data:表数据;二维数组;默认值为当前表格数据。 - - type:单元格属性值;可选值;默认值为'v',表示获取单元格的值。 + - {Object} [options]:表格的所有配置信息 - **用法**: - 此方法为获取单元格的值。`r`, `c`都没有值时,返回`data`;`r`, `c`只有一个有值时,返回整行或整列数据; + 初始化一个luckysheet,可包含多个工作表,参考 [配置列表](https://mengshukeji.github.io/LuckysheetDocs/zh/guide/config.html#container) ------------ -## luckysheet.getluckysheetfile() -- **用法**: - - 返回所有表格数据结构。 - ------------- -## luckysheet.sheetmanage.getSheetByIndex(index) -- **参数**: - - index:表格下标;从0开始的整数,0表示第一个表格;默认为当前表格下标。 -- **用法**: - - 返回某个表格数据结构。 - ------------- -## luckysheet.getconfig() -- **用法**: - - 返回当前表格config配置。 - ------------- -## luckysheet.getSheetConfig(sheetIndex) +## luckysheet.getcellvalue([r] [,c] [,data] [,type]) - **参数**: - - sheetIndex:表格下标;从0开始的整数,0表示第一个表格;默认为当前表格下标。 + - {Number} [r]:单元格所在行数;可选值;从0开始的整数,0表示第一行 + - {Number} [c]:单元格所在列数;可选值;从0开始的整数,0表示第一列 + - {Array} [data]:表数据,二维数组;可选值;默认值为当前表格数据 + - {String} [type]:单元格属性值;可选值;默认值为'v',表示获取单元格的实际值 - **用法**: + + 此方法为获取单元格的值。 + - `luckysheet.getcellvalue()`:返回当前工作表的所有数据; + - `luckysheet.getcellvalue(0)`:返回当前工作表第1行数据; + - `luckysheet.getcellvalue(null,0)`:返回当前工作表第1列数据; + - `luckysheet.getcellvalue(0,0)`:返回当前工作表第1行第1列单元格的数据的v值; + - `luckysheet.getcellvalue(1,1,null,'m')`: 返回指定data数据的第2行第2列单元格的原始值。 - 返回某个表格config配置。 + 特殊情况:单元格格式为`yyyy-MM-dd`,type为'v'时会强制取'm'显示值 ------------ -## luckysheet.getvisibledatarow() +## luckysheet.getluckysheetfile() - **用法**: - 返回当前表格行高。 + 返回所有表格数据结构的一维数组 [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),`luckysheet.getluckysheetfile()[0]`可取得第一个工作表的所有信息。 ------------ -## luckysheet.getvisibledatacolumn() +## luckysheet.getconfig() - **用法**: - 返回当前表格列宽。 + 快捷返回当前表格config配置,每个工作表的config信息仍然包含在luckysheetfile。 ------------ ## luckysheet.getluckysheet_select_save() - **用法**: - 返回当前选区。 + 返回当前选区对象的数组,可能存在多个选区。 ------------ -## luckysheet.getdatabyselection(range, sheetIndex) +## luckysheet.getdatabyselection([range] [,sheetIndex]) - **参数**: - - range:选区对象;`object: { row: [r1, r2], column: [c1, c2] }`;默认为当前选区。 - - sheetIndex:表格下标;从0开始的整数,0表示第一个表格;默认为当前表格下标。 + - {Object} [range]:选区对象,`object: { row: [r1, r2], column: [c1, c2] }`;可选值;默认为当前第一个选区。 + - {Number} [sheetIndex]:表格下标,从0开始的整数,0表示第一个表格;可选值;默认为当前表格下标。 - **用法**: - 返回某个表格某个区域单元格数据。 + 返回某个表格第一个选区的数据。 + - `luckysheet.getdatabyselection()`: 返回当前工作表当前选区的数据 + - `luckysheet.getdatabyselection(null,1)`: 返回第2个工作表的当前选区的数据 ------------ ## luckysheet.luckysheetrefreshgrid(scrollWidth, scrollHeight) - **参数**: - - scrollWidth:横向滚动值。默认为当前横向滚动位置。 - - scrollHeight:纵向滚动值。默认为当前纵向滚动位置。 + - {Number} [scrollWidth]:横向滚动值。默认为当前横向滚动位置。 + - {Number} [scrollHeight]:纵向滚动值。默认为当前纵向滚动位置。 - **用法**: 按照scrollWidth, scrollHeight刷新canvas展示数据。 @@ -77,22 +66,28 @@ ------------ ## luckysheet.setcellvalue(r, c, d, v) - **参数**: - - r:单元格所在行数;从0开始的整数,0表示第一行。 - - c:单元格所在列数;从0开始的整数,0表示第一列。 - - d:表数据;二维数组。 - - v:要设置的值;可为对象,对象是是要符合单元格对象格式。 + - {Number} [r]:单元格所在行数;从0开始的整数,0表示第一行。 + - {Number} [c]:单元格所在列数;从0开始的整数,0表示第一列。 + - {Array} [d]:表数据;可选值;二维数组。 + - {Object | String | Number} [v]:要设置的值;可为对象,对象是是要符合单元格对象格式。 - **用法**: 设置某个单元格的值。可配合`luckysheet.luckysheetrefreshgrid()`刷新查看单元格值改变。 ```js - luckysheet.setcellvalue(0, 0, luckysheet.flowdata, 'abc'); - luckysheet.luckysheetrefreshgrid(); + luckysheet.setcellvalue(0, 0, luckysheet.flowdata(), 'abc'); + luckysheet.jfrefreshgrid(); ``` +------------ +## luckysheet.jfrefreshgrid() +- **用法**: + + 刷新canvas + ------------ ## luckysheet.setluckysheet_select_save(v) - **参数**: - - v:要设置的选区值(数组)。符合选区格式规则,如`[{ row: [r1, r2], column: [c1, c2] }]`。 + - {Array} [v]:要设置的选区值(数组)。符合选区格式规则,如`[{ row: [r1, r2], column: [c1, c2] }]`。 - **用法**: 设置当前表格选区的值。配合`luckysheet.selectHightlightShow()`可在界面查看选区改变。 @@ -102,23 +97,51 @@ ``` ------------ -## luckysheet.sheetmanage.setSheetHide(index) +## luckysheet.selectHightlightShow() +- **用法**: + + 高亮当前选区 + +------------ +## luckysheet.setSheetHide(index) - **参数**: - - index:表格下标;从0开始的整数,0表示第一个表格;默认为当前表格下标。 + - {Number} [index]:表格索引;从0开始的整数,0表示第一个表格;默认为当前表格索引。 - **用法**: 隐藏某个表格。 ------------ -## luckysheet.sheetmanage.setSheetShow(index) +## luckysheet.setSheetShow(index) - **参数**: - - index:表格下标;从0开始的整数,0表示第一个表格;默认为当前表格下标。 + - {Number} [index]:表格索引;从0开始的整数,0表示第一个表格;默认为当前表格索引。 - **用法**: 显示某个表格。 ------------ -## luckysheet.method.destroy() +## luckysheet.flowdata() +- **用法**: + + 快捷获取当前表格的数据 + +------------ +## luckysheet.buildGridData(file) +- **参数**: + - {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) +- **用法**: + + 生成表格可以识别的二维数组 + +------------ +## luckysheet.getGridData(data) +- **参数**: + - {Array} [data]:工作表的二维数组数据 +- **用法**: + + 二维数组数据转化成 `{r, c, v}` 格式 一维数组 + +------------ +## luckysheet.destroy() - **用法**: - 释放表格 + 删除并释放表格 diff --git a/docs/zh/guide/format.md b/docs/zh/guide/format.md index 64fb6c456..806990985 100644 --- a/docs/zh/guide/format.md +++ b/docs/zh/guide/format.md @@ -64,13 +64,7 @@ cancelline 删除线 0 常规 、 1 删除线 - Style.Font object's Underline property - - - ul - underline - 下划线 - 0 常规 、 1 下划线 + Style.Font object's Underline property vt @@ -100,13 +94,6 @@ 0: 0、1: 45 、2:-45、3 竖排文字、4: 90 、5:-90 setRotationAngle - - fl - floatlenght - 小数位数 - 3 - - tb textbeak @@ -115,15 +102,15 @@ 2:setTextWrapped
0和1:IsTextWrapped = true - ov - originvalue + v + value 原始值 - v - value + m + monitor 显示值 @@ -141,9 +128,33 @@ 以下为3个单元格存储: ```json [ - {r:0, c:1, v: { v:"显示", f:"=SUM(A2)", bg:"#fff000", bs:"1",bc:"#000"}}, - {r:10, c:11, v:"值2"}, - {r:10, c:11, v:{f:"=sum", v:"100"}} + { + "r": 10, + "c": 11, + "v": { + "f": "=MAX(A7:A9)", + "ct": { + "fa": "General", + "t": "n" + }, + "v": 100, + "m": "100" + } + }, + { + "r": 0, + "c": 1, + "v": { + "v": 12, + "f": "=SUM(A2)", + "bg": "#fff000" + } + }, + { + "r": 10, + "c": 11, + "v": "值2" + } ] ``` @@ -155,60 +166,227 @@ ```json { - "v": "", - "f": "", "ct": { - "v": 1, - "f": "#,##0.00", - "t": " Decimal" - } + "fa": "General", + "t": "g" + }, + "m": "2424", + "v": 2424 } ``` -|参数|说明|使用| +|参数|说明|值| | ------------ | ------------ | ------------ | -|v|value,Aspose中的快捷设置值|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Number = 8;`| -|f|Format:格式的定义串 `$#,##0;$-#,##0`|`var currencyStyle = book.CreateStyle();`
`currencyStyle.Custom  = "#,##0 SEK";`| -|t|Type类型:
0:General
1:Decimal
2:Currency
3:Percentage
4:Scientific
5:Fraction
6:Date
7:Time
8:Accounting
9:Text
10:DateTime|类型是前端区分的格式,excel导入时根据导入format字符的关键字来区分是哪种类型:
1.含YYYY、MM、DD的是6| +|fa|Format格式的定义串| 如"General"| +|t|Type类型|如"g"| + +可选择的设置如下: +| 格式 | ct.fa | ct.t | m 值示例 |备注 | +|----------|----------|-------------------------|------------------------- |------------------------- | +| 自动 | General | g | Luckysheet || +| 纯文本 | @ | s | Luckysheet || +|


**数字格式** | | | | | +| 整数 | 0 | n | 1235 | 0位小数 || +| 数字一位小数 | 0.0 | n | 1234.6 | 点后面0的个数就代表小数位数,如果原始数字位数大,设置位数小时会做四舍五入 | +| 数字两位小数 | 0.00 | n | 1234.56 || +| 百分比整数 | 0% | n | 123456% |也支持 #0% 的用法| +| 百分比 | 0.00% | n | 123456.00% |也支持 #0.00% 的用法,点后面0的个数就代表小数位数| +| 科学计数 | 0.00E+00 | n | 1.23E+03 || +| 科学计数 | ##0.0E+0 | n | 1.2E+3 || +| 分数 | # ?/? | n | 1234 5/9 || +| 分数 | # ??/?? | n | 1234 14/25 || +| 万元 | w | n |12万3456|| +| 万元2位小数 | w0.00 | n |12万3456.00|| +| 会计 | ¥(0.00) | n || +| 更多数字格式 | #,##0 | n | 1,235 || +| 更多数字格式 | #,##0.00 | n | 1,234.56 || +| 更多数字格式 | `#,##0_);(#,##0)` | n | 1,235 || +| 更多数字格式 | `#,##0_);[Red](#,##0)` | n | 1,235 || +| 更多数字格式 | `#,##0.00_);(#,##0.00)` | n | 1,234.56 || +| 更多数字格式 | `#,##0.00_);[Red](#,##0.00)` | n | 1,234.56 || +| 更多数字格式 | $#,##0_);($#,##0) | n | $1,235 || +| 更多数字格式 | `$#,##0_);[Red]($#,##0)` | n | $1,235 || +| 更多数字格式 | $#,##0.00_);($#,##0.00) | n | $1,234.56 || +| 更多数字格式 | `$#,##0.00_);[Red]($#,##0.00)` | n | $1,234.56 || +| 更多数字格式 | _($* #,##0_);_(...($* "-"_);_(@_) | n | $ 1,235 || +| 更多数字格式 | _(* #,##0_);_(*..._(* "-"_);_(@_) | n | 1,235 || +| 更多数字格式 | _($* #,##0.00_);_(...($* "-"_);_(@_) | n | $ 1,234.56 || +| 更多数字格式 | _(* #,##0.00_);...* "-"??_);_(@_) | n | 1,234.56 || +|


**时间日期格式** | | | | | +| 时间 | hh:mm AM/PM | d |10:23 AM|| +| 时间24H | hh:mm | d |10:23|| +| 日期时间 | yyyy-MM-dd hh:mm AM/PM | d |2020-07-29 10:23 AM|| +| 日期时间24H | yyyy-MM-dd hh:mm | d |2020-07-29 10:23|| +| 日期 | yyyy-MM-dd | d | 1930-08-05 || +| 日期 | yyyy/MM/dd | d | 1930/8/5 || +| 日期 | yyyy"年"M"月"d"日" | d | 1930年8月5日 || +| 日期 | MM-dd | d | 08-05 || +| 日期 | M-d | d | 8-5 || +| 日期 | M"月"d"日" | d | 8月5日 || +| 日期 | h:mm:ss | d | 13:30:30 || +| 日期 | h:mm | d | 13:30 || +| 日期 | AM/PM hh:mm | d | 下午01:30 || +| 日期 | AM/PM h:mm | d | 下午1:30 || +| 日期 | AM/PM h:mm:ss | d | 下午1:30:30 || +| 日期 | MM-dd AM/PM hh:mm | d | 下08-05 下午01:30 || +|


**货币格式** | | | | | +| 货币:人民币 | "¥" 0.00 | n | ¥ 123.00 |也支持 ¥ #.00 或者 ¥0.00| +| 货币:美元 | "$" 0.00 | n | $ 123.00 || +| 货币:欧元 | "€" 0.00 | n | € 123.00 || +| 货币:英镑 | "£" 0.00 | n | £ 123.00 || +| 货币:港元 | "$" 0.00 | n | $ 123.00 || +| 货币:日元 | "¥" 0.00 | n | ¥ 123.00 || +| 货币:阿尔巴尼亚列克 | "Lek" 0.00 | n | Lek 123.00 || +| 货币:阿尔及利亚第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:阿富汗尼 | "Af" 0.00 | n | Af 123.00 || +| 货币:阿根廷比索 | "$" 0.00 | n | $ 123.00 || +| 货币:阿拉伯联合酋长国迪拉姆 | "dh" 0.00 | n | dh 123.00 || +| 货币:阿鲁巴弗罗林 | "Afl" 0.00 | n | Afl 123.00 || +| 货币:阿曼里亚尔 | "Rial" 0.00 | n | Rial 123.00 || +| 货币:阿塞拜疆马纳特 | "?" 0.00 | n | ? 123.00 || +| 货币:埃及镑 | "£" 0.00 | n | £ 123.00 || +| 货币:埃塞俄比亚比尔 | "Birr" 0.00 | n | Birr 123.00 || +| 货币:安哥拉宽扎 | "Kz" 0.00 | n | Kz 123.00 || +| 货币:澳大利亚元 | "$" 0.00 | n | $ 123.00 || +| 货币:澳门元 | "MOP" 0.00 | n | MOP 123.00 || +| 货币:巴巴多斯元 | "$" 0.00 | n | $ 123.00 || +| 货币:巴布亚新几内亚基那 | "PGK" 0.00 | n | PGK 123.00 || +| 货币:巴哈马元 | "$" 0.00 | n | $ 123.00 || +| 货币:巴基斯坦卢比 | "Rs" 0.00 | n | Rs 123.00 || +| 货币:巴拉圭瓜拉尼 | "Gs" 0.00 | n | Gs 123.00 || +| 货币:巴林第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:巴拿马巴波亚 | "B/" 0.00 | n | B/ 123.00 || +| 货币:巴西里亚伊 | "R$" 0.00 | n | R$ 123.00 || +| 货币:白俄罗斯卢布 | "р" 0.00 | n | р 123.00 || +| 货币:百慕大元 | "$" 0.00 | n | $ 123.00 || +| 货币:保加利亚列弗 | "lev" 0.00 | n | lev 123.00 || +| 货币:冰岛克朗 | "kr" 0.00 | n | kr 123.00 || +| 货币:波黑可兑换马克 | "KM" 0.00 | n | KM 123.00 || +| 货币:波兰兹罗提 | "z?" 0.00 | n | z? 123.00 || +| 货币:玻利维亚诺 | "Bs" 0.00 | n | Bs 123.00 || +| 货币:伯利兹元 | "$" 0.00 | n | $ 123.00 || +| 货币:博茨瓦纳普拉 | "P" 0.00 | n | P 123.00 || +| 货币:不丹努扎姆 | "Nu" 0.00 | n | Nu 123.00 || +| 货币:布隆迪法郎 | "FBu" 0.00 | n | FBu 123.00 || +| 货币:朝鲜圆 | "?KP" 0.00 | n | ?KP 123.00 || +| 货币:丹麦克朗 | "kr" 0.00 | n | kr 123.00 || +| 货币:东加勒比元 | "$" 0.00 | n | $ 123.00 || +| 货币:多米尼加比索 | "RD$" 0.00 | n | RD$ 123.00 || +| 货币:俄国卢布 | "?" 0.00 | n | ? 123.00 || +| 货币:厄立特里亚纳克法 | "Nfk" 0.00 | n | Nfk 123.00 || +| 货币:非洲金融共同体法郎 | "CFA" 0.00 | n | CFA 123.00 || +| 货币:菲律宾比索 | "?" 0.00 | n | ? 123.00 || +| 货币:斐济元 | "$" 0.00 | n | $ 123.00 || +| 货币:佛得角埃斯库多 | "CVE" 0.00 | n | CVE 123.00 || +| 货币:福克兰群岛镑 | "£" 0.00 | n | £ 123.00 || +| 货币:冈比亚达拉西 | "GMD" 0.00 | n | GMD 123.00 || +| 货币:刚果法郎 | "FrCD" 0.00 | n | FrCD 123.00 || +| 货币:哥伦比亚比索 | "$" 0.00 | n | $ 123.00 || +| 货币:哥斯达黎加科朗 | "?" 0.00 | n | ? 123.00 || +| 货币:古巴比索 | "$" 0.00 | n | $ 123.00 || +| 货币:古巴可兑换比索 | "$" 0.00 | n | $ 123.00 || +| 货币:圭亚那元 | "$" 0.00 | n | $ 123.00 || +| 货币:哈萨克斯坦坚戈 | "?" 0.00 | n | ? 123.00 || +| 货币:海地古德 | "HTG" 0.00 | n | HTG 123.00 || +| 货币:韩元 | "?" 0.00 | n | ? 123.00 || +| 货币:荷属安的列斯盾 | "NAf." 0.00 | n | NAf. 123.00 || +| 货币:洪都拉斯拉伦皮拉 | "L" 0.00 | n | L 123.00 || +| 货币:吉布提法郎 | "Fdj" 0.00 | n | Fdj 123.00 || +| 货币:吉尔吉斯斯坦索姆 | "KGS" 0.00 | n | KGS 123.00 || +| 货币:几内亚法郎 | "FG" 0.00 | n | FG 123.00 || +| 货币:加拿大元 | "$" 0.00 | n | $ 123.00 || +| 货币:加纳塞地 | "GHS" 0.00 | n | GHS 123.00 || +| 货币:柬埔寨瑞尔 | "Riel" 0.00 | n | Riel 123.00 || +| 货币:捷克克朗 | "K?" 0.00 | n | K? 123.00 || +| 货币:津巴布韦元 | "$" 0.00 | n | $ 123.00 || +| 货币:卡塔尔里亚尔 | "Rial" 0.00 | n | Rial 123.00 || +| 货币:开曼群岛元 | "$" 0.00 | n | $ 123.00 || +| 货币:科摩罗法郎 | "CF" 0.00 | n | CF 123.00 || +| 货币:科威特第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:克罗地亚库纳 | "kn" 0.00 | n | kn 123.00 || +| 货币:肯尼亚先令 | "Ksh" 0.00 | n | Ksh 123.00 || +| 货币:莱索托洛蒂 | "LSL" 0.00 | n | LSL 123.00 || +| 货币:老挝基普 | "?" 0.00 | n | ? 123.00 || +| 货币:黎巴嫩镑 | "L£" 0.00 | n | L£ 123.00 || +| 货币:立陶宛立特 | "Lt" 0.00 | n | Lt 123.00 || +| 货币:利比亚第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:利比亚元 | "$" 0.00 | n | $ 123.00 || +| 货币:卢旺达法郎 | "RF" 0.00 | n | RF 123.00 || +| 货币:罗马尼亚列伊 | "RON" 0.00 | n | RON 123.00 || +| 货币:马达加斯加阿里亚里 | "Ar" 0.00 | n | Ar 123.00 || +| 货币:马尔代夫拉菲亚 | "Rf" 0.00 | n | Rf 123.00 || +| 货币:马拉维克瓦查 | "MWK" 0.00 | n | MWK 123.00 || +| 货币:马来西亚林吉特 | "RM" 0.00 | n | RM 123.00 || +| 货币:马其顿戴第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:毛里求斯卢比 | "MURs" 0.00 | n | MURs 123.00 || +| 货币:毛里塔尼亚乌吉亚 | "MRO" 0.00 | n | MRO 123.00 || +| 货币:蒙古图格里克 | "?" 0.00 | n | ? 123.00 || +| 货币:孟加拉塔卡 | "?" 0.00 | n | ? 123.00 || +| 货币:秘鲁新索尔 | "S/" 0.00 | n | S/ 123.00 || +| 货币:缅甸开亚特 | "K" 0.00 | n | K 123.00 || +| 货币:摩尔多瓦列伊 | "MDL" 0.00 | n | MDL 123.00 || +| 货币:摩洛哥迪拉姆 | "dh" 0.00 | n | dh 123.00 || +| 货币:莫桑比克梅蒂卡尔 | "MTn" 0.00 | n | MTn 123.00 || +| 货币:墨西哥比索 | "$" 0.00 | n | $ 123.00 || +| 货币:纳米比亚元 | "$" 0.00 | n | $ 123.00 || +| 货币:南非兰特 | "R" 0.00 | n | R 123.00 || +| 货币:南苏丹镑 | "£" 0.00 | n | £ 123.00 || +| 货币:尼加拉瓜科多巴 | "C$" 0.00 | n | C$ 123.00 || +| 货币:尼泊尔卢比 | "Rs" 0.00 | n | Rs 123.00 || +| 货币:尼日利亚奈拉 | "?" 0.00 | n | ? 123.00 || +| 货币:挪威克朗 | "kr" 0.00 | n | kr 123.00 || +| 货币:乔治亚拉瑞 | "GEL" 0.00 | n | GEL 123.00 || +| 货币:人民币(离岸) | "¥" 0.00 | n | ¥ 123.00 || +| 货币:瑞典克朗 | "kr" 0.00 | n | kr 123.00 || +| 货币:瑞士法郎 | "CHF" 0.00 | n | CHF 123.00 || +| 货币:塞尔维亚第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:塞拉利昂利昂 | "SLL" 0.00 | n | SLL 123.00 || +| 货币:塞舌尔卢比 | "SCR" 0.00 | n | SCR 123.00 || +| 货币:沙特里亚尔 | "Rial" 0.00 | n | Rial 123.00 || +| 货币:圣多美多布拉 | "Db" 0.00 | n | Db 123.00 || +| 货币:圣赫勒拿群岛磅 | "£" 0.00 | n | £ 123.00 || +| 货币:斯里兰卡卢比 | "Rs" 0.00 | n | Rs 123.00 || +| 货币:斯威士兰里兰吉尼 | "SZL" 0.00 | n | SZL 123.00 || +| 货币:苏丹镑 | "SDG" 0.00 | n | SDG 123.00 || +| 货币:苏里南元 | "$" 0.00 | n | $ 123.00 || +| 货币:所罗门群岛元 | "$" 0.00 | n | $ 123.00 || +| 货币:索马里先令 | "SOS" 0.00 | n | SOS 123.00 || +| 货币:塔吉克斯坦索莫尼 | "Som" 0.00 | n | Som 123.00 || +| 货币:太平洋法郎 | "FCFP" 0.00 | n | FCFP 123.00 || +| 货币:泰国铢 | "?" 0.00 | n | ? 123.00 || +| 货币:坦桑尼亚先令 | "TSh" 0.00 | n | TSh 123.00 || +| 货币:汤加潘加 | "T$" 0.00 | n | T$ 123.00 || +| 货币:特立尼达和多巴哥元 | "$" 0.00 | n | $ 123.00 || +| 货币:突尼斯第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:土耳其里拉 | "?" 0.00 | n | ? 123.00 || +| 货币:瓦努阿图瓦图 | "VUV" 0.00 | n | VUV 123.00 || +| 货币:危地马拉格查尔 | "Q" 0.00 | n | Q 123.00 || +| 货币:委内瑞拉博利瓦 | "Bs" 0.00 | n | Bs 123.00 || +| 货币:文莱元 | "$" 0.00 | n | $ 123.00 || +| 货币:乌干达先令 | "UGX" 0.00 | n | UGX 123.00 || +| 货币:乌克兰格里夫尼亚 | "грн." 0.00 | n | грн. 123.00 || +| 货币:乌拉圭比索 | "$" 0.00 | n | $ 123.00 || +| 货币:乌兹别克斯坦苏姆 | "so?m" 0.00 | n | so?m 123.00 || +| 货币:西萨摩亚塔拉 | "WST" 0.00 | n | WST 123.00 || +| 货币:新加坡元 | "$" 0.00 | n | $ 123.00 || +| 货币:新台币 | "NT$" 0.00 | n | NT$ 123.00 || +| 货币:新西兰元 | "$" 0.00 | n | $ 123.00 || +| 货币:匈牙利福林 | "Ft" 0.00 | n | Ft 123.00 || +| 货币:叙利亚镑 | "£" 0.00 | n | £ 123.00 || +| 货币:牙买加元 | "$" 0.00 | n | $ 123.00 || +| 货币:亚美尼亚德拉姆 | "Dram" 0.00 | n | Dram 123.00 || +| 货币:也门里亚尔 | "Rial" 0.00 | n | Rial 123.00 || +| 货币:伊拉克第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:伊朗里亚尔 | "Rial" 0.00 | n | Rial 123.00 || +| 货币:以色列新谢克尔 | "?" 0.00 | n | ? 123.00 || +| 货币:印度卢比 | "?" 0.00 | n | ? 123.00 || +| 货币:印度尼西亚卢比 | "Rp" 0.00 | n | Rp 123.00 || +| 货币:约旦第纳尔 | "din" 0.00 | n | din 123.00 || +| 货币:越南盾 | "?" 0.00 | n | ? 123.00 || +| 货币:赞比亚克瓦查 | "ZMW" 0.00 | n | ZMW 123.00 || +| 货币:直布罗陀镑 | "£" 0.00 | n | £ 123.00 || +| 货币:智利比索 | "$" 0.00 | n | $ 123.00 || +| 货币:中非金融合作法郎 | "FCFA" 0.00 | n | FCFA 123.00 || -Aspose设置如下: -| Value | Type | Format String | -|-------|------------|---------------------------------------------| -| 0 | General | General | -| 1 | Decimal | 0 | -| 2 | Decimal | 0\.00 | -| 3 | Decimal | \#,\#\#0 | -| 4 | Decimal | \#,\#\#0\.00 | -| 5 | Currency | $\#,\#\#0;$\-\#,\#\#0 | -| 6 | Currency | $\#,\#\#0;$\-\#,\#\#0 | -| 7 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | -| 8 | Currency | $\#,\#\#0\.00;$\-\#,\#\#0\.00 | -| 9 | Percentage | 0% | -| 10 | Percentage | 0\.00% | -| 11 | Scientific | 0\.00E\+00 | -| 12 | Fraction | \# ?/? | -| 13 | Fraction | \# / | -| 14 | Date | m/d/yy | -| 15 | Date | d\-mmm\-yy | -| 16 | Date | d\-mmm | -| 17 | Date | mmm\-yy | -| 18 | Time | h:mm AM/PM | -| 19 | Time | h:mm:ss AM/PM | -| 20 | Time | h:mm | -| 21 | Time | h:mm:ss | -| 22 | Time | m/d/yy h:mm | -| 37 | Currency | \#,\#\#0;\-\#,\#\#0 | -| 38 | Currency | \#,\#\#0;\-\#,\#\#0 | -| 39 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | -| 40 | Currency | \#,\#\#0\.00;\-\#,\#\#0\.00 | -| 41 | Accounting | \_ \* \#,\#\#0\_ ;\_ \* "\_ ;\_ @\_ | -| 42 | Accounting | \_ $\* \#,\#\#0\_ ;\_ $\* "\_ ;\_ @\_ | -| 43 | Accounting | \_ \* \#,\#\#0\.00\_ ;\_ \* "??\_ ;\_ @\_ | -| 44 | Accounting | \_ $\* \#,\#\#0\.00\_ ;\_ $\* "??\_ ;\_ @\_ | -| 45 | Time | mm:ss | -| 46 | Time | h :mm:ss | -| 47 | Time | mm:ss\.0 | -| 48 | Scientific | \#\#0\.0E\+00 | -| 49 | Text | @ | -导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1, \ No newline at end of file +注意: 导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1 \ No newline at end of file diff --git a/src/controllers/conditionformat.js b/src/controllers/conditionformat.js index c9d3c6ea4..e50207f00 100644 --- a/src/controllers/conditionformat.js +++ b/src/controllers/conditionformat.js @@ -98,6 +98,8 @@ const conditionformat = { init: function(){ let _this = this; + const conditionformat_Text = locale().conditionformat; + // 管理规则 $(document).off("change.CFchooseSheet").on("change.CFchooseSheet", "#luckysheet-administerRule-dialog .chooseSheet", function(){ let index = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val(); @@ -221,10 +223,10 @@ const conditionformat = { $(document).off("click.CFnewConditionRule").on("click.CFnewConditionRule", "#newConditionRule", function(){ if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择应用范围"); + alert(conditionformat_Text.pleaseSelectRange); } else{ - tooltip.info("请选择应用范围", ""); + tooltip.info(conditionformat_Text.pleaseSelectRange, ""); } return; } @@ -304,7 +306,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr1 = _this.getRangeByTxt(v1); if(rangeArr1.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr1.length == 1){ @@ -318,13 +320,13 @@ const conditionformat = { conditionValue.push(v1); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr1.length == 0){ if(isNaN(v1) || v1 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -334,7 +336,7 @@ const conditionformat = { let rangeArr2 = _this.getRangeByTxt(v2); if(rangeArr2.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr2.length == 1){ @@ -348,13 +350,13 @@ const conditionformat = { conditionValue.push(v2); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr2.length == 0){ if(isNaN(v2) || v2 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -369,7 +371,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr = _this.getRangeByTxt(v); if(rangeArr.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr.length == 1){ @@ -383,13 +385,13 @@ const conditionformat = { conditionValue.push(v); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr.length == 0){ if(isNaN(v) || v == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -407,7 +409,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr = _this.getRangeByTxt(v); if(rangeArr.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr.length == 1){ @@ -421,13 +423,13 @@ const conditionformat = { conditionValue.push(v); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr.length == 0){ if(isNaN(v) || v == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -442,7 +444,7 @@ const conditionformat = { let v = $("#luckysheet-newConditionRule-dialog #daterange-btn").val(); if(v == "" || v == null){ - _this.infoDialog("请选择日期", ""); + _this.infoDialog(conditionformat_Text.pleaseSelectADate, ""); return; } @@ -472,7 +474,7 @@ const conditionformat = { let v = $("#luckysheet-newConditionRule-dialog #conditionVal input").val().trim(); if(parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1000){ - _this.infoDialog("请输入一个介于 1 和 1000 之间的整数", ""); + _this.infoDialog(conditionformat_Text.pleaseEnterInteger, ""); return; } @@ -669,7 +671,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr1 = _this.getRangeByTxt(v1); if(rangeArr1.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr1.length == 1){ @@ -683,13 +685,13 @@ const conditionformat = { conditionValue.push(v1); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr1.length == 0){ if(isNaN(v1) || v1 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -699,7 +701,7 @@ const conditionformat = { let rangeArr2 = _this.getRangeByTxt(v2); if(rangeArr2.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr2.length == 1){ @@ -713,13 +715,13 @@ const conditionformat = { conditionValue.push(v2); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr2.length == 0){ if(isNaN(v2) || v2 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -734,7 +736,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr = _this.getRangeByTxt(v); if(rangeArr.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr.length == 1){ @@ -748,13 +750,13 @@ const conditionformat = { conditionValue.push(v); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr.length == 0){ if(isNaN(v) || v == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -772,7 +774,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr = _this.getRangeByTxt(v); if(rangeArr.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr.length == 1){ @@ -786,13 +788,13 @@ const conditionformat = { conditionValue.push(v); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr.length == 0){ if(isNaN(v) || v == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -807,7 +809,7 @@ const conditionformat = { let v = $("#luckysheet-editorConditionRule-dialog #daterange-btn").val(); if(v == "" || v == null){ - _this.infoDialog("请选择日期", ""); + _this.infoDialog(conditionformat_Text.pleaseSelectADate, ""); return; } @@ -837,7 +839,7 @@ const conditionformat = { let v = $("#luckysheet-editorConditionRule-dialog #conditionVal input").val().trim(); if(parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1000){ - _this.infoDialog("请输入一个介于 1 和 1000 之间的整数", ""); + _this.infoDialog(conditionformat_Text.pleaseEnterInteger, ""); return; } @@ -998,7 +1000,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr = _this.getRangeByTxt(v); if(rangeArr.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr.length == 1){ @@ -1012,13 +1014,13 @@ const conditionformat = { conditionValue.push(v); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr.length == 0){ if(isNaN(v) || v == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -1033,7 +1035,7 @@ const conditionformat = { //条件值是否是选区 let rangeArr1 = _this.getRangeByTxt(v1); if(rangeArr1.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr1.length == 1){ @@ -1047,13 +1049,13 @@ const conditionformat = { conditionValue.push(v1); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr1.length == 0){ if(isNaN(v1) || v1 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -1063,7 +1065,7 @@ const conditionformat = { let rangeArr2 = _this.getRangeByTxt(v2); if(rangeArr2.length > 1){ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } else if(rangeArr2.length == 1){ @@ -1077,13 +1079,13 @@ const conditionformat = { conditionValue.push(v2); } else{ - _this.infoDialog("只能对单个单元格进行引用", ""); + _this.infoDialog(conditionformat_Text.onlySingleCell, ""); return; } } else if(rangeArr2.length == 0){ if(isNaN(v2) || v2 == ""){ - _this.infoDialog("条件值只能是数字或者单个单元格", ""); + _this.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); return; } else{ @@ -1095,7 +1097,7 @@ const conditionformat = { let v = $("#luckysheet-conditionformat-dialog #daterange-btn").val(); if(v == "" || v == null){ - _this.infoDialog("请选择日期", ""); + _this.infoDialog(conditionformat_Text.pleaseSelectADate, ""); return; } @@ -1108,7 +1110,7 @@ const conditionformat = { let v = $("#luckysheet-conditionformat-dialog #conditionVal").val().trim(); if(parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1000){ - _this.infoDialog("请输入一个介于 1 和 1000 之间的整数", ""); + _this.infoDialog(conditionformat_Text.pleaseEnterInteger, ""); return; } @@ -1287,7 +1289,7 @@ const conditionformat = { //新建规则弹出层 if(id == "luckysheet-newConditionRule-dialog"){ - let source=$("#" + id).find("#luckysheet-newConditionRule-dialog-close").attr("data-source"); + let source = $("#" + id).find("#luckysheet-newConditionRule-dialog-close").attr("data-source"); //新建规则入口 if(source == 1){ $("#luckysheet-administerRule-dialog").show(); @@ -1343,12 +1345,15 @@ const conditionformat = { $("#luckysheet-modal-dialog-mask").hide(); $("#luckysheet-singleRange-dialog").remove(); + const conditionformat_Text = locale().conditionformat; + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-singleRange-dialog", "addclass": "luckysheet-singleRange-dialog", - "title": "选择单元格", - "content": '', - "botton": '', + "title": conditionformat_Text.selectCell, + "content": ``, + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-singleRange-dialog") @@ -1370,12 +1375,15 @@ const conditionformat = { $("#luckysheet-modal-dialog-mask").hide(); $("#luckysheet-multiRange-dialog").remove(); + const conditionformat_Text = locale().conditionformat; + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-multiRange-dialog", "addclass": "luckysheet-multiRange-dialog", - "title": "选择应用范围", - "content": '', - "botton": '', + "title": conditionformat_Text.selectRange, + "content": ``, + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-multiRange-dialog") @@ -1431,6 +1439,8 @@ const conditionformat = { return range; }, colorSelectInit: function(){ + const conditionformat_Text = locale().conditionformat; + $(".luckysheet-conditionformat-config-color").spectrum({ showPalette: true, showPaletteOnly:true, @@ -1445,12 +1455,12 @@ const conditionformat = { maxPaletteSize: 8, maxSelectionSize: 8, // color: currenColor, - cancelText: "取消", - chooseText: "确定颜色", + cancelText: conditionformat_Text.cancel, + chooseText: conditionformat_Text.confirmColor, togglePaletteMoreText: "自定义", togglePaletteLessText: "收起", togglePaletteOnly: true, - clearText: "清除颜色选择", + clearText: conditionformat_Text.clearColorSelect, noColorSelectedText: "没有颜色被选择", localStorageKey: "spectrum.textcolor" + server.gridKey, palette: [["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"], @@ -1474,12 +1484,15 @@ const conditionformat = { $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-conditionformat-dialog").remove(); + const conditionformat_Text = locale().conditionformat; + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-conditionformat-dialog", "addclass": "luckysheet-conditionformat-dialog", "title": title, "content": content, - "botton": '', + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-conditionformat-dialog") @@ -1498,7 +1511,7 @@ const conditionformat = { _this.init(); _this.colorSelectInit(); - if(title == "条件格式——发生日期"){ + if(title == locale().conditionformat.conditionformat_occurrenceDate){ _this.daterangeInit("luckysheet-conditionformat-dialog"); } }, @@ -1506,68 +1519,70 @@ const conditionformat = { $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-CFicons-dialog").remove(); - let content = '
'+ - '
请点击选择一组图标:
'+ - '
方向
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
形状
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
标记
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
等级
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
'; + const conditionformat_Text = locale().conditionformat; + + let content = `
+
${conditionformat_Text.pleaseSelectIcon}
+
${conditionformat_Text.direction}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
${conditionformat_Text.shape}
+
+
+
+
+
+
+
+
+
+
+
+
+
${conditionformat_Text.mark}
+
+
+
+
+
+
+
+
+
+
+
${conditionformat_Text.grade}
+
+
+
+
+
+
+
+
+
+
+
+
+
`; $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-CFicons-dialog", "addclass": "luckysheet-CFicons-dialog", - "title": "图标集", + "title": conditionformat_Text.icons, "content": content, - "botton": '', + "botton": ``, "style": "z-index:100003" })); let $t = $("#luckysheet-CFicons-dialog") @@ -1627,7 +1642,7 @@ const conditionformat = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-administerRule-dialog", "addclass": "luckysheet-administerRule-dialog", - "title": conditionformat_Text.manageRules, + "title": conditionformat_Text.conditionformatManageRules, "content": content, "botton": ` `, @@ -1912,6 +1927,8 @@ const conditionformat = { editorConditionRuleDialog: function(){ let _this = this; + const conditionformat_Text = locale().conditionformat; + let rule = _this.editorRule.data; let ruleType = rule["type"], ruleFormat = rule["format"]; @@ -1965,9 +1982,9 @@ const conditionformat = { $("#luckysheet-editorConditionRule-dialog").remove(); let content = '
' + - '
选择规则类型:
' + + '
'+ conditionformat_Text.chooseRuleType +':
' + _this.ruleTypeHtml() + - '
编辑规则说明:
' + + '
'+ conditionformat_Text.editRuleDescription +':
' + '
' + ruleExplainHtml + '
' + @@ -1976,9 +1993,10 @@ const conditionformat = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-editorConditionRule-dialog", "addclass": "luckysheet-newEditorRule-dialog", - "title": "编辑格式规则", + "title": conditionformat_Text.editFormatRule, "content": content, - "botton": '', + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-editorConditionRule-dialog") @@ -2129,7 +2147,7 @@ const conditionformat = { "addclass": "", "title": title, "content": content, - "botton": '', + "botton": ``, "style": "z-index:100003" })); let $t = $("#luckysheet-conditionformat-info-dialog") @@ -2213,138 +2231,159 @@ const conditionformat = {
  • -
  • +
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • `; break; case 1: //只为包含以下内容的单元格设置格式 - ruleExplainHtml = '
    只为满足以下条件的单元格:
    ' + - '
    ' + - ''+ - '
    ' + - '
    ' + - '' + - '
    ' + - '' + - '
    ' + - '' + - '' + - '
    ' + - '' + - '' + - '
    ' + - '
    ' + - '
    设置格式:
    ' + textCellColorHtml; + ruleExplainHtml = `
    ${conditionformat_Text.ruleTypeItem2_title}:
    +
    + +
    +
    + +
    + + +
    + + +
    + + +
    +
    +
    设置格式:
    ${textCellColorHtml}`; break; case 2: //仅对排名靠前或靠后的数值设置格式 - ruleExplainHtml = '
    为以下排名内的值:
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - ''+ - ''+ - '
    '+ - '
    设置格式:
    ' + textCellColorHtml; + ruleExplainHtml = `
    ${conditionformat_Text.ruleTypeItem3_title}:
    +
    + +
    + +
    + + +
    +
    ${conditionformat_Text.setFormat}:
    ${textCellColorHtml}`; break; case 3: //仅对高于或低于平均值的数值设置格式 - ruleExplainHtml = '
    为满足以下条件的值:
    '+ - '
    '+ - ''+ - '选定范围的平均值'+ - '
    '+ - '
    设置格式:
    ' + textCellColorHtml; + ruleExplainHtml = `
    ${conditionformat_Text.ruleTypeItem4_title}:
    +
    + + ${conditionformat_Text.selectRange_average} +
    +
    ${conditionformat_Text.setFormat}:
    ${textCellColorHtml}`; break; case 4: //仅对唯一值或重复值设置格式 - ruleExplainHtml = '
    全部:
    '+ - '
    '+ - ''+ - '选定范围中的数值'+ - '
    '+ - '
    设置格式:
    ' + textCellColorHtml; + ruleExplainHtml = `
    ${conditionformat_Text.all}:
    +
    + + ${conditionformat_Text.selectRange_value} +
    +
    ${conditionformat_Text.setFormat}:
    ${textCellColorHtml}`; break; } return ruleExplainHtml; }, daterangeInit: function(id){ + const conditionformat_Text = locale().conditionformat; + //日期选择插件 $('.ranges_1 ul').remove(); $('#' + id).find("#daterange-btn").daterangepicker({ ranges: { - // '全部': [moment(), moment().subtract(-1, 'days')], - '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], - '今天': [moment(), moment()], - // '明天': [moment().subtract(-1, 'days'), moment().subtract(-1, 'days')], - '上周': [moment(moment().subtract(1, 'week')).subtract(new Date().getDay() - 1, 'days'), moment().subtract(new Date().getDay(), 'days')], - '本周': [moment().subtract(new Date().getDay() - 1, 'days'), moment().add(7 - new Date().getDay(), 'days')], - '上月': [moment(moment().format('YYYY-MM')).subtract(1, 'month'), moment(moment().format('YYYY-MM')).subtract(1, 'day')], - '本月': [moment().format('YYYY-MM'), moment(moment(moment().format('YYYY-MM')).add(1, 'month')).subtract(1, 'day')], - '去年': [moment(moment(moment().format('YYYY'))).subtract(1, 'years').format('YYYY'), moment(moment().format('YYYY')).subtract(1, 'day')], - '本年': [moment().format('YYYY'), moment(moment(moment().add(1, 'years')).format('YYYY')).subtract(1, 'day')], - '最近7天': [moment().subtract(6, 'days'), moment()], - '最近30天': [moment().subtract(29, 'days'), moment()] - // '未来七天': [moment(),moment().subtract(-6, 'days')], - // '未来30天': [moment(),moment().subtract(-29, 'days')], - // '未来60天': [moment(),moment().subtract(-59, 'days'), ] + // [conditionformat_Text.all]: [moment(), moment().subtract(-1, 'days')], + [conditionformat_Text.yesterday]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')], + [conditionformat_Text.today]: [moment(), moment()], + // [conditionformat_Text.tomorrow]: [moment().subtract(-1, 'days'), moment().subtract(-1, 'days')], + [conditionformat_Text.lastWeek]: [moment(moment().subtract(1, 'week')).subtract(new Date().getDay() - 1, 'days'), moment().subtract(new Date().getDay(), 'days')], + [conditionformat_Text.thisWeek]: [moment().subtract(new Date().getDay() - 1, 'days'), moment().add(7 - new Date().getDay(), 'days')], + [conditionformat_Text.lastMonth]: [moment(moment().format('YYYY-MM')).subtract(1, 'month'), moment(moment().format('YYYY-MM')).subtract(1, 'day')], + [conditionformat_Text.thisMonth]: [moment().format('YYYY-MM'), moment(moment(moment().format('YYYY-MM')).add(1, 'month')).subtract(1, 'day')], + [conditionformat_Text.lastYear]: [moment(moment(moment().format('YYYY'))).subtract(1, 'years').format('YYYY'), moment(moment().format('YYYY')).subtract(1, 'day')], + [conditionformat_Text.thisYear]: [moment().format('YYYY'), moment(moment(moment().add(1, 'years')).format('YYYY')).subtract(1, 'day')], + [conditionformat_Text.last7days]: [moment().subtract(6, 'days'), moment()], + [conditionformat_Text.last30days]: [moment().subtract(29, 'days'), moment()] + // [conditionformat_Text.next7days]: [moment(),moment().subtract(-6, 'days')], + // [conditionformat_Text.next30days]: [moment(),moment().subtract(-29, 'days')], + // [conditionformat_Text.next60days]: [moment(),moment().subtract(-59, 'days'), ] }, startDate: moment(), endDate: moment() }, function(start, end,label) { //label:通过它来知道用户选择的是什么,传给后台进行相应的展示 - if(label == '全部'){ + let format1 = [ + conditionformat_Text.yesterday, + conditionformat_Text.today + ]; + + let format2 = [ + conditionformat_Text.lastWeek, + conditionformat_Text.thisWeek, + conditionformat_Text.lastMonth, + conditionformat_Text.thisMonth, + conditionformat_Text.lastYear, + conditionformat_Text.thisYear, + conditionformat_Text.last7days, + conditionformat_Text.last30days + ] + + if(label == conditionformat_Text.all){ $('#daterange-btn').val(''); } - else if(label == '昨天' || label == '今天'){ + else if(format1.indexOf(label) > -1){ $('#daterange-btn').val(start.format('YYYY/MM/DD')); } - else if(label == '上周' || label == '本周' || label == '上月' || label == '本月' || label == '去年' || label == '本年' || label == '最近7天' || label == '最近30天'){ - $('#daterange-btn').val(start.format('YYYY/MM/DD')+'-'+end.format('YYYY/MM/DD')); + else if(format2.indexOf(label) > -1){ + $('#daterange-btn').val(start.format('YYYY/MM/DD') + '-' + end.format('YYYY/MM/DD')); } } ); diff --git a/src/controllers/constant.js b/src/controllers/constant.js index 9697dd016..a2cd635db 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -1,19 +1,24 @@ import locale from '../locale/locale'; //dom variable -const gridHTML = '
    ' + +const gridHTML = function(){ + + const _locale = locale(); + const locale_info = _locale.info; + + return '
    ' + '' + '
    ' + '' + '
    ' + - '
    ' + + '
    ' + '' + '
    ' + '
    ' + - '' + + '' + '
    ' + - '
    新打开
    ' + - '
    待更新
    ' + + '
    '+locale_info.detailUpdate+'
    ' + + '
    '+locale_info.wait+'
    ' + '
    ${functionButton}
    ' + '
    ' + '
    ${menu}
    ' + @@ -160,8 +165,10 @@ const gridHTML = '
    ' + '
    ' + '' + '
    ' + - '
    ', - columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], + '
    '; +} + +const columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], columeHeader_word_index = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25 }, flow = '
    ${flow}
    ', colsmenuHTML = ''; @@ -434,7 +441,7 @@ const pivottableconfigHTML = '
    ${item}
    ', sheetselectlistitemHTML = '
    ${icon}${name}
    ', inputHTML = '
    ', - modelHTML = '', + modelHTML = '', maskHTML = '
    '; @@ -484,8 +491,11 @@ function sheetconfigHTML(){
    `; } -const luckysheetPivotTableHTML = '
    数据透视表
    编辑范围
    选择需要添加到数据透视表的字段 清除
    筛选
    数值
    '; - +const luckysheetPivotTableHTML = function(){ + const _locale = locale(); + const locale_pivotTable = _locale.pivotTable; + return '
    数据透视表
    编辑范围
    选择需要添加到数据透视表的字段 清除
    筛选
    数值
    '; +} function filtermenuHTML() { const _locale = locale(); @@ -1150,8 +1160,13 @@ function menuToolBar (){ ${toolbar.splitColumn}
    `; } -const luckysheetlodingHTML = '
    渲染中...
    '; + +const luckysheetlodingHTML = function(){ + const _locale = locale() + const info =_locale.info; + return'
    '+info.loading+'...
    '; +} // var menusetting = { // menu_selectall: '
    全选
    ', // menu_copy: '
    复制
    ', diff --git a/src/controllers/filter.js b/src/controllers/filter.js index e667cf5b7..cd6cca5b9 100644 --- a/src/controllers/filter.js +++ b/src/controllers/filter.js @@ -2,13 +2,27 @@ import { getSheetIndex } from '../methods/get'; import editor from '../global/editor'; import { isRealNull, isEditMode } from '../global/validate'; import tooltip from '../global/tooltip'; -import { orderbydata } from '../global/sort'; import { rowlenByRange } from '../global/getRowlen'; -import { jfrefreshgrid } from '../global/refresh'; import { selectHightlightShow } from './select'; import { luckysheetMoveEndCell } from './sheetMove'; import server from './server'; +import locale from '../locale/locale'; import Store from '../store'; +import menuButton from './menuButton'; +import conditionformat from './conditionformat'; +import alternateformat from './alternateformat'; +import { + rgbTohex, + showrightclickmenu, +} from '../utils/util'; +import cleargridelement from '../global/cleargridelement'; +import { + jfrefreshgrid, + jfrefreshgrid_rhcw, +} from '../global/refresh'; +import { orderbydata, orderbydata1D } from '../global/sort'; +import json from '../global/json'; +import { update, genarate } from '../global/format'; //筛选配置状态 function labelFilterOptionState($top, optionstate, rowhidden, caljs, notSave, str, edr, cindex, stc, edc) { @@ -263,9 +277,1501 @@ function createFilterOptions(luckysheet_filter_save, filterObj) { file.filter_select = luckysheet_filter_save; } + + +function initialFilterHandler(){ + //filter event handler + let hidefilersubmenu = null; + const _locale = locale(); + const locale_filter = _locale.filter; + const locale_button= _locale.button; + $("#luckysheetfilter").click(createFilter); + + //右键菜单 菜单项hover + let submenuhide = null, rightclickmenu = null; + $(".luckysheet-cols-menu .luckysheet-cols-submenu").hover( + function () { + let $t = $(this), attrid = $t.attr("id"), $attr = $("#" + attrid + "_sub"), $con = $t.parent(); + let winW = $(window).width(), winH = $(window).height(); + let menuW = $con.width(), attrH = $attr.height() + 25, attrW = $attr.width() + 5; + let offset = $t.offset(); + let top = offset.top, left = offset.left + menuW; + + if (left + attrW > winW) { + left = offset.left - attrW; + } + + if (top + attrH > winH) { + top = winH - attrH; + } + + $attr.css({ "top": top, "left": left }).show(); + rightclickmenu = $t; + }, + function () { + let $t = $(this), attrid = $t.attr("id"), $attr = $("#" + attrid + "_sub"); + submenuhide = setTimeout(function () { $attr.hide(); }, 200); + } + ); + + $(".luckysheet-rightgclick-menu-sub").hover( + function () { + rightclickmenu.addClass("luckysheet-cols-menuitem-hover"); + clearTimeout(submenuhide); + }, + function () { + rightclickmenu.removeClass("luckysheet-cols-menuitem-hover"); + $(this).hide(); + } + ); + + $("#luckysheet-filter-menu").mouseover(function () { + clearTimeout(hidefilersubmenu); + + hidefilersubmenu = setTimeout(function () { + $("#luckysheet-filter-submenu").hide(); + }, 500); + }); + + + $("#luckysheet-filter-submenu").mouseover(function () { + clearTimeout(hidefilersubmenu); + }).find(".luckysheet-cols-menuitem").click(function (e) { + $("#luckysheet-filter-selected span").html($(this).find(".luckysheet-cols-menuitem-content").text()).data("value", $(this).data("value")); + $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide(); + + let $type = $(this).data("type"); + let $value = $(this).attr("data-value"); + + if ($type == "2") { + $("#luckysheet-filter-selected span").data("type", "2"); + $("#luckysheet-filter-menu .luckysheet-filter-selected-input2").show(); + $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "number"); + } + else if ($type == "0") { + $("#luckysheet-filter-selected span").data("type", "0"); + } + else { + $("#luckysheet-filter-selected span").data("type", "1"); + $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).show(); + + //若是日期 改变input type类型为date + if($value == "dateequal" || $value == "datelessthan" || $value == "datemorethan"){ + $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "date"); + } + else if($value == "morethan" || $value == "moreequalthan" || $value == "lessthan" || $value == "lessequalthan" || $value == "equal" || $value == "noequal"){ + $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "number"); + } + else{ + $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "text"); + } + } + + $("#luckysheet-filter-byvalue").next().slideUp(); + $("#luckysheet-filter-submenu").hide(); + }); + + $("#luckysheet-filter-bycondition, #luckysheet-filter-byvalue").click(function () { + let $t = $(this); + $t.next().slideToggle(200); + + setTimeout(function () { + if ($t.attr("id") == "luckysheet-filter-bycondition" && $("#luckysheet-filter-bycondition").next().is(":visible")) { + if ($("#luckysheet-filter-selected span").text() != locale_filter.filiterInputNone) { + $("#luckysheet-filter-byvalue").next().slideUp(200); + } + } + + if ($t.is($("#luckysheet-filter-bycondition"))) { + if ($("#luckysheet-filter-bycondition").next().is(":hidden") && $("#luckysheet-filter-byvalue").next().is(":hidden")) { + $("#luckysheet-filter-byvalue").next().slideDown(200); + } + } + }, 300); + }); + + $("#luckysheet-filter-selected").click(function () { + let $t = $(this), toffset = $t.offset(), $menu = $("#luckysheet-filter-submenu"); + $menu.hide(); + + let winH = $(window).height(), winW = $(window).width(); + let menuW = $menu.width(), menuH = $menu.height(); + let top = toffset.top, left = toffset.left, mheight = winH - toffset.top - 20; + + if (toffset.left + menuW > winW) { + left = toffset.left - menuW; + } + + if (toffset.top > winH / 2) { + top = winH - toffset.top; + + if (top < 0) { + top = 0; + } + + mheight = toffset.top - 20; + } + + $menu.css({ "top": top, "left": left, "height": mheight }).show(); + clearTimeout(hidefilersubmenu); + }); + + //筛选按钮点击事件 + $("#luckysheet-cell-main").on("click", ".luckysheet-filter-options", function (e) { + let $t = $(e.currentTarget), + toffset = $t.offset(), + $menu = $("#luckysheet-filter-menu"), + winH = $(window).height(), + winW = $(window).width(); + + let st_r = $t.data("str"), + ed_r = $t.data("edr"), + cindex = $t.data("cindex"), + st_c = $t.data("stc"), + ed_c = $t.data("edc"), + rowhidden = $t.data("rowhidden") == "" ? {} : JSON.parse($t.data("rowhidden").replace(/\'/g, '"')); + + $("body .luckysheet-cols-menu").hide(); + $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); + $("#luckysheet-filter-byvalue-input").val(""); + $("#luckysheet-filter-bycondition").next().hide(); + $("#luckysheet-filter-byvalue").next().show(); + + $menu.data("str", st_r); + $menu.data("edr", ed_r); + $menu.data("cindex", cindex); + $menu.data("stc", st_c); + $menu.data("edc", ed_c); + + $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide().find("input").val(); + $("#luckysheet-filter-selected span").data("type", "0").data("type", null).text(locale_filter.filiterInputNone); + + let byconditiontype = $t.data("byconditiontype"); + $("#luckysheet-filter-selected span").data("value", $t.data("byconditionvalue")).data("type", byconditiontype).text($t.data("byconditiontext")); + + if (byconditiontype == "2") { + let $input = $("#luckysheet-filter-menu .luckysheet-filter-selected-input2").show().find("input"); + $input.eq(0).val($t.data("byconditionvalue1")); + $input.eq(1).val($t.data("byconditionvalue2")); + } + else if (byconditiontype == "1") { + $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).show().find("input").val($t.data("byconditionvalue1")); + } + + $("#luckysheet-filter-orderby-asc").off("click").on("click", function () { + orderbydatafiler(st_r, st_c, ed_r, ed_c, cindex, true); + }); + + $("#luckysheet-filter-orderby-desc").off("click").on("click", function () { + orderbydatafiler(st_r, st_c, ed_r, ed_c, cindex, false); + }); + + $("#luckysheet-filter-byvalue-select").empty().html('
    '+locale_filter.filiterMoreDataTip+'
    '); + + let rowhiddenother = {}; //其它筛选列的隐藏行 + $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not(this).each(function () { + let $t = $(this), rh = $t.data("rowhidden"); + + if (rh == "") { + return true; + } + + rh = JSON.parse(rh.replace(/\'/g, '"')); + + for (let r in rh) { + rowhiddenother[r] = 0; + } + }); + + let data = Store.flowdata; + + setTimeout(function () { + //日期值 + let dvmap = {}; + let dvmap_uncheck = {}; + + //除日期以外的值 + let vmap = {}; + let vmap_uncheck = {}; + + for (let r = st_r + 1; r <= ed_r; r++) { + if(r in rowhiddenother){ + continue; + } + + if(Store.flowdata[r] == null){ + continue; + } + + let cell = Store.flowdata[r][cindex]; + + if(cell != null && !isRealNull(cell.v) && cell.ct != null && cell.ct.t == "d" ){ //单元格是日期 + let v = update("YYYY-MM-DD", cell.v); + + let y = v.split("-")[0]; + let m = v.split("-")[1]; + let d = v.split("-")[2]; + + if(!(y in dvmap)){ + dvmap[y] = {}; + } + + if(!(m in dvmap[y])){ + dvmap[y][m] = {}; + } + + if(!(d in dvmap[y][m])){ + dvmap[y][m][d] = 0; + } + + dvmap[y][m][d]++; + + if(r in rowhidden){ + dvmap_uncheck[y] = 0; + dvmap_uncheck[m] = 0; + dvmap_uncheck[d] = 0; + } + } + else{ + let v, m; + if(cell == null || isRealNull(cell.v)){ + v = null; + m = null; + } + else{ + v = cell.v; + m = cell.m; + } + + if(!(v in vmap)){ + vmap[v] = {}; + } + + if(!(m in vmap[v])){ + vmap[v][m] = 0; + } + + vmap[v][m]++; + + if(r in rowhidden){ + vmap_uncheck[v + "#$$$#" + m] = 0; + } + } + } + + //遍历数据加到页面 + let item = []; + + if(JSON.stringify(dvmap).length > 2){ + for(let y in dvmap){ + let ysum = 0; + let monthHtml = ''; + + for(let m in dvmap[y]){ + let msum = 0; + let dayHtml = ''; + + for(let d in dvmap[y][m]){ + let dayL = dvmap[y][m][d]; + msum += dayL; + + //月 小于 10 + let mT; + if(Number(m) < 10){ + mT = "0" + Number(m); + } + else{ + mT = m; + } + + //日 小于 10 + let dT; + if(Number(d) < 10){ + dT = "0" + Number(d); + } + else{ + dT = d; + } + + //日是否选中状态 + if((y in dvmap_uncheck) && (m in dvmap_uncheck) && (d in dvmap_uncheck)){ + dayHtml += '
    ' + + '' + + '' + + '( ' + dayL + ' )' + + '
    '; + } + else{ + dayHtml += '
    ' + + '' + + '' + + '( ' + dayL + ' )' + + '
    '; + } + } + + ysum += msum; + + //月 小于 10 + let mT2; + if(Number(m) < 10){ + mT2 = "0" + Number(m); + } + else{ + mT2 = m; + } + + //月是否选中状态 + if((y in dvmap_uncheck) && (m in dvmap_uncheck)){ + monthHtml += '
    ' + + '
    ' + + '' + + '' + + '' + + '( ' + msum + ' )' + + '
    ' + + '
    ' + dayHtml + '
    ' + + '
    '; + } + else{ + monthHtml += '
    ' + + '
    ' + + '' + + '' + + '' + + '( ' + msum + ' )' + + '
    ' + + '
    ' + dayHtml + '
    ' + + '
    '; + } + } + + //年是否选中状态 + let yearHtml; + if(y in dvmap_uncheck){ + yearHtml = '
    ' + + '
    ' + + '' + + '' + + '' + + '( ' + ysum + ' )' + + '
    ' + + '
    ' + monthHtml + '
    ' + + '
    '; + } + else{ + yearHtml = '
    ' + + '
    ' + + '' + + '' + + '' + + '( ' + ysum + ' )' + + '
    ' + + '
    ' + monthHtml + '
    ' + + '
    '; + } + + item.unshift(yearHtml); + } + } + + if(JSON.stringify(vmap).length > 2){ + let vmapKeys = Object.keys(vmap); + vmapKeys = orderbydata1D(vmapKeys, true); + + for(let i = 0; i < vmapKeys.length; i++){ + let v = vmapKeys[i]; + + for(let x in vmap[v]){ + let text; + if((v + "#$$$#" + x) == "null#$$$#null"){ + text = "(空白)"; + } + else{ + text = x; + } + + //是否选中状态 + let dataHtml; + if((v + "#$$$#" + x) in vmap_uncheck){ + dataHtml = '
    ' + + '' + + '' + + '( ' + vmap[v][x] + ' )' + + '
    '; + } + else{ + dataHtml = '
    ' + + '' + + '' + + '( ' + vmap[v][x] + ' )' + + '
    '; + } + + item.push(dataHtml); + } + } + } + + $("#luckysheet-filter-byvalue-select").html("
    " + item.join("") + "
    "); + }, 1); + + showrightclickmenu($menu, toffset.left, toffset.top + 20); + + e.stopPropagation(); + return false; + }); + + //按颜色筛选 + $("#luckysheet-filter-orderby-color").hover( + function(){ + //遍历筛选列颜色 + let $menu = $("#luckysheet-filter-menu"); + let st_r = $menu.data("str"), + ed_r = $menu.data("edr"), + cindex = $menu.data("cindex"), + st_c = $menu.data("stc"), + ed_c = $menu.data("edc"); + let bgMap = {}; //单元格颜色 + let fcMap = {}; //字体颜色 + + let af_compute = alternateformat.getComputeMap(); + let cf_compute = conditionformat.getComputeMap(); + + for (let r = st_r + 1; r <= ed_r; r++) { + let cell = Store.flowdata[r][cindex]; + + //单元格颜色 + let bg = menuButton.checkstatus(Store.flowdata, r, cindex , "bg"); + + let checksAF = alternateformat.checksAF(r, cindex, af_compute); + if(checksAF != null){//若单元格有交替颜色 + bg = checksAF[1]; + } + + let checksCF = conditionformat.checksCF(r, cindex, cf_compute); + if(checksCF != null && checksCF["cellColor"] != null){//若单元格有条件格式 + bg = checksCF["cellColor"]; + } + + if(bg.indexOf("rgb") > -1){ + bg = rgbTohex(bg); + } + + if(bg.length == 4){ + bg = bg.substr(0, 1) + bg.substr(1, 1).repeat(2) + bg.substr(2, 1).repeat(2) + bg.substr(3, 1).repeat(2); + } + + //字体颜色 + let fc = menuButton.checkstatus(Store.flowdata, r, cindex , "fc"); + + if(checksAF != null){//若单元格有交替颜色 + fc = checksAF[0]; + } + + if(checksCF != null && checksCF["textColor"] != null){//若单元格有条件格式 + fc = checksCF["textColor"]; + } + + if(fc.indexOf("rgb") > -1){ + fc = rgbTohex(fc); + } + + if(fc.length == 4){ + fc = fc.substr(0, 1) + fc.substr(1, 1).repeat(2) + fc.substr(2, 1).repeat(2) + fc.substr(3, 1).repeat(2); + } + + if(Store.config != null && Store.config["rowhidden"] != null && r in Store.config["rowhidden"]){ + bgMap[bg] = 1; + + if(cell != null && !isRealNull(cell.v)){ + fcMap[fc] = 1; + } + } + else{ + bgMap[bg] = 0; + + if(cell != null && !isRealNull(cell.v)){ + fcMap[fc] = 0; + } + } + } + // + let filterBgColorHtml = ''; + if(JSON.stringify(bgMap).length > 2 && Object.keys(bgMap).length > 1){ + let bgColorItemHtml = ''; + for(let b in bgMap){ + if(bgMap[b] == 0){ + bgColorItemHtml += '
    '; + } + else{ + bgColorItemHtml += '
    '; + } + } + filterBgColorHtml = '
    '+locale_filter.filiterByColorTip+'
    ' + bgColorItemHtml + '
    '; + } + + let filterFcColorHtml = ''; + if(JSON.stringify(fcMap).length > 2 && Object.keys(fcMap).length > 1){ + let fcColorItemHtml = ''; + for(let f in fcMap){ + if(fcMap[f] == 0){ + fcColorItemHtml += '
    '; + } + else{ + fcColorItemHtml += '
    '; + } + } + filterFcColorHtml = '
    '+locale_filter.filiterByTextColorTip+'
    ' + fcColorItemHtml + '
    '; + } + // + let content; + if(filterBgColorHtml == '' && filterFcColorHtml == ''){ + content = '
    '+locale_filter.filterContainerOneColorTip+'
    '; + } + else{ + content = filterBgColorHtml + filterFcColorHtml + '
    '; + } + //颜色筛选子菜单 + $("#luckysheet-filter-orderby-color-submenu").remove(); + $("body").append('
    '+content+'
    '); + let $t = $("#luckysheet-filter-orderby-color-submenu").end(); + let $con = $(this).parent(); + let winW = $(window).width(), winH = $(window).height(); + let menuW = $con.width(), + myh = $t.height() + 25, + myw = $t.width() + 5; + let offset = $(this).offset(); + let top = offset.top, left = offset.left + menuW; + + if (left + myw > winW) { + left = offset.left - myw; + } + + if (top + myh > winH) { + top = winH - myh; + } + + $("#luckysheet-filter-orderby-color-submenu").css({ "top": top, "left": left }).show(); + }, + function(){ + submenuhide = setTimeout(function () { $("#luckysheet-filter-orderby-color-submenu").hide(); }, 200); + } + ); + + $(document).on("mouseover mouseleave", "#luckysheet-filter-orderby-color-submenu", function(e){ + if (e.type === "mouseover") { + clearTimeout(submenuhide); + } + else { + $(this).hide(); + } + }); + $(document).on("click", "#luckysheet-filter-orderby-color-submenu .item label", function(){ + $(this).siblings("input[type='checkbox']").click(); + }); + $(document).off("click.orderbyColorConfirm").on("click.orderbyColorConfirm", "#luckysheet-filter-orderby-color-submenu #luckysheet-filter-orderby-color-confirm", function(){ + let bg_colorMap = {}; + let fc_colorMap = {}; + + $("#luckysheet-filter-orderby-color-submenu .item").each(function(i, e){ + if($(e).find("input[type='checkbox']").is(":checked")){ + let color = $(this).find("label").attr("title"); + let $id = $(this).closest(".box").attr("id"); + + if($id == "filterBgColor"){ + bg_colorMap[color] = 0; + } + else if($id == "filterFcColor"){ + fc_colorMap[color] = 0; + } + } + }); + + let bg_filter; + if($("#luckysheet-filter-orderby-color-submenu #filterBgColor").length > 0){ + bg_filter = true; + } + else{ + bg_filter = false; + } + + let fc_filter; + if($("#luckysheet-filter-orderby-color-submenu #filterFcColor").length > 0){ + fc_filter = true; + } + else{ + fc_filter = false; + } + + let $menu = $("#luckysheet-filter-menu"); + let st_r = $menu.data("str"), + ed_r = $menu.data("edr"), + cindex = $menu.data("cindex"), + st_c = $menu.data("stc"), + ed_c = $menu.data("edc"); + + let rowhiddenother = {}; //其它筛选列的隐藏行 + $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not($("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c).get(0)).each(function () { + let $t = $(this), rh = $t.data("rowhidden"); + + if (rh == "") { + return true; + } + + rh = JSON.parse(rh); + + for (let r in rh) { + rowhiddenother[r] = 0; + } + }); + + let filterdata = {}; + let rowhidden = {}; + let caljs = {}; + + let af_compute = alternateformat.getComputeMap(); + let cf_compute = conditionformat.getComputeMap(); + + for (let r = st_r + 1; r <= ed_r; r++) { + if(r in rowhiddenother){ + continue; + } + + if(Store.flowdata[r] == null){ + continue; + } + + let cell = Store.flowdata[r][cindex]; + + //单元格颜色 + let bg = menuButton.checkstatus(Store.flowdata, r, cindex , "bg"); + + let checksAF = alternateformat.checksAF(r, cindex, af_compute); + if(checksAF != null){//若单元格有交替颜色 + bg = checksAF[1]; + } + + let checksCF = conditionformat.checksCF(r, cindex, cf_compute); + if(checksCF != null && checksCF["cellColor"] != null){//若单元格有条件格式 + bg = checksCF["cellColor"]; + } + + if(bg.indexOf("rgb") > -1){ + bg = rgbTohex(bg); + } + + if(bg.length == 4){ + bg = bg.substr(0, 1) + bg.substr(1, 1).repeat(2) + bg.substr(2, 1).repeat(2) + bg.substr(3, 1).repeat(2); + } + + //文本颜色 + let fc = menuButton.checkstatus(Store.flowdata, r, cindex , "fc"); + + if(checksAF != null){//若单元格有交替颜色 + fc = checksAF[0]; + } + + if(checksCF != null && checksCF["textColor"] != null){//若单元格有条件格式 + fc = checksCF["textColor"]; + } + + if(fc.indexOf("rgb") > -1){ + fc = rgbTohex(fc); + } + + if(fc.length == 4){ + fc = fc.substr(0, 1) + fc.substr(1, 1).repeat(2) + fc.substr(2, 1).repeat(2) + fc.substr(3, 1).repeat(2); + } + + if(bg_filter && fc_filter){ + if(!(bg in bg_colorMap) && (!(fc in fc_colorMap) || cell == null || isRealNull(cell.v))){ + rowhidden[r] = 0; + } + } + else if(bg_filter){ + if(!(bg in bg_colorMap)){ + rowhidden[r] = 0; + } + } + else if(fc_filter){ + if(!(fc in fc_colorMap) || cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + } + } + + let $top = $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c); + + let optionstate = Object.keys(rowhidden).length > 0; + + let rowhiddenall = $.extend(true, rowhiddenother, rowhidden), + rowhidenPre = json.parseJsonParm($top.data("rowhidden")); + + labelFilterOptionState($top, optionstate, rowhidden, caljs, true, st_r, ed_r, cindex, st_c, ed_c); + + let cfg = $.extend(true, {}, Store.config); + cfg["rowhidden"] = rowhiddenall; + + //保存撤销 + if(Store.clearjfundo){ + let redo = {}; + redo["type"] = "datachangeAll_filter"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["config"] = $.extend(true, {}, Store.config); + redo["curconfig"] = cfg; + + redo["optionstate"] = optionstate; + redo["optionsindex"] = cindex - st_c; + + redo["rowhidden"] = $.extend(true, {}, rowhidden); + redo["rowhidenPre"] = $.extend(true, {}, rowhidenPre); + + if (caljs != null) { + redo["caljs"] = caljs; + } + + Store.jfundo = []; + Store.jfredo.push(redo); + } + + //config + Store.config = cfg; + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + + server.saveParam("cg", Store.currentSheetIndex, cfg["rowhidden"], { "k": "rowhidden" }); + + //行高、列宽 刷新 + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + + $("#luckysheet-filter-menu, #luckysheet-filter-submenu, #luckysheet-filter-orderby-color-submenu").hide(); + cleargridelement(); + }); + + //点击复选框 + $(document).off("click.filterCheckbox1").on("click.filterCheckbox1", "#luckysheet-filter-byvalue-select .textBox",function(){ + if($(this).attr("data-check") == "true"){ + $(this).attr("data-check", "false"); + $(this).find("input[type='checkbox']").removeAttr("checked"); + } + else{ + $(this).attr("data-check", "true"); + $(this).find("input[type='checkbox']").prop("checked", true); + } + }) + $(document).off("click.filterCheckbox2").on("click.filterCheckbox2", "#luckysheet-filter-byvalue-select .year",function(){ + if($(this).attr("data-check") == "true"){ + $(this).attr("data-check", "false"); + $(this).parents(".yearBox").find(".month").attr("data-check", "false"); + $(this).parents(".yearBox").find(".day").attr("data-check", "false"); + $(this).parents(".yearBox").find("input[type='checkbox']").removeAttr("checked"); + } + else{ + $(this).attr("data-check", "true"); + $(this).parents(".yearBox").find(".month").attr("data-check", "true"); + $(this).parents(".yearBox").find(".day").attr("data-check", "true"); + $(this).parents(".yearBox").find("input[type='checkbox']").prop("checked", true); + } + }) + $(document).off("click.filterCheckbox3").on("click.filterCheckbox3", "#luckysheet-filter-byvalue-select .month",function(){ + //月份 对应的 天 + if($(this).attr("data-check") == "true"){ + $(this).attr("data-check", "false"); + $(this).parents(".monthBox").find(".day").attr("data-check", "false"); + $(this).parents(".monthBox").find("input[type='checkbox']").removeAttr("checked"); + } + else{ + $(this).attr("data-check", "true"); + $(this).parents(".monthBox").find(".day").attr("data-check", "true"); + $(this).parents(".monthBox").find("input[type='checkbox']").prop("checked", true); + } + //月份 对应的 年份 + let yearDayAllCheck = true; + let $yearDay = $(this).parents(".yearBox").find(".day"); + $yearDay.each(function(i,e){ + if($(e).attr("data-check") == "true"){ + + } + else{ + yearDayAllCheck = false; + } + }); + if(yearDayAllCheck){ + $(this).parents(".yearBox").find(".year").attr("data-check", "true"); + $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true); + } + else{ + $(this).parents(".yearBox").find(".year").attr("data-check", "false"); + $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked"); + } + }) + $(document).off("click.filterCheckbox4").on("click.filterCheckbox4", "#luckysheet-filter-byvalue-select .day",function(){ + if($(this).attr("data-check") == "true"){ + $(this).attr("data-check", "false"); + $(this).find("input[type='checkbox']").removeAttr("checked"); + } + else{ + $(this).attr("data-check", "true"); + $(this).find("input[type='checkbox']").prop("checked", true); + } + //天 对应的 月份 + let monthDayAllCheck = true; + let $monthDay = $(this).parents(".monthBox").find(".day"); + $monthDay.each(function(i,e){ + if($(e).attr("data-check") == "true"){ + + } + else{ + monthDayAllCheck = false; + } + }); + if(monthDayAllCheck){ + $(this).parents(".monthBox").find(".month").attr("data-check", "true"); + $(this).parents(".monthBox").find(".month input[type='checkbox']").prop("checked", true); + } + else{ + $(this).parents(".monthBox").find(".month").attr("data-check", "false"); + $(this).parents(".monthBox").find(".month input[type='checkbox']").removeAttr("checked"); + } + //天 对应的 年份 + let yearDayAllCheck = true; + let $yearDay = $(this).parents(".yearBox").find(".day"); + $yearDay.each(function(i,e){ + if($(e).attr("data-check") == "true"){ + + } + else{ + yearDayAllCheck = false; + } + }); + if(yearDayAllCheck){ + $(this).parents(".yearBox").find(".year").attr("data-check", "true"); + $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true); + } + else{ + $(this).parents(".yearBox").find(".year").attr("data-check", "false"); + $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked"); + } + }) + + //日期 三级下拉显示 + $(document).off("click.filterYearDropdown").on("click.filterYearDropdown", "#luckysheet-filter-byvalue-select .yearBox .fa-caret-right",function(event){ + let $p = $(this).parents(".luckysheet-mousedown-cancel"); + if($p.hasClass("year")){ + $(this).parents(".yearBox").find(".monthList").slideToggle(); + } + if($p.hasClass("month")){ + $(this).parents(".monthBox").find(".dayList").slideToggle(); + } + + event.stopPropagation(); + }); + + //全选 + $("#luckysheet-filter-byvalue-btn-all").click(function () { + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").prop("checked", true); + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "true"); + }); + + //清除 + $("#luckysheet-filter-byvalue-btn-clear").click(function () { + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").removeAttr("checked"); + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "false"); + }); + + //反选 + $("#luckysheet-filter-byvalue-btn-contra").click(function () { + let $input = $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']"); + $input.each(function(i, e){ + if($(e).is(":checked")){ + $(e).removeAttr("checked"); + $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "false"); + } + else{ + $(e).prop("checked", true); + $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "true"); + } + }); + //天 对应的 月份 + let $month = $("#luckysheet-filter-byvalue-select .ListBox .monthBox"); + $month.each(function(index, event){ + let monthDayAllCheck = true; + let $monthDay = $(event).find(".day input[type='checkbox']"); + $monthDay.each(function(i,e){ + if($(e).is(":checked")){ + + } + else{ + monthDayAllCheck = false; + } + }); + if(monthDayAllCheck){ + $(event).find(".month input[type='checkbox']").prop("checked", true); + $(event).attr("data-check", "true"); + } + else{ + $(event).find(".month input[type='checkbox']").removeAttr("checked"); + $(event).attr("data-check", "false"); + } + }); + //天 对应的 年份 + let $year = $("#luckysheet-filter-byvalue-select .ListBox .yearBox"); + $year.each(function(index, event){ + let yearDayAllCheck = true; + let $yearDay = $(event).find(".day input[type='checkbox']"); + $yearDay.each(function(i,e){ + if($(e).is(":checked")){ + + } + else{ + yearDayAllCheck = false; + } + }); + if(yearDayAllCheck){ + $(event).find(".year input[type='checkbox']").prop("checked", true); + $(event).attr("data-check", "true"); + } + else{ + $(event).find(".year input[type='checkbox']").removeAttr("checked"); + $(event).attr("data-check", "false"); + } + }); + }); + + //清除筛选 + $("#luckysheet-filter-initial").click(function () { + $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide().find("input").val(); + $("#luckysheet-filter-selected span").data("type", "0").data("type", null).text(locale_filter.conditionNone); + + $('#luckysheet-filter-selected-sheet' + Store.currentSheetIndex + ', #luckysheet-filter-options-sheet' + Store.currentSheetIndex).remove(); + $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); + + let redo = {}; + redo["type"] = "datachangeAll_filter_clear"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["config"] = $.extend(true, {}, Store.config); + Store.config["rowhidden"] = {}; + redo["curconfig"] = $.extend(true, {}, Store.config); + + redo["filter_save"] = $.extend(true, {}, Store.luckysheet_filter_save); + + let optiongroups = []; + $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").each(function () { + let $t = $(this); + + let optionstate = $t.hasClass("luckysheet-filter-options-active"); + let rowhidden = json.parseJsonParm($t.data("rowhidden")); + let caljs = json.parseJsonParm($t.data("caljs")); + + optiongroups.push({ + "optionstate":optionstate, + "rowhidden": rowhidden, + "caljs":caljs, + "str": $t.data("str"), + "edr": $t.data("edr"), + "cindex": $t.data("cindex"), + "stc": $t.data("stc"), + "edc": $t.data("edc") + }); + }); + redo["optiongroups"] = optiongroups; + + Store.jfundo = []; + Store.jfredo.push(redo); + + //清除筛选发送给后台 + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter = null; + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter_select = null; + + server.saveParam("fsc", Store.currentSheetIndex, null); + + //config + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + + server.saveParam("cg", Store.currentSheetIndex, {}, { "k": "rowhidden" }); + + //行高、列宽 刷新 + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + }); + + //按照值进行筛选 + $("#luckysheet-filter-byvalue-input").on('input propertychange', function () { + let v = $(this).val().toString(); + $("#luckysheet-filter-byvalue-select .ListBox .luckysheet-mousedown-cancel").show(); + + if(v != ""){ + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").each(function(i, e){ + if($(e).closest(".day").length > 0){ + let day = $(e).siblings("label").text().toString(); + let month = $(e).closest(".monthBox").find(".month label").text().toString(); + let year = $(e).closest(".yearBox").find(".year label").text().toString(); + let itemV = year + "-" + month + "-" + day; + + if(itemV.indexOf(v) == -1){ + $(e).closest(".day").hide(); + + //天 对应的 月份 + let $monthDay = $(e).closest(".dayList").find(".day:visible"); + if($monthDay.length == 0){ + $(e).closest(".monthBox").find(".month").hide(); + } + + //天 对应的 年份 + let $yearDay = $(e).closest(".monthList").find(".day:visible"); + if($yearDay.length == 0){ + $(e).closest(".yearBox").find(".year").hide(); + } + } + } + + if($(e).closest(".textBox").length > 0){ + let itemV = $(e).siblings("label").text().toString(); + + if(itemV.indexOf(v) == -1){ + $(e).parents(".textBox").hide(); + } + } + }); + } + }); + + //筛选取消 + $("#luckysheet-filter-cancel").click(function () { + $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); + }); + + //筛选 确认 + $("#luckysheet-filter-confirm").click(function () { + let $menu = $("#luckysheet-filter-menu"); + let st_r = $menu.data("str"), + ed_r = $menu.data("edr"), + cindex = $menu.data("cindex"), + st_c = $menu.data("stc"), + ed_c = $menu.data("edc"); + + let rowhiddenother = {}; //其它筛选列的隐藏行 + $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not($("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c).get(0)).each(function () { + let $t = $(this), rh = $t.data("rowhidden"); + + if (rh == "") { + return true; + } + + rh = JSON.parse(rh.replace(/\'/g, '"')); + + for (let r in rh) { + rowhiddenother[r] = 0; + } + }); + + let filterdata = {}; + let rowhidden = {}; + let caljs = {}; + + if ($("#luckysheet-filter-bycondition").next().is(":visible") && $("#luckysheet-filter-byvalue").next().is(":hidden") && $("#luckysheet-filter-selected span").data("value") != "null") { + let $t = $("#luckysheet-filter-selected span"); + let type = $t.data("type"), value = $t.data("value"); + + caljs["value"] = value; + caljs["text"] = $t.text(); + + if (type == "0") { + caljs["type"] = "0"; + } + else if (type == "2") { + let $input = $("#luckysheet-filter-menu .luckysheet-filter-selected-input2 input"); + caljs["type"] = "2"; + caljs["value1"] = $input.eq(0).val(); + caljs["value2"] = $input.eq(1).val(); + } + else { + caljs["type"] = "1"; + caljs["value1"] = $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).find("input").val(); + } + + for (let r = st_r + 1; r <= ed_r; r++) { + if(r in rowhiddenother){ + continue; + } + + if(Store.flowdata[r] == null){ + continue; + } + + let cell = Store.flowdata[r][cindex]; + + if (value == "cellnull") { //单元格为空 + if(cell != null && !isRealNull(cell.v)){ + rowhidden[r] = 0; + } + } + else if (value == "cellnonull") { //单元格有数据 + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + } + else if (value == "textinclude") { //文本包含 + let value1 = caljs["value1"]; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else{ + if(cell.m.indexOf(value1) == -1){ + rowhidden[r] = 0; + } + } + } + else if (value == "textnotinclude") { //文本不包含 + let value1 = caljs["value1"]; + + if(cell == null || isRealNull(cell.v)){ + + } + else{ + if(cell.m.indexOf(value1) > -1){ + rowhidden[r] = 0; + } + } + } + else if (value == "textstart") { //文本开头为 + let value1 = caljs["value1"], valuelen = value1.length; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else{ + if(cell.m.substr(0, valuelen) != value1){ + rowhidden[r] = 0; + } + } + } + else if (value == "textend") { //文本结尾为 + let value1 = caljs["value1"], valuelen = value1.length; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else{ + if(valuelen > cell.m.length || cell.m.substr(cell.m.length - valuelen, valuelen) != value1){ + rowhidden[r] = 0; + } + } + } + else if (value == "textequal") { //文本等于 + let value1 = caljs["value1"]; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else{ + if(cell.m != value1){ + rowhidden[r] = 0; + } + } + } + else if (value == "dateequal") { //日期等于 + let value1 = genarate(caljs["value1"])[2]; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "d"){ + if(parseInt(cell.v) != value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "datelessthan") { //日期早于 + let value1 = genarate(caljs["value1"])[2]; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "d"){ + if(parseInt(cell.v) >= value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "datemorethan") { //日期晚于 + let value1 = genarate(caljs["value1"])[2]; + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "d"){ + if(parseInt(cell.v) <= value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "morethan") { //大于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v <= value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "moreequalthan") { //大于等于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v < value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "lessthan") { //小于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v >= value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "lessequalthan") { //小于等于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v > value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "equal") { //等于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v != value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "noequal") { //不等于 + let value1 = parseFloat(caljs["value1"]); + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v == value1){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "include") { //介于 + let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]); + + let min, max; + if(value1 < value2){ + min = value1; + max = value2; + } + else{ + max = value1; + min = value2; + } + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v < min || cell.v > max){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + else if (value == "noinclude") { //不在其中 + let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]); + + let min, max; + if(value1 < value2){ + min = value1; + max = value2; + } + else{ + max = value1; + min = value2; + } + + if(cell == null || isRealNull(cell.v)){ + rowhidden[r] = 0; + } + else if(cell.ct != null && cell.ct.t == "n"){ + if(cell.v >= min && cell.v <= max){ + rowhidden[r] = 0; + } + } + else{ + rowhidden[r] = 0; + } + } + } + } + else { + $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").each(function(i, e){ + if($(e).is(":visible") && $(e).is(":checked")){ + return true; + } + + if($(e).closest(".day").length > 0){ + let day = $(e).siblings("label").text(); + if(Number(day) < 10){ + day = "0" + Number(day); + } + + let month = $(e).closest(".monthBox").find(".month label").text().replace(locale_filter.filiterMonthText, ""); + if(Number(month) < 10){ + month = "0" + Number(month); + } + + let year = $(e).closest(".yearBox").find(".year label").text().replace(locale_filter.filiterYearText, ""); + + let itemV = locale_filter.filterDateFormatTip +"#$$$#" + year + "-" + month + "-" + day; + + filterdata[itemV] = "1"; + } + + if($(e).closest(".textBox").length > 0){ + let itemV = $(e).closest(".textBox").data("filter"); + + filterdata[itemV] = "1"; + } + }); + + for (let r = st_r + 1; r <= ed_r; r++) { + if(r in rowhiddenother){ + continue; + } + + if(Store.flowdata[r] == null){ + continue; + } + + let cell = Store.flowdata[r][cindex]; + + let value; + if(cell == null || isRealNull(cell.v)){ + value = "null#$$$#null"; + } + else if(cell.ct != null && cell.ct.t == "d"){ + let fmt = update("YYYY-MM-DD", cell.v); + value = locale_filter.filterDateFormatTip +"#$$$#" + fmt; + } + else{ + value = cell.v + "#$$$#" + cell.m; + } + + if(value in filterdata){ + rowhidden[r] = 0; + } + } + } + + let $top = $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c); + + let optionstate = $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']:visible:checked").length < $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']:visible").length || $("#luckysheet-filter-byvalue-input").val().length > 0 || ($("#luckysheet-filter-bycondition").next().is(":visible") && $("#luckysheet-filter-byvalue").next().is(":hidden") && $("#luckysheet-filter-selected span").data("value") != "null"); + + let rowhiddenall = $.extend(true, rowhiddenother, rowhidden), + rowhidenPre = json.parseJsonParm($top.data("rowhidden")); + + labelFilterOptionState($top, optionstate, rowhidden, caljs, true, st_r, ed_r, cindex, st_c, ed_c); + + let cfg = $.extend(true, {}, Store.config); + cfg["rowhidden"] = rowhiddenall; + + //保存撤销 + if(Store.clearjfundo){ + let redo = {}; + redo["type"] = "datachangeAll_filter"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["config"] = $.extend(true, {}, Store.config); + redo["curconfig"] = cfg; + + redo["optionstate"] = optionstate; + redo["optionsindex"] = cindex - st_c; + + redo["rowhidden"] = $.extend(true, {}, rowhidden); + redo["rowhidenPre"] = $.extend(true, {}, rowhidenPre); + + if (caljs != null) { + redo["caljs"] = caljs; + } + + Store.jfundo = []; + Store.jfredo.push(redo); + } + + //config + Store.config = cfg; + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + + server.saveParam("cg", Store.currentSheetIndex, cfg["rowhidden"], { "k": "rowhidden" }); + + //行高、列宽 刷新 + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + + $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); + cleargridelement(); + }); +} + export { labelFilterOptionState, orderbydatafiler, createFilter, - createFilterOptions + createFilterOptions, + initialFilterHandler } \ No newline at end of file diff --git a/src/controllers/formulaBar.js b/src/controllers/formulaBar.js new file mode 100644 index 000000000..364f43ff1 --- /dev/null +++ b/src/controllers/formulaBar.js @@ -0,0 +1,293 @@ +import menuButton from './menuButton'; +import luckysheetupdateCell from './updateCell'; +import { keycode } from './constant'; +import { + luckysheetMoveHighlightCell, +} from './sheetMove'; + +import insertFormula from './insertFormula'; +import { + rowLocation, + colLocation, + mouseposition +} from '../global/location'; +import { isEditMode } from '../global/validate'; +import formula from '../global/formula'; +import tooltip from '../global/tooltip'; +import locale from '../locale/locale'; +import Store from '../store'; + +export function formulaBarInitial(){ + //公式栏处理 + + const _locale = locale(); + const locale_formula= _locale.formula; + + $("#luckysheet-functionbox-cell").focus(function () { + if(isEditMode()){//此模式下禁用公式栏 + return; + } + + if(Store.luckysheet_select_save.length > 0){ + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + let row = Store.visibledatarow[row_index], + row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; + let col = Store.visibledatacolumn[col_index], + col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + + let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); + if(!!margeset){ + row = margeset.row[1]; + row_pre = margeset.row[0]; + row_index = margeset.row[2]; + col = margeset.column[1]; + col_pre = margeset.column[0]; + col_index = margeset.column[2]; + } + + luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, null, true); + formula.rangeResizeTo = $("#luckysheet-functionbox-cell"); + } + }).keydown(function (event) { + if(isEditMode()){//此模式下禁用公式栏 + return; + } + + let ctrlKey = event.ctrlKey; + let altKey = event.altKey; + let shiftKey = event.shiftKey; + let kcode = event.keyCode; + let $inputbox = $("#luckysheet-input-box"); + + if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { + if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { + formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); + } + else { + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + Store.luckysheet_select_save = [{ "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], "row_focus": Store.luckysheetCellUpdate[0], "column_focus": Store.luckysheetCellUpdate[1] }]; + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + $("#luckysheet-functionbox-cell").blur(); + } + event.preventDefault(); + } + else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { + formula.setfreezonFuc(event); + event.preventDefault(); + } + else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { + if ($("#luckysheet-formula-search-c").is(":visible")) { + let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").prev(); + if ($up.length == 0) { + $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").last(); + } + $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); + $up.addClass("luckysheet-formula-search-item-active"); + event.preventDefault(); + } + } + else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { + if ($("#luckysheet-formula-search-c").is(":visible")) { + let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); + if ($up.length == 0) { + $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); + } + $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); + $up.addClass("luckysheet-formula-search-item-active"); + event.preventDefault(); + } + } + else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { + formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); + } + else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { + formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); + } + else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { + formula.functionInputHanddler($("#luckysheet-rich-text-editor"), $("#luckysheet-functionbox-cell"), kcode); + } + }).click(function () { + if(isEditMode()){//此模式下禁用公式栏 + return; + } + + formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); + }); + + //公式栏 取消(X)按钮 + $("#luckysheet-wa-functionbox-cancel").click(function () { + if (!$(this).hasClass("luckysheet-wa-calculate-active")) { + return; + } + //若有参数弹出框,隐藏 + if($("#luckysheet-search-formula-parm").is(":visible")){ + $("#luckysheet-search-formula-parm").hide(); + } + //若有参数选取范围弹出框,隐藏 + if($("#luckysheet-search-formula-parm-select").is(":visible")){ + $("#luckysheet-search-formula-parm-select").hide(); + } + + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + }); + + //公式栏 确认()按钮 + $("#luckysheet-wa-functionbox-confirm").click(function () { + if (!$(this).hasClass("luckysheet-wa-calculate-active")) { + return; + } + //若有参数弹出框,隐藏 + if($("#luckysheet-search-formula-parm").is(":visible")){ + $("#luckysheet-search-formula-parm").hide(); + } + //若有参数选取范围弹出框,隐藏 + if($("#luckysheet-search-formula-parm-select").is(":visible")){ + $("#luckysheet-search-formula-parm-select").hide(); + } + + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + }); + + //公式栏 fx按钮 + $("#luckysheet-wa-functionbox-fx").click(function () { + //点击函数查找弹出框 + if(Store.luckysheet_select_save.length == 0){ + if(isEditMode()){ + alert(locale_formula.tipSelectCell); + } + else{ + tooltip.info(locale_formula.tipSelectCell,""); + } + + return; + } + + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + let row = Store.visibledatarow[row_index], + row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; + let col = Store.visibledatacolumn[col_index], + col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + + luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); + + let cell = Store.flowdata[row_index][col_index]; + if(cell != null && cell.f != null){ + //单元格有计算 + let functionStr = formula.getfunctionParam(cell.f); + if(functionStr.fn != null){ + //有函数公式 + insertFormula.formulaParmDialog(functionStr.fn, functionStr.param); + } + else{ + //无函数公式 + insertFormula.formulaListDialog(); + } + } + else{ + //单元格无计算 + $("#luckysheet-rich-text-editor").html('='); + $("#luckysheet-functionbox-cell").html($("#luckysheet-rich-text-editor").html()); + insertFormula.formulaListDialog(); + } + + insertFormula.init(); + }); + + //公式选区操作 + $("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-copy", function (event) { + formula.rangeMove = true; + Store.luckysheet_scroll_status = true; + formula.rangeMoveObj = $(this).parent(); + formula.rangeMoveIndex = $(this).parent().attr("rangeindex"); + + let mouse = mouseposition(event.pageX, event.pageY); + let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft(); + let y = mouse[1] + $("#luckysheet-cell-main").scrollTop(); + $("#luckysheet-formula-functionrange-highlight-" + formula.rangeMoveIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); + + let type = $(this).data("type"); + if (type == "top") { + y += 3; + } + else if (type == "right") { + x -= 3; + } + else if (type == "bottom") { + y -= 3; + } + else if (type == "left") { + x += 3; + } + + let row_index = rowLocation(y)[2]; + let col_index = colLocation(x)[2]; + + formula.rangeMovexy = [row_index, col_index]; + $("#luckysheet-sheettable").css("cursor", "move"); + event.stopPropagation(); + }); + + $("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-highlight", function (e) { + formula.rangeResize = $(this).data("type");//开始状态resize + formula.rangeResizeIndex = $(this).parent().attr("rangeindex"); + + let mouse = mouseposition(e.pageX, e.pageY), + scrollLeft = $("#luckysheet-cell-main").scrollLeft(), + scrollTop = $("#luckysheet-cell-main").scrollTop(); + let x = mouse[0] + scrollLeft; + let y = mouse[1] + scrollTop; + formula.rangeResizeObj = $(this).parent(); + $("#luckysheet-formula-functionrange-highlight-" + formula.rangeResizeIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); + + if (formula.rangeResize == "lt") { + x += 3; + y += 3; + } + else if (formula.rangeResize == "lb") { + x += 3; + y -= 3; + } + else if (formula.rangeResize == "rt") { + x -= 3; + y += 3; + } + else if (formula.rangeResize == "rb") { + x -= 3; + y -= 3; + } + + let row_location = rowLocation(y), + row = row_location[1], + row_pre = row_location[0], + row_index = row_location[2]; + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + + let position = formula.rangeResizeObj.position(); + formula.rangeResizexy = [ + col_pre, + row_pre, + formula.rangeResizeObj.width(), + formula.rangeResizeObj.height(), + position.left + scrollLeft, + position.top + scrollTop, col, row + ]; + formula.rangeResizeWinH = $("#luckysheet-cell-main")[0].scrollHeight; + formula.rangeResizeWinW = $("#luckysheet-cell-main")[0].scrollWidth; + Store.luckysheet_scroll_status = true; + event.stopPropagation(); + }); +} \ No newline at end of file diff --git a/src/controllers/handler.js b/src/controllers/handler.js index cf6458111..6502a0d9b 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -12,62 +12,45 @@ import sheetmanage from './sheetmanage'; import server from './server'; import luckysheetupdateCell from './updateCell'; import { luckysheet_searcharray } from './sheetSearch'; -import { modelHTML, sheetselectlistitemHTML, sheetselectlistHTML, keycode } from './constant'; import luckysheetsizeauto from './resize'; import { luckysheetMoveHighlightCell, - luckysheetMoveHighlightCell2, - luckysheetMoveHighlightRange, - luckysheetMoveHighlightRange2 } from './sheetMove'; import { selectHightlightShow, selectIsOverlap, selectionCopyShow, luckysheet_count_show } from './select'; import selection from './selection'; -import searchReplace from './searchReplace'; import controlHistory from './controlHistory'; import splitColumn from './splitColumn'; -import { labelFilterOptionState, orderbydatafiler, createFilter, createFilterOptions } from './filter'; -import insertFormula from './insertFormula'; + import { replaceHtml, getObjType, chatatABC, ArrayUnique, - getByteLen, - rgbTohex, showrightclickmenu, - luckysheetactiveCell, - numFormat, - mouseclickposition, + luckysheetactiveCell, } from '../utils/util'; import { getSheetIndex, getRangetxt } from '../methods/get'; import { rowLocation, - rowLocationByIndex, colLocation, - colLocationByIndex, mouseposition } from '../global/location'; import { rowlenByRange } from '../global/getRowlen'; -import { isRealNull, isRealNum, hasPartMC, isEditMode } from '../global/validate'; +import { isRealNull, hasPartMC, isEditMode } from '../global/validate'; import { countfunc } from '../global/count'; import browser from '../global/browser'; import formula from '../global/formula'; -import { luckysheetextendtable, luckysheetdeletetable } from '../global/extend'; -import cleargridelement from '../global/cleargridelement'; +import { luckysheetextendtable } from '../global/extend'; import luckysheetscrollevent from '../global/scroll'; import { jfrefreshgrid, - jfrefreshgridall, jfrefreshgrid_rhcw, luckysheetrefreshgrid, } from '../global/refresh'; -import { getdatabyselection, getcellvalue, datagridgrowth } from '../global/getdata'; -import { orderbydata, orderbydata1D, sortColumnSeletion } from '../global/sort'; +import { getdatabyselection, datagridgrowth } from '../global/getdata'; import tooltip from '../global/tooltip'; import editor from '../global/editor'; -import { isdatatype } from '../global/datecontroll'; -import json from '../global/json'; -import { update, genarate } from '../global/format'; +import { genarate } from '../global/format'; import method from '../global/method'; import { getBorderInfoCompute } from '../global/border'; import { luckysheetDrawMain } from '../global/draw'; @@ -89,6 +72,10 @@ export default function luckysheetHandler() { event.preventDefault(); }); + const _locale = locale(); + const locale_drag = _locale.drag; + const locale_info = _locale.info; + $("#luckysheet-grid-window-1").mousewheel(function (event, delta) { let scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(), scrollTop = $("#luckysheet-scrollbar-y").scrollTop(); @@ -2281,10 +2268,10 @@ export default function luckysheetHandler() { //选区包含部分单元格 if(hasPartMC(cfg, last["row"][0], last["row"][1], last["column"][0], last["column"][1])){ if(isEditMode()){ - alert("无法对合并单元格执行此操作"); + alert(locale_drag.noMerge); } else{ - tooltip.info('提示',"无法对合并单元格执行此操作"); + tooltip.info('',locale_drag.noMerge); } return; } @@ -2317,10 +2304,10 @@ export default function luckysheetHandler() { //替换的位置包含部分单元格 if(hasPartMC(cfg, row_s, row_e, col_s, col_e)){ if(isEditMode()){ - alert("无法对合并单元格执行此操作"); + alert(locale_drag.noMerge); } else{ - tooltip.info('提示',"无法对合并单元格执行此操作"); + tooltip.info('',locale_drag.noMerge); } return; } @@ -2553,7 +2540,7 @@ export default function luckysheetHandler() { //是否有数据透视表范围 if(pivotTable.isPivotRange(row_s, col_e)){ - tooltip.info("无法对所选单元格进行此更改,因为它会影响数据透视表!",""); + tooltip.info(locale_drag.affectPivot,""); return; } } @@ -2565,7 +2552,7 @@ export default function luckysheetHandler() { //是否有数据透视表范围 if(pivotTable.isPivotRange(row_e, col_e)){ - tooltip.info("无法对所选单元格进行此更改,因为它会影响数据透视表!",""); + tooltip.info(locale_drag.affectPivot,""); return; } } @@ -2584,7 +2571,7 @@ export default function luckysheetHandler() { //是否有数据透视表范围 if(pivotTable.isPivotRange(row_e, col_s)){ - tooltip.info("无法对所选单元格进行此更改,因为它会影响数据透视表!",""); + tooltip.info(locale_drag.affectPivot,""); return; } } @@ -2596,7 +2583,7 @@ export default function luckysheetHandler() { //是否有数据透视表范围 if(pivotTable.isPivotRange(row_e, col_e)){ - tooltip.info("无法对所选单元格进行此更改,因为它会影响数据透视表!",""); + tooltip.info(locale_drag.affectPivot,""); return; } } @@ -2622,10 +2609,10 @@ export default function luckysheetHandler() { if(hasMc){ if(isEditMode()){ - alert("无法对合并单元格执行此操作"); + alert(locale_drag.noMerge); } else{ - tooltip.info("无法对合并单元格执行此操作", ""); + tooltip.info(locale_drag.noMerge, ""); } return; @@ -2644,10 +2631,10 @@ export default function luckysheetHandler() { if(hasMc){ if(isEditMode()){ - alert("无法对合并单元格执行此操作"); + alert(locale_drag.noMerge); } else{ - tooltip.info("无法对合并单元格执行此操作", ""); + tooltip.info(locale_drag.noMerge, ""); } return; @@ -2673,10 +2660,10 @@ export default function luckysheetHandler() { e.preventDefault(); }); - //禁止前台编辑(只可 框选单元格、滚动查看表格) - if(!Store.allowEdit){ - return; - } + // //禁止前台编辑(只可 框选单元格、滚动查看表格) + // if(!Store.allowEdit){ + // return; + // } //选区拖动替换 $("#luckysheet-cell-main div.luckysheet-cs-draghandle").mousedown(function (event) { @@ -2900,10 +2887,10 @@ export default function luckysheetHandler() { if (isNaN(parseInt(value))) { if(isEditMode()){ - alert("请输入数字"); + alert(locale_info.tipInputNumber); } else{ - tooltip.info("增加错误", "请输入数字"); + tooltip.info("error", locale_info.tipInputNumber); } return; } @@ -2911,10 +2898,10 @@ export default function luckysheetHandler() { value = parseInt(value); if (value < 1 || value > 100) { if(isEditMode()){ - alert("增加范围限制在1-100"); + alert(locale_info.tipInputNumberLimit); } else{ - tooltip.info("增加错误", "增加范围限制在1-100"); + tooltip.info("error", locale_info.tipInputNumberLimit); } return; } @@ -2926,6585 +2913,476 @@ export default function luckysheetHandler() { $("#luckysheet-scrollbar-y").scrollTop(0); }); - //单元格编辑输入 - let luckysheet_shiftkeydown = false; + //右键菜单 复制按钮 + $("#luckysheet-copy-btn, #luckysheet-cols-copy-btn, #luckysheet-paste-btn-title").click(function (event) { + $(this).parent().hide(); + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; - $("#luckysheet-input-box").click(function () { - formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); - }).add("#" + Store.container).on("keydown", function (event) { - if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { - return; - } + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; - let ctrlKey = event.ctrlKey; - let altKey = event.altKey; - let shiftKey = event.shiftKey; - let kcode = event.keyCode; - - if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("sp-input") || (parseInt($("#luckysheet-input-box").css("top")) > 0 && $(event.target).closest(".luckysheet-input-box").length > 0 && kcode != keycode.ENTER && kcode != keycode.TAB && kcode != keycode.UP && kcode != keycode.DOWN && kcode != keycode.LEFT && kcode != keycode.RIGHT)) { - let anchor = $(window.getSelection().anchorNode); - - if(anchor.parent().is("#luckysheet-helpbox-cell") || anchor.is("#luckysheet-helpbox-cell")){ - if(kcode == keycode.ENTER){ - let helpboxValue = $("#luckysheet-helpbox-cell").text(); - - if(formula.iscelldata(helpboxValue)){ - let cellrange = formula.getcellrange(helpboxValue); - - Store.luckysheet_select_save = [{ "row": cellrange["row"], "column": cellrange["column"], "row_focus": cellrange["row"][0], "column_focus": cellrange["column"][0] }]; - selectHightlightShow(); - - $("#luckysheet-helpbox-cell").blur(); - - let scrollLeft = $("#luckysheet-cell-main").scrollLeft(), - scrollTop = $("#luckysheet-cell-main").scrollTop(); - let winH = $("#luckysheet-cell-main").height(), - winW = $("#luckysheet-cell-main").width(); - - let row = Store.visibledatarow[cellrange["row"][1]], - row_pre = cellrange["row"][0] - 1 == -1 ? 0 : Store.visibledatarow[cellrange["row"][0] - 1]; - let col = Store.visibledatacolumn[cellrange["column"][1]], - col_pre = cellrange["column"][0] - 1 == -1 ? 0 : Store.visibledatacolumn[cellrange["column"][0] - 1]; - - if (col - scrollLeft - winW + 20 > 0) { - $("#luckysheet-scrollbar-x").scrollLeft(col - winW + 20); - } - else if (col_pre - scrollLeft - 20 < 0) { - $("#luckysheet-scrollbar-x").scrollLeft(col_pre - 20); - } + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - if (row - scrollTop - winH + 20 > 0) { - $("#luckysheet-scrollbar-y").scrollTop(row - winH + 20); - } - else if (row_pre - scrollTop - 20 < 0) { - $("#luckysheet-scrollbar-y").scrollTop(row_pre - 20); - } - } + if(has_PartMC){ + break; } } - - return; - } - - let $inputbox = $("#luckysheet-input-box"); - - if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { - if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { - formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); - } - else { - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - Store.luckysheet_select_save = [{ - "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], - "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], - "row_focus": Store.luckysheetCellUpdate[0], - "column_focus": Store.luckysheetCellUpdate[1] - }]; - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - } - //若有参数弹出框,隐藏 - if($("#luckysheet-search-formula-parm").is(":visible")){ - $("#luckysheet-search-formula-parm").hide(); - } - //若有参数选取范围弹出框,隐藏 - if($("#luckysheet-search-formula-parm-select").is(":visible")){ - $("#luckysheet-search-formula-parm-select").hide(); - } - event.preventDefault(); - } - else if (kcode == keycode.TAB) { - if (parseInt($inputbox.css("top")) > 0) { - return; + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; } - - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - event.preventDefault(); } - else if(kcode == keycode.F2){ - if (parseInt($inputbox.css("top")) > 0) { - return; - } - let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + //多重选区 有条件格式时 提示 + let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save; + if(Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0){ + let hasCF = false; - let row_index = last["row_focus"], col_index = last["column_focus"]; - let row = Store.visibledatarow[row_index], - row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; - let col = Store.visibledatacolumn[col_index], - col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + let cf_compute = conditionformat.getComputeMap(); - luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); - event.preventDefault(); - } - else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { - formula.setfreezonFuc(event); - event.preventDefault(); - } - else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.ENTER) { - if($(event.target).hasClass("formulaInputFocus") || $("#luckysheet-conditionformat-dialog").is(":visible")){ - return; - } - else if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible")) { - let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; - - let row_index = last["row_focus"], col_index = last["column_focus"]; - let row = Store.visibledatarow[row_index], - row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; - let col = Store.visibledatacolumn[col_index], - col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; - - let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); - if(!!margeset){ - row = margeset.row[1]; - row_pre = margeset.row[0]; - row_index = margeset.row[2]; - col = margeset.column[1]; - col_pre = margeset.column[0]; - col_index = margeset.column[2]; + label: + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + if(hasCF){ + break; } + + let r1 = Store.luckysheet_select_save[s].row[0], + r2 = Store.luckysheet_select_save[s].row[1]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; - luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); - event.preventDefault(); - } - } - else { - if (ctrlKey || event.metaKey) { - if (shiftKey) { - if (!luckysheet_shiftkeydown) { - Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); - Store.luckysheet_shiftkeydown = true; - } - - //Ctrl + shift + 方向键 调整选区 - if (kcode == keycode.UP) { - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightRange2("up", "rangeOfSelect"); - } - else if (kcode == keycode.DOWN) { - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightRange2("down", "rangeOfSelect"); - } - else if (kcode == keycode.LEFT) { - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; + for(let r = r1; r <= r2; r++){ + for(let c = c1; c <= c2; c++){ + if(conditionformat.checksCF(r, c, cf_compute) != null){ + hasCF = true; + continue label; } - - luckysheetMoveHighlightRange2("left", "rangeOfSelect"); } - else if (kcode == keycode.RIGHT) { - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } + } + } - luckysheetMoveHighlightRange2("right", "rangeOfSelect"); - } + if(hasCF){ + if(isEditMode()){ + alert(locale_drag.noMulti); } - else if (kcode == 66) {//Ctrl + B 加粗 - $("#luckysheet-icon-bold").click(); + else{ + tooltip.info(locale_drag.noMulti, ""); } - else if (kcode == 67) {//Ctrl + C 复制 - //复制时存在格式刷状态,取消格式刷 - if(menuButton.luckysheetPaintModelOn){ - menuButton.cancelPaintModel(); - } - - if(Store.luckysheet_select_save.length == 0){ - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; + return; + } + } - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; + //多重选区 行不一样且列不一样时 提示 + if(Store.luckysheet_select_save.length > 1){ + let isSameRow = true, + str_r = Store.luckysheet_select_save[0].row[0], + end_r = Store.luckysheet_select_save[0].row[1]; + let isSameCol = true, + str_c = Store.luckysheet_select_save[0].column[0], + end_c = Store.luckysheet_select_save[0].column[1]; + + for(let s = 1; s < Store.luckysheet_select_save.length; s++){ + if(Store.luckysheet_select_save[s].row[0] != str_r || Store.luckysheet_select_save[s].row[1] != end_r){ + isSameRow = false; + } + if(Store.luckysheet_select_save[s].column[0] != str_c || Store.luckysheet_select_save[s].column[1] != end_c){ + isSameCol = false; + } + } - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + if((!isSameRow && !isSameCol) || selectIsOverlap()){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + } + + selection.copy(event); + }); - if(has_PartMC){ - break; - } - } + //右键菜单 粘贴按钮 + $("#luckysheet-copy-paste, #luckysheet-cols-paste-btn, #luckysheet-paste-btn-title").click(function (event) { + selection.paste(event, "btn"); + $(this).parent().hide(); + }); - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } + //菜单栏 图表按钮 + $("#luckysheet-chart-btn-title").click(function () { + $("#luckysheetdatavisual").click(); + let chartData = getdatabyselection() + let { render , container } = Store.createChart($('.luckysheet-cell-main')[0] , chartData) - //多重选区 有条件格式时 提示 - let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save; - if(Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0){ - let hasCF = false; + container.style.width = '400px' + container.style.height = '250px' + container.style.position = 'absolute' + container.style.background = '#fff' + container.style.left = Math.random()*100 + 'px' + container.style.top = Math.random()*100 + 'px' + render.style.width = '100%' + render.style.height = '100%' + container.style.zIndex = Store.zIndex + Store.zIndex++ + let chartSetting = document.getElementsByClassName('chartSetting')[0] + chartSetting.style.display = 'block' - let cf_compute = conditionformat.getComputeMap(); + $('.luckysheet-cell-main').click(function(e){ + console.dir(e) + if(e.target.parentNode.parentNode && Array.from(e.target.parentNode.parentNode.classList).includes('jfgrid-modal-dialog-content')){ + Store.highlightChart(e.target.parentNode.parentNode.id) + container.style.zIndex = ++Store.zIndex + chartSetting.style.display = 'block' + }else{ + chartSetting.style.display = 'none' + } + }) + }); - label: - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - if(hasCF){ - break; - } - - let r1 = Store.luckysheet_select_save[s].row[0], - r2 = Store.luckysheet_select_save[s].row[1]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - for(let r = r1; r <= r2; r++){ - for(let c = c1; c <= c2; c++){ - if(conditionformat.checksCF(r, c, cf_compute) != null){ - hasCF = true; - continue label; - } - } - } - } + //菜单栏 数据透视表 + $("#luckysheet-pivot-btn-title").click(function (e) { + pivotTable.createPivotTable(e); + }); - if(hasCF){ - if(isEditMode()){ - alert("无法对多重选择区域执行此操作"); - } - else{ - tooltip.info("无法对多重选择区域执行此操作", ""); - } - return; - } - } + //菜单栏 截图按钮 + $("#luckysheet-chart-btn-screenshot").click(function () { + const locale_screenshot = _locale.screenshot; + if(Store.luckysheet_select_save.length == 0){ + if(isEditMode()){ + alert(locale_screenshot.screenshotTipNoSelection); + } + else{ + tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipNoSelection); + } + return; + } - //多重选区 行不一样且列不一样时 提示 - if(Store.luckysheet_select_save.length > 1){ - let isSameRow = true, - str_r = luckysheet_select_save[0].row[0], - end_r = luckysheet_select_save[0].row[1]; - let isSameCol = true, - str_c = luckysheet_select_save[0].column[0], - end_c = luckysheet_select_save[0].column[1]; - - for(let s = 1; s < luckysheet_select_save.length; s++){ - if(luckysheet_select_save[s].row[0] != str_r || luckysheet_select_save[s].row[1] != end_r){ - isSameRow = false; - } - if(luckysheet_select_save[s].column[0] != str_c || luckysheet_select_save[s].column[1] != end_c){ - isSameCol = false; - } - } + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_screenshot.screenshotTipHasMulti); + } + else{ + tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMulti); + } - if((!isSameRow && !isSameCol) || selectIsOverlap()){ - if(isEditMode()){ - alert("无法对多重选择区域执行此操作"); - } - else{ - tooltip.info("无法对多重选择区域执行此操作", ""); - } - return; - } - } + return; + } - selection.copy(event); + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; - Store.luckysheet_paste_iscut = false; - luckysheetactiveCell(); + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; - event.stopPropagation(); - return; - } - else if (kcode == 70) {//Ctrl + F 查找 - searchReplace.createDialog(0); - searchReplace.init(); + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - $("#luckysheet-search-replace #searchInput input").focus(); + if(has_PartMC){ + break; } - else if (kcode == 72) {//Ctrl + H 替换 - searchReplace.createDialog(1); - searchReplace.init(); + } - $("#luckysheet-search-replace #searchInput input").focus(); + if(has_PartMC){ + if(isEditMode()){ + alert(locale_screenshot.screenshotTipHasMerge); } - else if (kcode == 73) {//Ctrl + I 斜体 - $("#luckysheet-icon-italic").click(); + else{ + tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMerge); } - else if (kcode == 86) {//Ctrl + V 粘贴 - if(isEditMode()){//此模式下禁用粘贴 - return; - } + return; + } + } - if($(event.target).hasClass("formulaInputFocus")){ - return; - } + let st_r = Store.luckysheet_select_save[0].row[0], + ed_r = Store.luckysheet_select_save[0].row[1]; + let st_c = Store.luckysheet_select_save[0].column[0], + ed_c = Store.luckysheet_select_save[0].column[1]; - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("无法在此处粘贴此内容,请选择粘贴区域的一个单元格,然后再次尝试粘贴"); - } - else{ - tooltip.info("无法在此处粘贴此内容,请选择粘贴区域的一个单元格,然后再次尝试粘贴", ""); - } - return; - } - - selection.isPasteAction = true; - luckysheetactiveCell(); - - event.stopPropagation(); - return; - } - else if (kcode == 88) {//Ctrl + X 剪切 - //复制时存在格式刷状态,取消格式刷 - if(menuButton.luckysheetPaintModelOn){ - menuButton.cancelPaintModel(); - } - - if(Store.luckysheet_select_save.length == 0){ - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(luckysheetConfigsetting.editMode){ - alert("无法对合并单元格执行此操作"); - } - else{ - tooltip.info("无法对合并单元格执行此操作", ""); - } - return; - } - } - - //多重选区时 提示 - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - selection.copy(event); - - Store.luckysheet_paste_iscut = true; - luckysheetactiveCell(); - - event.stopPropagation(); - return; - } - else if (kcode == 90) {//Ctrl + Z 撤销 - controlHistory.redo(event); - luckysheetactiveCell(); - event.stopPropagation(); - return; - } - else if (kcode == 89) {//Ctrl + Y 重做 - controlHistory.undo(event); - luckysheetactiveCell(); - event.stopPropagation(); - return; - } - else if (kcode == keycode.UP) {//Ctrl + up 调整单元格 - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell2("up", "rangeOfSelect"); - } - else if (kcode == keycode.DOWN) {//Ctrl + down 调整单元格 - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell2("down", "rangeOfSelect"); - } - else if (kcode == keycode.LEFT) {//Ctrl + top 调整单元格 - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell2("left", "rangeOfSelect"); - } - else if (kcode == keycode.RIGHT) {//Ctrl + right 调整单元格 - if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell2("right", "rangeOfSelect"); - } - else if (String.fromCharCode(kcode).toLocaleUpperCase() == "A") {//Ctrl + A 全选 - $("#luckysheet-left-top").trigger("mousedown"); - $(document).trigger("mouseup"); - } - - event.preventDefault(); - return; - } - else if (shiftKey && (kcode == keycode.UP || kcode == keycode.DOWN || kcode == keycode.LEFT || kcode == keycode.RIGHT || (altKey && (kcode == 53 || kcode == 101)))) { - if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus")) { - return; - } - - if (!luckysheet_shiftkeydown) { - Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); - Store.luckysheet_shiftkeydown = true; - } - - //shift + 方向键 调整选区 - if (kcode == keycode.UP) { - if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ - return; - } - - luckysheetMoveHighlightRange("down", -1, "rangeOfSelect"); - } - else if (kcode == keycode.DOWN) { - if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ - return; - } - - luckysheetMoveHighlightRange("down", 1, "rangeOfSelect"); - } - else if (kcode == keycode.LEFT) { - if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ - return; - } - - luckysheetMoveHighlightRange("right", -1, "rangeOfSelect"); - } - else if (kcode == keycode.RIGHT) { - if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ - return; - } - - luckysheetMoveHighlightRange("right", 1, "rangeOfSelect"); - } - else if (altKey && (kcode == 53 || kcode == 101)) { - //Alt + Shift + 5(删除线) - $("#luckysheet-icon-strikethrough").click(); - } - - event.preventDefault(); - } - else if (kcode == keycode.ESC) { - if(menuButton.luckysheetPaintModelOn){ - menuButton.cancelPaintModel(); - } - else{ - cleargridelement(event); - event.preventDefault(); - } - - selectHightlightShow(); - } - else if (kcode == keycode.DELETE) { - $("#luckysheet-delete-text").click(); - - event.preventDefault(); - } - else if (kcode == keycode.UP) { - if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.DOWN) { - if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.LEFT) { - if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.RIGHT) { - if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { - return; - } - - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - event.preventDefault(); - } - else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || kcode == 0 || (event.ctrlKey && kcode == 86)) { - if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible") && (kcode != keycode.CAPSLOCK && kcode != keycode.WIN && kcode != 18)) { - let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; - - let row_index = last["row_focus"], col_index = last["column_focus"]; - let row = Store.visibledatarow[row_index], - row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; - let col = Store.visibledatacolumn[col_index], - col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; - - let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); - if(!!margeset){ - row = margeset.row[1]; - row_pre = margeset.row[0]; - row_index = margeset.row[2]; - col = margeset.column[1]; - col_pre = margeset.column[0]; - col_index = margeset.column[2]; - } + let shotData = datagridgrowth([], ed_r + 1, ed_c + 1); - luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, true); - if(kcode == 8){ - $("#luckysheet-rich-text-editor").html("
    "); - } - formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); - } + for(let r = st_r; r <= ed_r; r++){ + for(let c = st_c; c <= ed_c; c++){ + shotData[r][c] = Store.flowdata[r][c]; } } - - luckysheetactiveCell(); - - event.stopPropagation(); - }); - - //右键菜单 复制按钮 - $("#luckysheet-copy-btn, #luckysheet-cols-copy-btn, #luckysheet-paste-btn-title").click(function (event) { - $(this).parent().hide(); - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } + let scrollHeight, rh_height; + if(st_r - 1 < 0){ + scrollHeight = 0; + rh_height = Store.visibledatarow[ed_r]; + } + else{ + scrollHeight = Store.visibledatarow[st_r - 1]; + rh_height = Store.visibledatarow[ed_r] - Store.visibledatarow[st_r - 1]; } - //多重选区 有条件格式时 提示 - let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save; - if(Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0){ - let hasCF = false; + let scrollWidth, ch_width; + if(st_c - 1 < 0){ + scrollWidth = 0; + ch_width = Store.visibledatacolumn[ed_c]; + } + else{ + scrollWidth = Store.visibledatacolumn[st_c - 1]; + ch_width = Store.visibledatacolumn[ed_c] - Store.visibledatacolumn[st_c - 1]; + } - let cf_compute = conditionformat.getComputeMap(); + let newCanvas = $("").attr({ + width: Math.ceil(ch_width * devicePixelRatio), + height: Math.ceil(rh_height * devicePixelRatio) + }).css({ width: ch_width, height: rh_height }); - label: - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - if(hasCF){ - break; - } - - let r1 = Store.luckysheet_select_save[s].row[0], - r2 = Store.luckysheet_select_save[s].row[1]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; + let d = Store.flowdata; + Store.flowdata = shotData; - for(let r = r1; r <= r2; r++){ - for(let c = c1; c <= c2; c++){ - if(conditionformat.checksCF(r, c, cf_compute) != null){ - hasCF = true; - continue label; - } - } - } - } + luckysheetDrawMain(scrollWidth, scrollHeight, ch_width, rh_height, 1, 1, null, null, newCanvas); - if(hasCF){ - if(isEditMode()){ - alert("无法对多重选择区域执行此操作"); - } - else{ - tooltip.info("无法对多重选择区域执行此操作", ""); - } - return; - } - } + Store.flowdata = d; + editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据 - //多重选区 行不一样且列不一样时 提示 - if(Store.luckysheet_select_save.length > 1){ - let isSameRow = true, - str_r = Store.luckysheet_select_save[0].row[0], - end_r = Store.luckysheet_select_save[0].row[1]; - let isSameCol = true, - str_c = Store.luckysheet_select_save[0].column[0], - end_c = Store.luckysheet_select_save[0].column[1]; - - for(let s = 1; s < Store.luckysheet_select_save.length; s++){ - if(Store.luckysheet_select_save[s].row[0] != str_r || Store.luckysheet_select_save[s].row[1] != end_r){ - isSameRow = false; - } - if(Store.luckysheet_select_save[s].column[0] != str_c || Store.luckysheet_select_save[s].column[1] != end_c){ - isSameCol = false; - } - } + let image = new Image(); + let url = newCanvas.get(0).toDataURL("image/png"); + image.src = url; - if((!isSameRow && !isSameCol) || selectIsOverlap()){ - if(isEditMode()){ - alert("无法对多重选择区域执行此操作"); - } - else{ - tooltip.info("无法对多重选择区域执行此操作", ""); - } - return; - } + if(ch_width > rh_height){ + image.style.width = "100%"; + } + else{ + image.style.height = "100%"; } - - selection.copy(event); - }); - //右键菜单 粘贴按钮 - $("#luckysheet-copy-paste, #luckysheet-cols-paste-btn, #luckysheet-paste-btn-title").click(function (event) { - selection.paste(event, "btn"); - $(this).parent().hide(); - }); - - //菜单栏 图表按钮 - $("#luckysheet-chart-btn-title").click(function () { - $("#luckysheetdatavisual").click(); - let chartData = getdatabyselection() - let { render , container } = Store.createChart($('.luckysheet-cell-main')[0] , chartData) - - container.style.width = '400px' - container.style.height = '250px' - container.style.position = 'absolute' - container.style.background = '#fff' - container.style.left = Math.random()*100 + 'px' - container.style.top = Math.random()*100 + 'px' - render.style.width = '100%' - render.style.height = '100%' - container.style.zIndex = Store.zIndex - Store.zIndex++ - let chartSetting = document.getElementsByClassName('chartSetting')[0] - chartSetting.style.display = 'block' - - $('.luckysheet-cell-main').click(function(e){ - console.dir(e) - if(e.target.parentNode.parentNode && Array.from(e.target.parentNode.parentNode.classList).includes('jfgrid-modal-dialog-content')){ - Store.highlightChart(e.target.parentNode.parentNode.id) - container.style.zIndex = ++Store.zIndex - chartSetting.style.display = 'block' - }else{ - chartSetting.style.display = 'none' - } - }) - }); - - //菜单栏 数据透视表 - $("#luckysheet-pivot-btn-title").click(function (e) { - pivotTable.createPivotTable(e); - }); - - //菜单栏 截图按钮 - $("#luckysheet-chart-btn-screenshot").click(function () { - const _locale = locale(); - const locale_screenshot = _locale.screenshot; - if(Store.luckysheet_select_save.length == 0){ - if(isEditMode()){ - alert(locale_screenshot.screenshotTipNoSelection); - } - else{ - tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipNoSelection); - } - return; - } - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert(locale_screenshot.screenshotTipHasMulti); - } - else{ - tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMulti); - } - - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert(locale_screenshot.screenshotTipHasMerge); - } - else{ - tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMerge); - } - return; - } - } - - let st_r = Store.luckysheet_select_save[0].row[0], - ed_r = Store.luckysheet_select_save[0].row[1]; - let st_c = Store.luckysheet_select_save[0].column[0], - ed_c = Store.luckysheet_select_save[0].column[1]; - - let shotData = datagridgrowth([], ed_r + 1, ed_c + 1); - - for(let r = st_r; r <= ed_r; r++){ - for(let c = st_c; c <= ed_c; c++){ - shotData[r][c] = Store.flowdata[r][c]; - } - } - - let scrollHeight, rh_height; - if(st_r - 1 < 0){ - scrollHeight = 0; - rh_height = Store.visibledatarow[ed_r]; - } - else{ - scrollHeight = Store.visibledatarow[st_r - 1]; - rh_height = Store.visibledatarow[ed_r] - Store.visibledatarow[st_r - 1]; - } - - let scrollWidth, ch_width; - if(st_c - 1 < 0){ - scrollWidth = 0; - ch_width = Store.visibledatacolumn[ed_c]; - } - else{ - scrollWidth = Store.visibledatacolumn[st_c - 1]; - ch_width = Store.visibledatacolumn[ed_c] - Store.visibledatacolumn[st_c - 1]; - } - - let newCanvas = $("").attr({ - width: Math.ceil(ch_width * devicePixelRatio), - height: Math.ceil(rh_height * devicePixelRatio) - }).css({ width: ch_width, height: rh_height }); - - let d = Store.flowdata; - Store.flowdata = shotData; - - luckysheetDrawMain(scrollWidth, scrollHeight, ch_width, rh_height, 1, 1, null, null, newCanvas); - - Store.flowdata = d; - editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据 - - let image = new Image(); - let url = newCanvas.get(0).toDataURL("image/png"); - image.src = url; - - if(ch_width > rh_height){ - image.style.width = "100%"; - } - else{ - image.style.height = "100%"; - } - - let maxHeight = $(window).height() - 200; - tooltip.screenshot(locale_screenshot.screenshotTipSuccess, '
    ', url); - $("#luckysheet-confirm-screenshot-save").append(image); - newCanvas.remove(); + let maxHeight = $(window).height() - 200; + tooltip.screenshot(locale_screenshot.screenshotTipSuccess, '
    ', url); + $("#luckysheet-confirm-screenshot-save").append(image); + newCanvas.remove(); }); //截图下载 $(document).on("click", "a.download", function(){ let dataURI = $("#luckysheet-confirm-screenshot-save img").attr("src"); - const _locale = locale(); const locale_screenshot = _locale.screenshot; - let binStr = atob(dataURI.split(",")[1]), - len = binStr.length, - arr = new Uint8Array(len); - - for(let i = 0; i < len; i++){ - arr[i] = binStr.charCodeAt(i); - } - - let blob = new Blob([arr]); - - let element = document.createElement('a'); - element.setAttribute('href', URL.createObjectURL(blob)); - element.setAttribute('download', locale_screenshot.screenshotImageName+'.png'); - - element.style.display = 'none'; - document.body.appendChild(element); - - element.click(); - - let clickHandler; - element.addEventListener('click', clickHandler = function(){ - requestAnimationFrame(function(){ - URL.revokeObjectURL(element.href); - }); - - element.removeAttribute('href'); - element.removeEventListener('click', clickHandler); - }) - - document.body.removeChild(element); - }) - - //菜单栏 分列按钮 - $("#luckysheet-splitColumn-btn-title").click(function(){ - if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ - return; - } - - if(Store.luckysheet_select_save.length > 1){ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - return; - } - - if(Store.luckysheet_select_save[0].column[0] != Store.luckysheet_select_save[0].column[1]){ - tooltip.info("一次只能转换一列数据,选定区域可以有多行,但不能有多列,请在选定单列区域以后再试", ""); - return; - } - - splitColumn.createDialog(); - splitColumn.init(); - }); - - //冻结行列 - $("#luckysheet-freezen-btn-horizontal").click(function () { - if($.trim($(this).text())==locale().freezen.freezenCancel){ - if (luckysheetFreezen.freezenverticaldata != null) { - luckysheetFreezen.cancelFreezenVertical(); - luckysheetFreezen.createAssistCanvas(); - luckysheetrefreshgrid(); - } - - if (luckysheetFreezen.freezenhorizontaldata != null) { - luckysheetFreezen.cancelFreezenHorizontal(); - luckysheetFreezen.createAssistCanvas(); - luckysheetrefreshgrid(); - } - - luckysheetFreezen.scrollAdapt(); - } - else{ - if (luckysheetFreezen.freezenverticaldata != null) { - luckysheetFreezen.cancelFreezenVertical(); - luckysheetFreezen.createAssistCanvas(); - luckysheetrefreshgrid(); - } - - if (luckysheetFreezen.freezenhorizontaldata == null) { - luckysheetFreezen.createFreezenHorizontal(); - luckysheetFreezen.createAssistCanvas(); - } - } - }); - - $("#luckysheet-freezen-btn-vertical").click(function () { - if (luckysheetFreezen.freezenverticaldata != null) { - luckysheetFreezen.cancelFreezenVertical(); - luckysheetrefreshgrid(); - } - else { - luckysheetFreezen.createFreezenVertical(); - } - luckysheetFreezen.createAssistCanvas(); - }); - - //右键菜单 菜单项hover - let submenuhide = null, rightclickmenu = null; - $(".luckysheet-cols-menu .luckysheet-cols-submenu").hover( - function () { - let $t = $(this), attrid = $t.attr("id"), $attr = $("#" + attrid + "_sub"), $con = $t.parent(); - let winW = $(window).width(), winH = $(window).height(); - let menuW = $con.width(), attrH = $attr.height() + 25, attrW = $attr.width() + 5; - let offset = $t.offset(); - let top = offset.top, left = offset.left + menuW; - - if (left + attrW > winW) { - left = offset.left - attrW; - } - - if (top + attrH > winH) { - top = winH - attrH; - } - - $attr.css({ "top": top, "left": left }).show(); - rightclickmenu = $t; - }, - function () { - let $t = $(this), attrid = $t.attr("id"), $attr = $("#" + attrid + "_sub"); - submenuhide = setTimeout(function () { $attr.hide(); }, 200); - } - ); - - $(".luckysheet-rightgclick-menu-sub").hover( - function () { - rightclickmenu.addClass("luckysheet-cols-menuitem-hover"); - clearTimeout(submenuhide); - }, - function () { - rightclickmenu.removeClass("luckysheet-cols-menuitem-hover"); - $(this).hide(); - } - ); - - $("#luckysheet-rightclick-menu input").on("keydown", function (e) { - e.stopPropagation(); - }); - - $("#luckysheet-modal-dialog-mask").on("click dbclick mousedown mousemove mouseup", function (e) { - e.stopPropagation(); - e.preventDefault(); - }); - - let copychange = function () { - if (document.hidden || document.webkitHidden || document.msHidden) { - Store.iscopyself = false; - } - } - - $(document).on("visibilitychange webkitvisibilitychange msvisibilitychange", copychange).mouseleave(function () { - Store.iscopyself = false; - }).mousedown(function (event) { - //有批注在编辑时 - luckysheetPostil.removeActivePs(); - - if (!$(event.target).hasClass("luckysheet-mousedown-cancel") && $(event.target).filter("[class*='sp-palette']").length == 0 && $(event.target).filter("[class*='sp-thumb']").length == 0 && $(event.target).filter("[class*='sp-']").length == 0) { - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-cols-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide(); - $("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide(); - //$("body > luckysheet-menuButton").hide(); - Store.luckysheet_cols_menu_status = false; - } - - //点击功能栏时 如果是单元格编辑模式 则退出编辑模式 - if($(event.target).closest("#luckysheet-wa-editor").length > 0 && parseInt($("#luckysheet-input-box").css("top")) > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - } - }); - - //单元格编辑 keydown (公式 上下左右键移动) - $("#" + Store.container).add("#luckysheet-input-box").keydown(function (event) { - if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { - return; - } - - let ctrlKey = event.ctrlKey; - let altKey = event.altKey; - let shiftKey = event.shiftKey; - let kcode = event.keyCode; - - let $inputbox = $("#luckysheet-input-box"); - if (kcode == keycode.ESC && parseInt($("#luckysheet-input-box").css("top")) > 0) { - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { - if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { - formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); - event.preventDefault(); - } - } - else if(kcode == keycode.TAB && parseInt($inputbox.css("top")) > 0){ - if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { - formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); - } - else{ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - } - - event.preventDefault(); - } - else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { - formula.setfreezonFuc(event); - event.preventDefault(); - } - else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { - formulaMoveEvent("up", ctrlKey, shiftKey); - } - else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { - formulaMoveEvent("down", ctrlKey, shiftKey); - } - else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { - formulaMoveEvent("left", ctrlKey, shiftKey); - } - else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { - formulaMoveEvent("right", ctrlKey, shiftKey); - } - else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { - formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); - } - }).keyup(function (e) { - let kcode = e.keyCode; - - if (!e.shiftKey && kcode == 16) { - Store.luckysheet_shiftkeydown = false; - Store.luckysheet_shiftpositon = null; - } - - //输入框中文输入后 shift 和 空格 处理 - if(parseInt($("#luckysheet-input-box").css("top")) > 0 && (kcode == 13 || kcode == 16 || kcode == 32)){ - formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); - } - - e.preventDefault(); - }); - - function formulaMoveEvent(dir, ctrlKey, shiftKey){ - if ($("#luckysheet-formula-search-c").is(":visible")) { - let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); - if ($up.length == 0) { - $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); - } - - $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); - $up.addClass("luckysheet-formula-search-item-active"); - - event.preventDefault(); - } - else{ - if($("#luckysheet-formula-functionrange-select").is(":visible")){ - if(ctrlKey && shiftKey){ - luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); - } - else if(ctrlKey){ - luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); - } - else if(shiftKey){ - let dir_n = dir, step = 1; - if(dir == 'up'){ - dir_n = 'down'; - step = -1; - } - if(dir == 'left'){ - dir_n = 'right'; - step = -1; - } - - luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); - } - else{ - let dir_n = dir, step = 1; - if(dir == 'up'){ - dir_n = 'down'; - step = -1; - } - if(dir == 'left'){ - dir_n = 'right'; - step = -1; - } - - luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); - } - } - else if(formula.israngeseleciton()){ - let anchor = $(window.getSelection().anchorNode); - - if(anchor.parent().next().text() == null || anchor.parent().next().text() == ""){ - let vText = $("#luckysheet-input-box #luckysheet-input-box-index").text(); - let range = formula.getcellrange(vText); - - if(range == null){ - range = formula.getcellrange($("#luckysheet-input-box-index").text()); - } - - let r1 = range["row"][0], r2 = range["row"][1]; - let c1 = range["column"][0], c2 = range["column"][1]; - - let row = Store.visibledatarow[r2], - row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; - let col = Store.visibledatacolumn[c2], - col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; - - formula.func_selectedrange = { - "left": col_pre, - "width": col - col_pre - 1, - "top": row_pre, - "height": row - row_pre - 1, - "left_move": col_pre, - "width_move": col - col_pre - 1, - "top_move": row_pre, - "height_move": row - row_pre - 1, - "row": [r1, r2], - "column": [c1, c2], - "row_focus": r1, - "column_focus": c1 - }; - - formula.rangeSetValue({ "row": [r1, r2], "column": [c1, c2] }); - - formula.rangestart = true; - formula.rangedrag_column_start = false; - formula.rangedrag_row_start = false; - - if(ctrlKey && shiftKey){ - luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); - } - else if(ctrlKey){ - luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); - } - else if(shiftKey){ - let dir_n = dir, step = 1; - if(dir == 'up'){ - dir_n = 'down'; - step = -1; - } - if(dir == 'left'){ - dir_n = 'right'; - step = -1; - } - - luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); - } - else{ - let dir_n = dir, step = 1; - if(dir == 'up'){ - dir_n = 'down'; - step = -1; - } - if(dir == 'left'){ - dir_n = 'right'; - step = -1; - } - - luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); - } - } - } - else if(!ctrlKey && !shiftKey){ - let anchor = $(window.getSelection().anchorNode); - let anchorOffset = window.getSelection().anchorOffset; - - if(dir == 'up'){ - if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); - - event.preventDefault(); - } - } - else if(dir == 'down'){ - if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - - event.preventDefault(); - } - } - else if(dir == 'left'){ - if(anchor.parent().is("span") && anchor.parent().prev().length == 0 && anchorOffset == 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.is("#luckysheet-rich-text-editor") && anchorOffset == 1){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchorOffset == 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); - - event.preventDefault(); - } - } - else if(dir == 'right'){ - if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - - event.preventDefault(); - } - else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); - - event.preventDefault(); - } - } - } - } - } - - //表格左上角点击 全选表格 - $("#luckysheet-left-top").mousedown(function (event) { - $("#luckysheet-wa-functionbox-confirm").click(); - Store.luckysheet_select_status = false; - - Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0 }]; - selectHightlightShow(); - - clearTimeout(Store.countfuncTimeout); - Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500); - - event.stopPropagation(); - }); - - //表格行标题 mouse事件 - $("#luckysheet-rows-h").mousedown(function (event) { - //有批注在编辑时 - luckysheetPostil.removeActivePs(); - - let mouse = mouseposition(event.pageX, event.pageY); - let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); - - let row_location = rowLocation(y), - row = row_location[1], - row_pre = row_location[0], - row_index = row_location[2]; - let col_index = Store.visibledatacolumn.length - 1, - col = Store.visibledatacolumn[col_index], col_pre = 0; - - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - - //mousedown是右键 - if (event.which == "3") { - let isright = false; - - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - let obj_s = Store.luckysheet_select_save[s]; - - if(obj_s["row"] != null && (row_index >= obj_s["row"][0] && row_index <= obj_s["row"][1]) && (obj_s["column"][0] == 0 && obj_s["column"][1] == Store.flowdata[0].length - 1)){ - isright = true; - break; - } - } - - if(isright){ - return; - } - } - - let top = row_pre, height = row - row_pre - 1; - let rowseleted = [row_index, row_index]; - - Store.luckysheet_scroll_status = true; - - //公式相关 - let $input = $("#luckysheet-input-box"); - if (parseInt($input.css("top")) > 0) { - if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton() || $("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) { - //公式选区 - let changeparam = menuButton.mergeMoveMain([0, col_index], rowseleted, {"row_focus": row_index, "column_focus": 0}, top, height, col_pre, col); - if(changeparam != null){ - //columnseleted = changeparam[0]; - rowseleted = changeparam[1]; - top = changeparam[2]; - height = changeparam[3]; - //left = changeparam[4]; - //width = changeparam[5]; - } - - if(event.shiftKey){ - let last = formula.func_selectedrange; - - let top = 0, height = 0, rowseleted = []; - if (last.top > row_pre) { - top = row_pre; - height = last.top + last.height - row_pre; - - if(last.row[1] > last.row_focus){ - last.row[1] = last.row_focus; - } - - rowseleted = [row_index, last.row[1]]; - } - else if (last.top == row_pre) { - top = row_pre; - height = last.top + last.height - row_pre; - rowseleted = [row_index, last.row[0]]; - } - else { - top = last.top; - height = row - last.top - 1; - - if(last.row[0] < last.row_focus){ - last.row[0] = last.row_focus; - } - - rowseleted = [last.row[0], row_index]; - } - - let changeparam = menuButton.mergeMoveMain([0, col_index], rowseleted, {"row_focus": row_index, "column_focus": 0}, top, height, col_pre, col); - if(changeparam != null){ - // columnseleted = changeparam[0]; - rowseleted = changeparam[1]; - top = changeparam[2]; - height = changeparam[3]; - // left = changeparam[4]; - // width = changeparam[5]; - } - - last["row"] = rowseleted; - - last["top_move"] = top; - last["height_move"] = height; - - formula.func_selectedrange = last; - } - else if(event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ","){ - //按住ctrl 选择选区时 先处理上一个选区 - let vText = $("#luckysheet-rich-text-editor").text() + ","; - if(vText.length > 0 && vText.substr(0, 1) == "="){ - vText = formula.functionHTMLGenerate(vText); - - if (window.getSelection) { // all browsers, except IE before version 9 - let currSelection = window.getSelection(); - formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset]; - } - else { // Internet Explorer before version 9 - let textRange = document.selection.createRange(); - formula.functionRangeIndex = textRange; - } - - $("#luckysheet-rich-text-editor").html(vText); - - formula.canceFunctionrangeSelected(); - formula.createRangeHightlight(); - } - - formula.rangestart = false; - formula.rangedrag_column_start = false; - formula.rangedrag_row_start = false; - - $("#luckysheet-functionbox-cell").html(vText); - formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); - - //再进行 选区的选择 - formula.israngeseleciton(); - formula.func_selectedrange = { - "left": colLocationByIndex(0)[0], - "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, - "top": top, - "height": height, - "left_move": col_pre, - "width_move": col - col_pre - 1, - "top_move": top, - "height_move": height, - "row": rowseleted, - "column": [0, col_index], - "row_focus": row_index, - "column_focus": 0 - } - } - else{ - formula.func_selectedrange = { - "left": colLocationByIndex(0)[0], - "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, - "top": top, - "height": height, - "left_move": col_pre, - "width_move": col - col_pre - 1, - "top_move": top, - "height_move": height, - "row": rowseleted, - "column": [0, col_index], - "row_focus": row_index, - "column_focus": 0 - } - } - - if(formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()){ - formula.rangeSetValue({ "row": rowseleted, "column": [null, null] }); - } - else if($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")){//if公式生成器 - let range = getRangetxt(Store.currentSheetIndex, { "row": rowseleted, "column": [0, col_index] }, Store.currentSheetIndex); - $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range); - } - - formula.rangedrag_row_start = true; - formula.rangestart = false; - formula.rangedrag_column_start = false; - - $("#luckysheet-formula-functionrange-select").css({ - "left": col_pre, - "width": col - col_pre - 1, - "top": top, - "height": height - }).show(); - $("#luckysheet-formula-help-c").hide(); - - luckysheet_count_show(col_pre, top, col - col_pre - 1, height, rowseleted, [0, col_index]); - - setTimeout(function(){ - let currSelection = window.getSelection(); - let anchorOffset = currSelection.anchorNode; - - let $editor; - if($("#luckysheet-search-formula-parm").is(":visible")||$("#luckysheet-search-formula-parm-select").is(":visible")){ - $editor = $("#luckysheet-rich-text-editor"); - formula.rangechangeindex = formula.data_parm_index; - } - else{ - $editor = $(anchorOffset).closest("div"); - } - - let $span = $editor.find("span[rangeindex='" + formula.rangechangeindex + "']"); - - formula.setCaretPosition($span.get(0), 0, $span.html().length); - }, 1); - - return; - } - else { - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - Store.luckysheet_rows_selected_status = true; - } - } - else { - Store.luckysheet_rows_selected_status = true; - } - - if (Store.luckysheet_rows_selected_status) { - if(event.shiftKey){ - //按住shift点击行索引选取范围 - let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个 - - let top = 0, height = 0, rowseleted = []; - if (last.top > row_pre) { - top = row_pre; - height = last.top + last.height - row_pre; - - if(last.row[1] > last.row_focus){ - last.row[1] = last.row_focus; - } - - rowseleted = [row_index, last.row[1]]; - } - else if (last.top == row_pre) { - top = row_pre; - height = last.top + last.height - row_pre; - rowseleted = [row_index, last.row[0]]; - } - else { - top = last.top; - height = row - last.top - 1; - - if(last.row[0] < last.row_focus){ - last.row[0] = last.row_focus; - } - - rowseleted = [last.row[0], row_index]; - } - - last["row"] = rowseleted; - - last["top_move"] = top; - last["height_move"] = height; - - Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last; - } - else if(event.ctrlKey){ - Store.luckysheet_select_save.push({ - "left": colLocationByIndex(0)[0], - "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, - "top": top, - "height": height, - "left_move": col_pre, - "width_move": col - col_pre - 1, - "top_move": top, - "height_move": height, - "row": rowseleted, - "column": [0, col_index], - "row_focus": row_index, - "column_focus": 0 - }); - } - else{ - Store.luckysheet_select_save = []; - Store.luckysheet_select_save.push({ - "left": colLocationByIndex(0)[0], - "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, - "top": top, - "height": height, - "left_move": col_pre, - "width_move": col - col_pre - 1, - "top_move": top, - "height_move": height, - "row": rowseleted, - "column": [0, col_index], - "row_focus": row_index, - "column_focus": 0 - }); - } - - selectHightlightShow(); - - if(server.allowUpdate){ - //允许编辑后的后台更新时 - server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save); - } - } - - $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1])); - - setTimeout(function () { - clearTimeout(Store.countfuncTimeout); - countfunc(); - }, 101); - }).mousemove(function (event) { - if (Store.luckysheet_rows_selected_status || Store.luckysheet_rows_change_size || Store.luckysheet_select_status) { - $("#luckysheet-rows-h-hover").hide(); - return; - } - - let mouse = mouseposition(event.pageX, event.pageY); - let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); - - let row_location = rowLocation(y), - row = row_location[1], - row_pre = row_location[0], - row_index = row_location[2]; - - $("#luckysheet-rows-h-hover").css({ "top": row_pre, "height": row - row_pre - 1, "display": "block" }); - - if (y < row - 1 && y >= row - 5) { - $("#luckysheet-rows-change-size").css({ "top": row - 3, "opacity": 0 }); - } - else { - $("#luckysheet-rows-change-size").css("opacity", 0); - } - }).mouseleave(function (event) { - $("#luckysheet-rows-h-hover").hide(); - $("#luckysheet-rows-change-size").css("opacity", 0); - }).mouseup(function (event) { - if (event.which == 3) { - if(isEditMode()){ //非编辑模式下禁止右键功能框 - return; - } - - $("#luckysheet-cols-rows-shift").hide(); - Store.luckysheetRightHeadClickIs = "row"; - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.row); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.height); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.top); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.bottom); - - $("#luckysheet-cols-rows-add").show(); - $("#luckysheet-cols-rows-data").show(); - $("#luckysheet-cols-rows-shift").hide(); - $("#luckysheet-cols-rows-handleincell").hide(); - - showrightclickmenu($("#luckysheet-rightclick-menu"), $(this).offset().left + 46, event.pageY); - Store.luckysheet_cols_menu_status = true; - - //行高默认值 - let cfg = $.extend(true, {}, Store.config); - if(cfg["rowlen"] == null){ - cfg["rowlen"] = {}; - } - - let first_rowlen = cfg["rowlen"][Store.luckysheet_select_save[0].row[0]] == null ? Store.defaultrowlen : cfg["rowlen"][Store.luckysheet_select_save[0].row[0]]; - let isSame = true; - - for(let i = 0; i < Store.luckysheet_select_save.length; i++){ - let s = Store.luckysheet_select_save[i]; - let r1 = s.row[0], r2 = s.row[1]; - - for(let r = r1; r <= r2; r++){ - let rowlen = cfg["rowlen"][r] == null ? Store.defaultrowlen : cfg["rowlen"][r]; - - if(rowlen != first_rowlen){ - isSame = false; - break; - } - } - } - - if(isSame){ - $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_rowlen); - } - else{ - $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(""); - } - } - }); - - //表格列标题 mouse事件 - $("#luckysheet-cols-h-c").mousedown(function (event) { - //有批注在编辑时 - luckysheetPostil.removeActivePs(); - - let mouse = mouseposition(event.pageX, event.pageY); - let x = mouse[0] + $(this).scrollLeft(); - - let row_index = Store.visibledatarow.length - 1, - row = Store.visibledatarow[row_index], row_pre = 0; - let col_location = colLocation(x), - col = col_location[1], - col_pre = col_location[0], - col_index = col_location[2]; - - Store.orderbyindex = col_index;//排序全局函数 - - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - - //mousedown是右键 - if (event.which == "3") { - let isright = false; - - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - let obj_s = Store.luckysheet_select_save[s]; - - if(obj_s["column"] != null && (col_index >= obj_s["column"][0] && col_index <= obj_s["column"][1]) && (obj_s["row"][0] == 0 && obj_s["row"][1] == Store.flowdata.length - 1)){ - isright = true; - break; - } - } - - if(isright){ - return; - } - } - - let left = col_pre, width = col - col_pre - 1; - let columnseleted = [col_index, col_index]; - - Store.luckysheet_scroll_status = true; - - //公式相关 - let $input = $("#luckysheet-input-box"); - if (parseInt($input.css("top")) > 0) { - if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton() || $("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) { - //公式选区 - let changeparam = menuButton.mergeMoveMain(columnseleted, [0, row_index], {"row_focus": 0, "column_focus": col_index}, row_pre, row, left, width); - if(changeparam != null){ - columnseleted = changeparam[0]; - //rowseleted= changeparam[1]; - //top = changeparam[2]; - //height = changeparam[3]; - left = changeparam[4]; - width = changeparam[5]; - } - - if(event.shiftKey){ - let last = formula.func_selectedrange; - - let left = 0, width = 0, columnseleted = []; - if (last.left > col_pre) { - left = col_pre; - width = last.left + last.width - col_pre; - - if(last.column[1] > last.column_focus){ - last.column[1] = last.column_focus; - } - - columnseleted = [col_index, last.column[1]]; - } - else if (last.left == col_pre) { - left = col_pre; - width = last.left + last.width - col_pre; - columnseleted = [col_index, last.column[0]]; - } - else { - left = last.left; - width = col - last.left - 1; - - if(last.column[0] < last.column_focus){ - last.column[0] = last.column_focus; - } - - columnseleted = [last.column[0], col_index]; - } - - let changeparam = menuButton.mergeMoveMain(columnseleted , [0, row_index], {"row_focus": 0, "column_focus": col_index}, row_pre, row, left, width); - if(changeparam != null){ - columnseleted = changeparam[0]; - //rowseleted= changeparam[1]; - //top = changeparam[2]; - //height = changeparam[3]; - left = changeparam[4]; - width = changeparam[5]; - } - - last["column"] = columnseleted; - - last["left_move"] = left; - last["width_move"] = width; - - formula.func_selectedrange = last; - } - else if(event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ","){ - //按住ctrl 选择选区时 先处理上一个选区 - let vText = $("#luckysheet-rich-text-editor").text() + ","; - if(vText.length > 0 && vText.substr(0, 1) == "="){ - vText = formula.functionHTMLGenerate(vText); - - if (window.getSelection) { // all browsers, except IE before version 9 - let currSelection = window.getSelection(); - formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset]; - } - else { // Internet Explorer before version 9 - let textRange = document.selection.createRange(); - formula.functionRangeIndex = textRange; - } - - $("#luckysheet-rich-text-editor").html(vText); - - formula.canceFunctionrangeSelected(); - formula.createRangeHightlight(); - } - - formula.rangestart = false; - formula.rangedrag_column_start = false; - formula.rangedrag_row_start = false; - - $("#luckysheet-functionbox-cell").html(vText); - formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); - - //再进行 选区的选择 - formula.israngeseleciton(); - formula.func_selectedrange = { - "left": left, - "width": width, - "top": rowLocationByIndex(0)[0], - "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, - "left_move": left, - "width_move": width, - "top_move": row_pre, - "height_move": row - row_pre - 1, - "row": [0, row_index], - "column": columnseleted, - "row_focus": 0, - "column_focus": col_index - } - } - else{ - formula.func_selectedrange = { - "left": left, - "width": width, - "top": rowLocationByIndex(0)[0], - "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, - "left_move": left, - "width_move": width, - "top_move": row_pre, - "height_move": row - row_pre - 1, - "row": [0, row_index], - "column": columnseleted, - "row_focus": 0, - "column_focus": col_index - } - } - - if(formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()){ - formula.rangeSetValue({ "row": [null, null], "column": columnseleted }); - } - else if($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")){//if公式生成器 - let range = getRangetxt(Store.currentSheetIndex, { "row": [0, row_index], "column": columnseleted }, Store.currentSheetIndex); - $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range); - } - - formula.rangedrag_column_start = true; - formula.rangestart = false; - formula.rangedrag_row_start = false; - - $("#luckysheet-formula-functionrange-select").css({ - "left": left, - "width": width, - "top": row_pre, - "height": row - row_pre - 1 - }).show(); - $("#luckysheet-formula-help-c").hide(); - - luckysheet_count_show(left, row_pre, width, row - row_pre - 1, [0, row_index], columnseleted); - - return; - } - else { - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - Store.luckysheet_cols_selected_status = true; - } - } - else { - Store.luckysheet_cols_selected_status = true; - } - - if (Store.luckysheet_cols_selected_status) { - if(event.shiftKey){ - //按住shift点击列索引选取范围 - let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个 - - let left = 0, width = 0, columnseleted = []; - if (last.left > col_pre) { - left = col_pre; - width = last.left + last.width - col_pre; - - if(last.column[1] > last.column_focus){ - last.column[1] = last.column_focus; - } - - columnseleted = [col_index, last.column[1]]; - } - else if (last.left == col_pre) { - left = col_pre; - width = last.left + last.width - col_pre; - columnseleted = [col_index, last.column[0]]; - } - else { - left = last.left; - width = col - last.left - 1; - - if(last.column[0] < last.column_focus){ - last.column[0] = last.column_focus; - } - - columnseleted = [last.column[0], col_index]; - } - - last["column"] = columnseleted; - - last["left_move"] = left; - last["width_move"] = width; - - Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last; - } - else if(event.ctrlKey){ - //选区添加 - Store.luckysheet_select_save.push({ - "left": left, - "width": width, - "top": rowLocationByIndex(0)[0], - "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, - "left_move": left, - "width_move": width, - "top_move": row_pre, - "height_move": row - row_pre - 1, - "row": [0, row_index], - "column": columnseleted, - "row_focus": 0, - "column_focus": col_index - }); - } - else{ - Store.luckysheet_select_save = []; - Store.luckysheet_select_save.push({ - "left": left, - "width": width, - "top": rowLocationByIndex(0)[0], - "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, - "left_move": left, - "width_move": width, - "top_move": row_pre, - "height_move": row - row_pre - 1, - "row": [0, row_index], - "column": columnseleted, - "row_focus": 0, - "column_focus": col_index - }); - } - - selectHightlightShow(); - - if(server.allowUpdate){ - //允许编辑后的后台更新时 - server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save); - } - } - - $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1])); - - setTimeout(function () { - clearTimeout(Store.countfuncTimeout); - countfunc(); - }, 101); - - if (Store.luckysheet_cols_menu_status) { - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-cols-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - Store.luckysheet_cols_menu_status = false; - } - event.stopPropagation(); - }).mousemove(function (event) { - if (Store.luckysheet_cols_selected_status || Store.luckysheet_select_status) { - $("#luckysheet-cols-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - return; - } - - if (Store.luckysheet_cols_menu_status || Store.luckysheet_cols_change_size) { - return; - } - - let mouse = mouseposition(event.pageX, event.pageY); - let x = mouse[0] + $("#luckysheet-cols-h-c").scrollLeft(); - - let col_location = colLocation(x), - col = col_location[1], - col_pre = col_location[0], - col_index = col_location[2]; - - $("#luckysheet-cols-h-hover").css({ "left": col_pre, "width": col - col_pre - 1, "display": "block" }); - $("#luckysheet-cols-menu-btn").css({ "left": col - 19, "display": "block" }); - - $("#luckysheet-cols-change-size").css({ "left": col - 5 }); - if (x < col && x >= col - 5) { - $("#luckysheet-cols-change-size").css({ "opacity": 0 }); - $("#luckysheet-cols-menu-btn").hide(); - } - else { - $("#luckysheet-change-size-line").hide(); - $("#luckysheet-cols-change-size").css("opacity", 0); - } - }).mouseleave(function (event) { - if (Store.luckysheet_cols_menu_status || Store.luckysheet_cols_change_size) { - return; - } - - $("#luckysheet-cols-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - $("#luckysheet-cols-change-size").css("opacity", 0); - }).mouseup(function (event) { - if (event.which == 3) { - if(isEditMode()){ //非编辑模式下禁止右键功能框 - return; - } - - Store.luckysheetRightHeadClickIs = "column"; - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.width); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right); - - $("#luckysheet-cols-rows-add").show(); - $("#luckysheet-cols-rows-data").show(); - $("#luckysheet-cols-rows-shift").hide(); - $("#luckysheet-cols-rows-handleincell").hide(); - - showrightclickmenu($("#luckysheet-rightclick-menu"), event.pageX, $(this).offset().top + 18); - Store.luckysheet_cols_menu_status = true; - - //列宽默认值 - let cfg = $.extend(true, {}, Store.config); - if(cfg["columlen"] == null){ - cfg["columlen"] = {}; - } - - let first_collen = cfg["columlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columlen"][Store.luckysheet_select_save[0].column[0]]; - let isSame = true; - - for(let i = 0; i < Store.luckysheet_select_save.length; i++){ - let s = Store.luckysheet_select_save[i]; - let c1 = s.column[0], c2 = s.column[1]; - - for(let c = c1; c <= c2; c++){ - let collen = cfg["columlen"][c] == null ? Store.defaultcollen : cfg["columlen"][c]; - - if(collen != first_collen){ - isSame = false; - break; - } - } - } - - if(isSame){ - $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_collen); - } - else{ - $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(""); - } - } - }); - - //表格列标题 改变列宽按钮 - $("#luckysheet-cols-change-size").mousedown(function (event) { - //有批注在编辑时 - luckysheetPostil.removeActivePs(); - - $("#luckysheet-input-box").hide(); - $("#luckysheet-cols-change-size").css({ "opacity": 1 }); - - let mouse = mouseposition(event.pageX, event.pageY); - let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft(); - let scrollTop = $("#luckysheet-cell-main").scrollTop(); - let winH = $("#luckysheet-cell-main").height(); - let x = mouse[0] + scrollLeft; - - let row_index = Store.visibledatarow.length - 1, - row = Store.visibledatarow[row_index], row_pre = 0; - let col_location = colLocation(x), - col = col_location[1], - col_pre = col_location[0], - col_index = col_location[2]; - - Store.luckysheet_cols_change_size = true; - Store.luckysheet_scroll_status = true; - $("#luckysheet-change-size-line").css({ - "height": winH + scrollTop, - "border-width": "0 1px 0 0", - "top": 0, - "left": col - 3, - "width": "1px", - "display": "block", - "cursor": "ew-resize" - }); - $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "ew-resize"); - Store.luckysheet_cols_change_size_start = [col_pre, col_index]; - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-cols-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - Store.luckysheet_cols_dbclick_times = 0; - event.stopPropagation(); - }).dblclick(function () { - luckysheetcolsdbclick(); - }) - - function luckysheetcolsdbclick() { - Store.luckysheet_cols_change_size = false; - $("#luckysheet-change-size-line").hide(); - $("#luckysheet-cols-change-size").css("opacity", 0); - $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default"); - - let mouse = mouseposition(event.pageX, event.pageY); - let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft(); - let x = mouse[0] + scrollLeft; - let winW = $(window).width(); - - let row_index = Store.visibledatarow.length - 1, - row = Store.visibledatarow[row_index], - row_pre = 0; - let col_location = colLocation(x), - col = col_location[1], - col_pre = col_location[0], - col_index = col_location[2]; - Store.luckysheet_cols_change_size_start = [col_pre, col_index]; - let dataflow = $("#luckysheetTableContent").get(0).getContext("2d"); - let cfg = $.extend(true, {}, Store.config); - - let matchColumn = {}; - 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]; - - if (col_index < c1 || col_index > c2) { - if(col_index in matchColumn){//此列已计算过 - continue; - } - - x = -Infinity; - let countret = 0; - let fontsize = 13; - for (let r = 0; r < Store.flowdata.length; r++) { - if (countret >= 15) { - break; - } - - let value = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata); - let mask = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata, "m"); - - if(mask != null){ - value = mask; - } - - let cell = Store.flowdata[r][Store.luckysheet_cols_change_size_start[1]]; - if(getObjType(cell) == "object" && ("fs" in cell)){ - if(cell.fs > fontsize){ - fontsize = cell.fs; - } - } - - if (value == null || value.toString().length == 0) { - countret++; - continue; - } - let textMetrics = dataflow.measureText(value).width; - if (textMetrics > x) { - x = textMetrics; - } - } - - let size = x + fontsize * 1.5; - if ((x + 3) < 30) { - size = 30; - } - - if (x >= winW - 100 + scrollLeft) { - size = winW - 100 + scrollLeft; - } - - if (cfg["columlen"] == null) { - cfg["columlen"] = {}; - } - - cfg["columlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size); - - matchColumn[col_index] = 1; - } - else { - for (let c = c1; c <= c2; c++) { - if(c in matchColumn){//此列已计算过 - continue; - } - - x = -Infinity; - let countret = 0; - let fontsize = 13; - for (let r = 0; r < Store.flowdata.length; r++) { - if (countret >= 15) { - break; - } - let value = getcellvalue(r, c, Store.flowdata); - - let cell = Store.flowdata[r][c]; - if(getObjType(cell) == "object" && ("fs" in cell)){ - if(cell.fs > fontsize){ - fontsize = cell.fs; - } - } - - if (isRealNull(value)) { - countret++; - continue; - } - - let textMetrics = dataflow.measureText(value).width; - if (textMetrics > x) { - x = textMetrics; - } - } - - let size = x + fontsize*1.5;; - if ((x + 3) < 30) { - size = 30; - } - - if (x >= winW - 100 + scrollLeft) { - size = winW - 100 + scrollLeft; - } - - if (cfg["columlen"] == null) { - cfg["columlen"] = {}; - } - cfg["columlen"][c] = Math.ceil(size); - - matchColumn[c] = 1; - } - } - } - - jfrefreshgridall(Store.flowdata[0].length, Store.flowdata.length, Store.flowdata, cfg, Store.luckysheet_select_save, "resizeC", "columlen"); - } - - //表格行标题 改变行高按钮 - $("#luckysheet-rows-change-size").mousedown(function (event) { - //有批注在编辑时 - luckysheetPostil.removeActivePs(); - - $("#luckysheet-input-box").hide(); - $("#luckysheet-rows-change-size").css({ "opacity": 1 }); - - let mouse = mouseposition(event.pageX, event.pageY); - let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); - - let scrollLeft = $("#luckysheet-cell-main").scrollLeft(); - let winW = $("#luckysheet-cell-main").width(); - - let row_location = rowLocation(y), - row = row_location[1], - row_pre = row_location[0], - row_index = row_location[2]; - - Store.luckysheet_rows_change_size = true; - Store.luckysheet_scroll_status = true; - $("#luckysheet-change-size-line").css({ - "height": "1px", - "border-width": - "0 0px 1px 0", - "top": row - 3, - "left": 0, - "width": scrollLeft + winW, - "display": "block", - "cursor": "ns-resize" - }); - $("#luckysheet-sheettable, #luckysheet-rows-h, #luckysheet-rows-h canvas").css("cursor", "ns-resize"); - Store.luckysheet_rows_change_size_start = [row_pre, row_index]; - $("#luckysheet-rightclick-menu").hide(); - $("#luckysheet-rows-h-hover").hide(); - $("#luckysheet-cols-menu-btn").hide(); - event.stopPropagation(); - }); - - $("#luckysheet-cols-menu-btn").click(function (event) { - let $menu = $("#luckysheet-rightclick-menu"); - let offset = $(this).offset(); - $("#luckysheet-cols-rows-shift").show(); - Store.luckysheetRightHeadClickIs = "column"; - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left); - $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right); - - $("#luckysheet-cols-rows-add").show(); - $("#luckysheet-cols-rows-data").hide(); - $("#luckysheet-cols-rows-shift").show(); - $("#luckysheet-cols-rows-handleincell").hide(); - - showrightclickmenu($menu, offset.left, offset.top + 18); - Store.luckysheet_cols_menu_status = true; - }); - - //菜单栏 排序按钮 - $("#luckysheetorderbyasc, #luckysheetorderbyasc_t").mousedown(function (event) { - cleargridelement(event); - sortColumnSeletion(Store.orderbyindex, true); - selectHightlightShow(); - }); - - $("#luckysheetorderbydesc, #luckysheetorderbydesc_t").click(function (event) { - cleargridelement(event); - sortColumnSeletion(Store.orderbyindex, false); - selectHightlightShow(); - }); - - //右键功能键 - //复制为json格式字符串,首行为标题 - $("#luckysheet-copy-json-head").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - - if (getdata.length == 1) { - let obj = {}; - for (let i = 0; i < getdata[0].length; i++) { - obj[getcellvalue(0, i, getdata)] = ""; - } - arr.push(obj); - } - else { - for (let r = 1; r < getdata.length; r++) { - let obj = {}; - for (let c = 0; c < getdata[0].length; c++) { - if(getcellvalue(0, c, getdata) == undefined){ - obj[""] = getcellvalue(r, c, getdata); - }else{ - obj[getcellvalue(0, c, getdata)] = getcellvalue(r, c, getdata); - } - } - arr.push(obj); - } - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为json格式字符串,无标题,采用ABCD作为标题 - $("#luckysheet-copy-json-nohead").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - let st = Store.luckysheet_select_save[0]["column"][0]; - for (let r = 0; r < getdata.length; r++) { - let obj = {}; - for (let c = 0; c < getdata[0].length; c++) { - obj[chatatABC(c + st)] = getcellvalue(r, c, getdata); - } - arr.push(obj); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为一维数组 - $("#luckysheet-copy-array1").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - for (let r = 0; r < getdata.length; r++) { - for (let c = 0; c < getdata[0].length; c++) { - arr.push(getcellvalue(r, c, getdata)); - } - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为二维数组 - $("#luckysheet-copy-array2").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - for (let r = 0; r < getdata.length; r++) { - let a = []; - for (let c = 0; c < getdata[0].length; c++) { - a.push(getcellvalue(r, c, getdata)); - } - arr.push(a); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为多维数组 - $("#luckysheet-copy-arraymore-confirm").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - - for (let r = 0; r < getdata.length; r++) { - for (let c = 0; c < getdata[0].length; c++) { - arr.push(getdata[r][c]); - } - } - - let row = $("#luckysheet-copy-arraymore-row").val(), col = $("#luckysheet-copy-arraymore-col").val(); - - if (row == "" && col == "") { - selection.copybyformat(event, JSON.stringify(arr)); - $("body .luckysheet-cols-menu").hide(); - return; - } - - if (row == "") { - row = 1; - } - else { - row = parseInt(row); - if (row == null) { - row = 1; - } - } - - if (col == "") { - col = 1; - } - else { - col = parseInt(col); - if (col == null) { - col = 1; - } - } - - if(row.toString() == "NaN" || col.toString() == "NaN"){ - if(isEditMode()){ - alert("请输入正确的数值!"); - } - else{ - tooltip.info("请输入正确的数值!", ""); - } - return; - } - - if(row < 1 || col < 1){ - if(isEditMode()){ - alert("行列数不能小于1!"); - } - else{ - tooltip.info("行列数不能小于1!", ""); - } - return; - } - - let arrlen = arr.length, i = 0, ret = []; - for (let r = 0; r < row; r++) { - let a = []; - for (let c = 0; c < col; c++) { - a.push(arr[i++]); - if (i >= arrlen) { - selection.copybyformat(event, JSON.stringify(ret)); - $("body .luckysheet-cols-menu").hide(); - return; - } - } - ret.push(a); - } - - selection.copybyformat(event, JSON.stringify(ret)); - }); - - //复制为对角线 - $("#luckysheet-copy-diagonal").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - - let clen = getdata[0].length; - for (let r = 0; r < getdata.length; r++) { - if (r >= clen) { - break; - } - arr.push(getdata[r][r]); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为反对角线 - $("#luckysheet-copy-antidiagonal").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - - let clen = getdata[0].length; - for (let r = 0; r < getdata.length; r++) { - if (r >= clen) { - break; - } - arr.push(getdata[r][clen - r - 1]); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为对角偏移n列 - $("#luckysheet-copy-diagonaloffset").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - - let clen = getdata[0].length, - offset = parseInt($("#luckysheet-copy-diagonaloffset-value").val()); - - if(offset.toString() == "NaN"){ - if(isEditMode()){ - alert("请输入正确的数值!"); - } - else{ - tooltip.info("请输入正确的数值!", ""); - } - return; - } - - if(offset < 0){ - if(isEditMode()){ - alert("偏移列不能为负数!"); - } - else{ - tooltip.info("偏移列不能为负数!", ""); - } - return; - } - - if (offset == null) { - offset = 1; - } - - for (let r = 0; r < getdata.length; r++) { - if (r + offset >= clen) { - break; - } - arr.push(getdata[r][r + offset]); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //复制为布尔值 - $("#luckysheet-copy-boolvalue").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - //复制范围内包含部分合并单元格,提示 - if(Store.config["merge"] != null){ - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); - - if(has_PartMC){ - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - return; - } - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - let arr = []; - if (getdata.length == 0) { - return; - } - for (let r = 0; r < getdata.length; r++) { - let a = []; - for (let c = 0; c < getdata[0].length; c++) { - let bool = false; - - if(getObjType(getdata[r][c]) == "object"){ - let v = getdata[r][c].v; - } - else{ - let v = getdata[r][c]; - } - - if (v == null || v == "") { - bool = false; - } - else { - v = parseInt(v); - if (v == null || v > 0) { - bool = true; - } - else { - bool = false; - } - } - a.push(bool); - } - arr.push(a); - } - - selection.copybyformat(event, JSON.stringify(arr)); - }); - - //矩阵操作选区 翻转 上下 - $("#luckysheet-matrix-turn-up").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - for (let r = getdata.length - 1; r >= 0; r--) { - let a = []; - for (let c = 0; c < getdata[0].length; c++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandler(arr); - }); - - //矩阵操作选区 翻转 左右 - $("#luckysheet-matrix-turn-left").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - for (let r = 0; r < getdata.length; r++) { - let a = []; - for (let c = getdata[0].length - 1; c >= 0; c--) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandler(arr); - }); - - //矩阵操作选区 翻转 顺时针 - $("#luckysheet-matrix-turn-cw").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - for (let c = 0; c < getdata[0].length; c++) { - let a = []; - for (let r = getdata.length - 1; r >= 0; r--) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandlerD(arr); - }); - - //矩阵操作选区 翻转 逆时针 - $("#luckysheet-matrix-turn-anticw").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - for (let c = getdata[0].length - 1; c >= 0; c--) { - let a = []; - for (let r = 0; r < getdata.length; r++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandlerD(arr); - }); - - //矩阵操作选区 转置 - $("#luckysheet-matrix-turn-trans").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - for (let c = 0; c < getdata[0].length; c++) { - let a = []; - for (let r = 0; r < getdata.length; r++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandlerD(arr); - }); - - let jfnqrt = function (x, p) { - if (x == 0) - return 0; - let x0, x1; - x0 = x; - x1 = ((p - 1) * x0 / p) + (x / (Math.pow(x0, p - 1) * p));//利用迭代法求解 - while (Math.abs(x1 - x0) > 0.000001) { - x0 = x1; - x1 = ((p - 1) * x0 / p) + (x / (Math.pow(x0, p - 1) * p)); - } - return x1; - } - - //矩阵操作选区 矩阵计算 - $("#luckysheet-matrix-cal-confirm").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let caltype = $("#luckysheet-matrix-cal-type").val(), - calvalue = parseInt($("#luckysheet-matrix-cal-value").val()); - - if(calvalue.toString() == "NaN"){ - if(isEditMode()){ - alert("请输入正确的数值!"); - } - else{ - tooltip.info("请输入正确的数值!", ""); - } - return; - } - - if (calvalue == null) { - calvalue = 2; - } - - let arr = []; - - for (let r = 0; r < getdata.length; r++) { - let a = []; - - for (let c = 0; c < getdata[0].length; c++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - if (parseInt(value) != null && getdata[r][c].ct != undefined && getdata[r][c].ct.t == "n") { - if (caltype == "minus") { - value.v = value.v - calvalue; - } - else if (caltype == "multiply") { - value.v = value.v * calvalue; - } - else if (caltype == "divided") { - value.v = numFormat(value.v / calvalue, 4); - } - else if (caltype == "power") { - value.v = Math.pow(value.v, calvalue); - } - else if (caltype == "root") { - if (calvalue == 2) { - value.v = numFormat(Math.sqrt(value.v), 4); - } - else if (calvalue == 3 && Math.cbrt) { - value.v = numFormat(Math.cbrt(value.v), 4); - } - else { - value.v = numFormat(jfnqrt(value.v, calvalue), 4); - } - } - else if (caltype == "log") { - value.v = numFormat(Math.log(value.v) * 10000 / Math.log(Math.abs(calvalue)), 4); - } - else { - value.v = value.v + calvalue; - } - - if(value.v == null){ - value.m = ""; - } - else{ - value.m = value.v.toString(); - } - } - } - a.push(value); - } - arr.push(a); - } - - editor.controlHandler(arr); - }); - - //矩阵操作选区 删除两端0值 按行 - $("#luckysheet-matrix-delezero-row").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - let getdatalen = getdata[0].length; - for (let r = 0; r < getdata.length; r++) { - let a = [], stdel = true, eddel = true; - for (let c = 0; c < getdatalen; c++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - if ((value.v == "0" || value.v == 0) && stdel) { - continue; - } - else { - stdel = false; - } - } - a.push(value); - } - - let a1 = []; - if (a.length == getdatalen) { - a1 = a; - } - else { - for (let c = a.length - 1; c >= 0; c--) { - let value = ""; - if (a[c] != null) { - value = a[c]; - if ((value.v == "0" || value.v == 0) && eddel) { - continue; - } - else { - eddel = false; - } - } - a1.unshift(value); - } - - let l = getdatalen - a1.length; - for (let c1 = 0; c1 < l; c1++) { - a1.push(""); - } - } - arr.push(a1); - } - - editor.controlHandler(arr); - }); - - //矩阵操作选区 删除两端0值 按列 - $("#luckysheet-matrix-delezero-column").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - let getdatalen = getdata.length, collen = getdata[0].length; - for (let c = 0; c < collen; c++) { - let a = [], stdel = true, eddel = true; - for (let r = 0; r < getdatalen; r++) { - let value = ""; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - if ((value.v == "0" || value.v == 0) && stdel) { - continue; - } - else { - stdel = false; - } - } - a.push(value); - } - - let a1 = []; - if (a.length == getdatalen) { - a1 = a; - } - else { - for (let r = a.length - 1; r >= 0; r--) { - let value = ""; - if (a[r] != null) { - value = a[r]; - if ((value.v == "0" || value.v == 0) && eddel) { - continue; - } - else { - eddel = false; - } - } - a1.unshift(value); - } - - let l = getdatalen - a1.length; - for (let r1 = 0; r1 < l; r1++) { - a1.push(""); - } - } - arr.push(a1); - } - - let arr1 = []; - for (let c = 0; c < arr[0].length; c++) { - let a = []; - for (let r = 0; r < arr.length; r++) { - let value = ""; - if (arr[r] != null && arr[r][c] != null) { - value = arr[r][c]; - } - a.push(value); - } - arr1.push(a); - } - - editor.controlHandler(arr1); - }); - - //矩阵操作选区 删除重复值 按行 - $("#luckysheet-matrix-delerpt-row").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - let getdatalen = getdata[0].length; - for (let r = 0; r < getdata.length; r++) { - let a = [], repeat = {}; - - for (let c = 0; c < getdatalen; c++) { - let value = null; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - - if(value.v in repeat){ - repeat[value.v].push(value); - } - else{ - repeat[value.v] = []; - repeat[value.v].push(value); - } - } - } - - for (let c = 0; c < getdatalen; c++) { - let value = null; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - - if(repeat[value.v].length == 1){ - a.push(value); - } - } - } - - let l = getdatalen - a.length; - for (let c1 = 0; c1 < l; c1++) { - a.push(null); - } - arr.push(a); - } - - editor.controlHandler(arr); - }); - - //矩阵操作选区 删除重复值 按列 - $("#luckysheet-matrix-delerpt-column").click(function (event) { - $("body .luckysheet-cols-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选定区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选定区域执行此操作,请选择单个区域,然后再试", ""); - } - return; - } - - let getdata = getdatabyselection(Store.luckysheet_select_save[0]); - if (getdata.length == 0) { - return; - } - - let arr = []; - let getdatalen = getdata.length, collen = getdata[0].length; - for (let c = 0; c < collen; c++) { - let a = [], repeat = {}; - - for (let r = 0; r < getdatalen; r++) { - let value = null; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - - if(value.v in repeat){ - repeat[value.v].push(value); - } - else{ - repeat[value.v] = []; - repeat[value.v].push(value); - } - } - } - - for (let r = 0; r < getdatalen; r++) { - let value = null; - if (getdata[r] != null && getdata[r][c] != null) { - value = getdata[r][c]; - - if(repeat[value.v].length == 1){ - a.push(value); - } - } - } - - a1 = a; - let l = getdatalen - a1.length; - for (let r1 = 0; r1 < l; r1++) { - a1.push(null); - } - arr.push(a1); - } - - let arr1 = []; - for (let c = 0; c < arr[0].length; c++) { - let a = []; - for (let r = 0; r < arr.length; r++) { - let value = null; - if (arr[r] != null && arr[r][c] != null) { - value = arr[r][c]; - } - a.push(value); - } - arr1.push(a); - } - - editor.controlHandler(arr1); - }); - - //回退 重做 按钮 - $("#luckysheet-icon-undo").click(function (event) { - controlHistory.redo(event); - }); - $("#luckysheet-icon-redo").click(function (event) { - controlHistory.undo(event); - }); - - //表格底部名称栏区域 相关事件(增、删、改、隐藏显示、颜色等等) - let isInitialSheetConfig = false, luckysheetcurrentSheetitem = null, jfdbclicklagTimeout = null; - function showsheetconfigmenu() { - if (!isInitialSheetConfig) { - isInitialSheetConfig = true; - $("#luckysheetsheetconfigcolorur").spectrum({ - showPalette: true, - preferredFormat: "hex", - clickoutFiresChange: false, - showInitial: true, - showInput: true, - flat: true, - hideAfterPaletteSelect: false, - showSelectionPalette: true, - maxPaletteSize: 10, - cancelText: locale().sheetconfig.cancelText, - chooseText: locale().sheetconfig.chooseText, - togglePaletteMoreText: "更多", - togglePaletteLessText: "少于", - clearText: "清除颜色选择", - noColorSelectedText: "没有颜色被选择", - palette: [["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", "rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"], ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)"], ["rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)"], ["rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)"], ["rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)", "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)"], ["rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"], ["#c1232b", "#27727b", "#fcce10", "#e87c25", "#b5c334", "#fe8463", "#9bca63", "#fad860", "#f3a43b", "#60c0dd", "#d7504b", "#c6e579", "#f4e001", "#f0805a", "#26c0c0", "#c12e34", "#e6b600", "#0098d9", "#2b821d", "#005eaa", "#339ca8", "#cda819", "#32a487", "#3fb1e3", "#6be6c1", "#626c91", "#a0a7e6", "#c4ebad", "#96dee8"]], - change: function (color) { - let $input = $(this); - if (color != null) { - color = color.toHexString(); - } - else { - color = "rgb(0, 0, 0)"; - } - - let oldcolor = null; - if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ - oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); - } - - luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); - luckysheetcurrentSheetitem.append('
    '); - let index = getSheetIndex(Store.currentSheetIndex); - Store.luckysheetfile[index].color = color; - server.saveParam("all", Store.currentSheetIndex, color, { "k": "color" }); - - if (Store.clearjfundo) { - let redo = {}; - redo["type"] = "sheetColor"; - redo["sheetIndex"] = Store.currentSheetIndex; - - redo["oldcolor"] = oldcolor; - redo["color"] = color; - - Store.jfundo = []; - Store.jfredo.push(redo); - } - } - }); - - $("#luckysheetsheetconfigcolorreset").click(function () { - let oldcolor = null; - if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ - oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); - } - - luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); - let index = getSheetIndex(Store.currentSheetIndex); - Store.luckysheetfile[index].color = null; - server.saveParam("all", Store.currentSheetIndex, null, { "k": "color" } ); - - if (Store.clearjfundo) { - let redo = {}; - redo["type"] = "sheetColor"; - redo["sheetIndex"] = Store.currentSheetIndex; - - redo["oldcolor"] = oldcolor; - redo["color"] = null; - - Store.jfundo = []; - Store.jfredo.push(redo); - } - }); - } - - let index = getSheetIndex(Store.currentSheetIndex); - if (Store.luckysheetfile[index].color != null && Store.luckysheetfile[index].color.length > 0) { - $("#luckysheetsheetconfigcolorur").spectrum("set", Store.luckysheetfile[index].color); - - } - - $("#luckysheetsheetconfigcolorur").parent().find("span, div, button, input, a").addClass("luckysheet-mousedown-cancel"); - setTimeout(function(){ - mouseclickposition($("#luckysheet-rightclick-sheet-menu"), luckysheetcurrentSheetitem.offset().left + luckysheetcurrentSheetitem.width(), luckysheetcurrentSheetitem.offset().top - 18, "leftbottom"); - },1); - } - - let luckysheetsheetrightclick = function ($t, $cur, e) { - clearTimeout(jfdbclicklagTimeout); - if ($cur.hasClass("luckysheet-sheets-item-name") && $cur.attr("contenteditable") == "true") { - return; - } - if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()) { - setTimeout(function () { - formula.setCaretPosition(formula.rangeSetValueTo.get(0), 0, formula.rangeSetValueTo.text().length); - formula.createRangeHightlight(); - $("#luckysheet-input-box-index").find(".luckysheet-input-box-index-sheettxt").remove().end().prepend("" + sheetmanage.getSheetName(formula.rangetosheet) + "!").show(); - $("#luckysheet-input-box-index").css({"left": $("#luckysheet-input-box").css("left"), "top": (parseInt($("#luckysheet-input-box").css("top")) - 20) + "px", "z-index": $("#luckysheet-input-box").css("z-index")}); - }, 1); - } - else { - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").remove(); - } - - $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active"); - $t.addClass("luckysheet-sheets-item-active"); - cleargridelement(e); - sheetmanage.changeSheet($t.data("index")); - - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - - if ($cur.hasClass("luckysheet-sheets-item-menu") || $cur.hasClass("fa-sort-desc") || e.which == "3") { - luckysheetcurrentSheetitem = $cur.closest(".luckysheet-sheets-item"); - showsheetconfigmenu(); - } - } - - $("#luckysheet-sheet-area").on("mousedown", "div.luckysheet-sheets-item", function (e) { - if(isEditMode()){ - // alert("非编辑模式下不允许该操作!"); - return; - } - - let $t = $(this), $cur = $(e.target), $item = $cur.closest(".luckysheet-sheets-item"); - - if (e.which == "3") { - luckysheetsheetrightclick($t, $cur, e); - luckysheetcurrentSheetitem = $item; - showsheetconfigmenu(); - return; - } - - if ($item.hasClass("luckysheet-sheets-item-active") && $item.find(".luckysheet-sheets-item-name").attr("contenteditable") == "false") { - jfdbclicklagTimeout = setTimeout(function () { - Store.luckysheet_sheet_move_status = true; - Store.luckysheet_sheet_move_data = {}; - Store.luckysheet_sheet_move_data.widthlist = []; - - $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").each(function (i) { - if (i == 0) { - Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth())); - } - else { - Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()) + Store.luckysheet_sheet_move_data.widthlist[i - 1]); - } - }); - - Store.luckysheet_sheet_move_data.curindex = $("#luckysheet-sheet-area div.luckysheet-sheets-item").index($item); - let x = e.pageX; - Store.luckysheet_sheet_move_data.curleft = x - $item.offset().left; - Store.luckysheet_sheet_move_data.pageX = x; - Store.luckysheet_sheet_move_data.activeobject = $item; - Store.luckysheet_sheet_move_data.cursorobject = $cur; - let $itemclone = $item.clone().css("visibility", "hidden").attr("id", "luckysheet-sheets-item-clone"); - $item.after($itemclone); - $item.css({ "position": "absolute", "opacity": 0.8, "cursor": "move", "transition": "initial", "z-index": 10 }); - }, 200); - } - }).on("click", "div.luckysheet-sheets-item", function (e) { - if(isEditMode()){ - // alert("非编辑模式下不允许该操作!"); - return; - } - - let $t = $(this), $cur = $(e.target); - luckysheetsheetrightclick($t, $cur, e); - }); - - let luckysheetsheetnameeditor = function ($t) { - $t.attr("contenteditable", "true").addClass("luckysheet-mousedown-cancel").data("oldtxt", $t.text()); - - setTimeout(function () { - if (document.selection) { - let range = document.body.createTextRange(); - range.moveToElementText($t.get(0)); - range.select(); - } else if (window.getSelection) { - let range = document.createRange(); - range.selectNodeContents($t.get(0)); - window.getSelection().removeAllRanges(); - window.getSelection().addRange(range); - } - }, 1); - } - - $("#luckysheet-sheet-area").on("dblclick", "span.luckysheet-sheets-item-name", function (e) { - luckysheetsheetnameeditor($(this)); - }); - - $("#luckysheet-sheet-area").on("blur", "span.luckysheet-sheets-item-name", function (e) { - let $t = $(this); - let txt = $t.text(), oldtxt = $t.data("oldtxt"); - let index = getSheetIndex(Store.currentSheetIndex); - for (let i = 0; i < Store.luckysheetfile.length; i++) { - if (index != i && Store.luckysheetfile[i].name == txt) { - if(isEditMode()){ - alert("标签页的名称不能重复!请重新修改"); - } - else{ - tooltip.info("提示", "标签页的名称不能重复!请重新修改"); - } - $t.text(oldtxt).attr("contenteditable", "false"); - return; - } - } - - let winW = $(window).width(); - - let c_width = 0; - $("#luckysheet-sheet-container-c > div.luckysheet-sheets-item:visible").each(function(){ - c_width += $(this).outerWidth(); - }); - - if (c_width >= winW * 0.7) { - $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); - $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); - } - - Store.luckysheetfile[index].name = txt; - server.saveParam("all", Store.currentSheetIndex, txt, { "k": "name" }); - - $t.attr("contenteditable", "false").removeClass("luckysheet-mousedown-cancel"); - - if (Store.clearjfundo) { - let redo = {}; - redo["type"] = "sheetName"; - redo["sheetIndex"] = Store.currentSheetIndex; - - redo["oldtxt"] = oldtxt; - redo["txt"] = txt; - - Store.jfundo = []; - Store.jfredo.push(redo); - } - }); - - $("#luckysheet-sheet-area").on("keydown", "span.luckysheet-sheets-item-name", function (e) { - let kcode = e.keyCode; - let $t = $(this); - if (kcode == keycode.ENTER) { - let index = getSheetIndex(Store.currentSheetIndex); - Store.luckysheetfile[index].name = $t.text(); - $t.attr("contenteditable", "false"); - } - }); - - $("#luckysheetsheetconfigrename").click(function () { - luckysheetsheetnameeditor(luckysheetcurrentSheetitem.find("span.luckysheet-sheets-item-name")); - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheetsheetconfigshow").click(function () { - $("#luckysheet-sheets-m").click(); - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheetsheetconfigmoveleft").click(function () { - if (luckysheetcurrentSheetitem.preval(":visible").length > 0) { - luckysheetcurrentSheetitem.insertBefore(luckysheetcurrentSheetitem.preval(":visible").eq(0)); - sheetmanage.reOrderAllSheet(); - } - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheetsheetconfigmoveright").click(function () { - if (luckysheetcurrentSheetitem.nextAll(":visible").length > 0) { - luckysheetcurrentSheetitem.insertAfter(luckysheetcurrentSheetitem.nextAll(":visible").eq(0)); - sheetmanage.reOrderAllSheet(); - } - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheetsheetconfigdelete").click(function (e) { - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - - if($("#luckysheet-sheet-container-c .luckysheet-sheets-item:visible").length <= 1){ - if(isEditMode()){ - alert("工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。"); - } - else{ - tooltip.info("工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。", ""); - } - - return; - } - - let index = getSheetIndex(Store.currentSheetIndex); - - tooltip.confirm("是否删除【" + Store.luckysheetfile[index].name + "】?", "可以通过Ctrl+Z撤销删除", function () { - sheetmanage.deleteSheet(luckysheetcurrentSheetitem.data("index")); - }, null); - - $("#luckysheet-input-box").removeAttr("style"); - }); - - $("#luckysheetsheetconfigcopy").click(function (e) { - sheetmanage.copySheet(luckysheetcurrentSheetitem.data("index"), e); - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheetsheetconfighide").click(function () { - if ($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").length == 1) { - if(isEditMode()){ - alert("不能隐藏, 至少保留一个sheet标签"); - } - else{ - tooltip.info("不能隐藏", "至少保留一个sheet标签"); - } - return; - } - sheetmanage.setSheetHide(luckysheetcurrentSheetitem.data("index")); - $("#luckysheet-input-box").removeAttr("style"); - $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); - }); - - $("#luckysheet-sheets-add").click(function (e) { - sheetmanage.addNewSheet(e); - sheetmanage.locationSheet(); - $("#luckysheet-input-box").removeAttr("style"); - }); - - let sheetscrollani = null, sheetscrollstart = 0, sheetscrollend = 0, sheetscrollstep = 150; - $("#luckysheet-sheets-leftscroll").click(function () { - let $c = $("#luckysheet-sheet-container-c"); - sheetscrollstart = $c.scrollLeft(); - sheetscrollend = $c.scrollLeft() - sheetscrollstep; - - if (sheetscrollend <= 0) { - $("#luckysheet-sheet-container .docs-sheet-fade-left").hide(); - } - $("#luckysheet-sheet-container .docs-sheet-fade-right").show(); - - clearInterval(sheetscrollani); - sheetscrollani = setInterval(function () { - sheetscrollstart -= 4; - $c.scrollLeft(sheetscrollstart); - if (sheetscrollstart <= sheetscrollend) { - clearInterval(sheetscrollani); - } - }, 1); - }); - - $("#luckysheet-sheets-rightscroll").click(function () { - let $c = $("#luckysheet-sheet-container-c"); - sheetscrollstart = $c.scrollLeft(); - sheetscrollend = $c.scrollLeft() + sheetscrollstep; - - if (sheetscrollstart > 0) { - $("#luckysheet-sheet-container .docs-sheet-fade-right").hide(); - } - $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); - - clearInterval(sheetscrollani); - sheetscrollani = setInterval(function () { - sheetscrollstart += 4; - $c.scrollLeft(sheetscrollstart); - if (sheetscrollstart >= sheetscrollend) { - clearInterval(sheetscrollani); - } - }, 1); - }); - - let initialOpenSheet = true; - $("#luckysheet-sheets-m").click(function (e) { - $("#luckysheet-sheet-list").html(""); - - let item = ""; - for (let i = 0; i < Store.luckysheetfile.length; i++) { - let f = Store.luckysheetfile[i], icon = '', style = ""; - if (f["status"] == 1) { - icon = ''; - } - - if (f["hide"] == 1) { - icon = ''; - style += "color:#BBBBBB;"; - } - - if (f["color"] != null && f["color"].length > 0) { - style += "border-right:4px solid " + f["color"] + ";"; - } - - item += replaceHtml(sheetselectlistitemHTML, { "index": f["index"], "name": f["name"], "icon": icon, "style": style }); - } - - if (initialOpenSheet) { - $("#" + Store.container).append(replaceHtml(sheetselectlistHTML, { "item": item })); - $("#luckysheet-sheet-list").on("click", ".luckysheet-cols-menuitem", function (e) { - if(isEditMode()){ - // tooltip.info("提示", "图表编辑模式下不允许该操作!"); - alert("图表编辑模式下不允许该操作!"); - return; - } - - let $item = $(this), index = $item.data("index"); - - if ($item.data("index") != Store.currentSheetIndex) { - sheetmanage.setSheetShow(index); - sheetmanage.locationSheet(); - } - }); - - initialOpenSheet = false; - } - else { - $("#luckysheet-sheet-list").html(item); - } - - let $t = $("#luckysheet-sheet-list"); - - mouseclickposition($t, $(this).offset().left, $(this).offset().top - 12, "leftbottom"); - $("#luckysheet-input-box").removeAttr("style"); - }); - - //向左增加列,向上增加行 - $("#luckysheet-add-lefttop, #luckysheet-add-lefttop_t").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - return; - } - - let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0]; - luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "lefttop"); - }); - $("#luckysheet-addTopRows").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - return; - } - - let st_index = Store.luckysheet_select_save[0].row[0]; - luckysheetextendtable('row', st_index, value, "lefttop"); - }) - $("#luckysheet-addLeftCols").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - return; - } - - let st_index = Store.luckysheet_select_save[0].column[0]; - luckysheetextendtable('column', st_index, value, "lefttop"); - }) - - //向右增加列,向下增加行 - $("#luckysheet-add-rightbottom, #luckysheet-add-rightbottom_t").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - - return; - } - - let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1]; - luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "rightbottom"); - }); - $("#luckysheet-addBottomRows").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - - return; - } - - let st_index = Store.luckysheet_select_save[0].row[1]; - luckysheetextendtable('row', st_index, value, "rightbottom"); - }); - $("#luckysheet-addRightCols").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - - return; - } - - let $t = $(this), value = $t.parent().find("input").val(); - if (!isRealNum(value)) { - if(isEditMode()){ - alert("增加错误, 请输入数字"); - } - else{ - tooltip.info("增加错误, 请输入数字", ""); - } - - return; - } - - value = parseInt(value); - - if (value < 1 || value > 100) { - if(isEditMode()){ - alert("增加错误, 增加范围限制在1-100"); - } - else{ - tooltip.info("增加错误, 增加范围限制在1-100", ""); - } - - return; - } - - let st_index = Store.luckysheet_select_save[0].column[1]; - luckysheetextendtable('column', st_index, value, "rightbottom"); - }); - - //删除选中行列 - $("#luckysheet-del-selected, #luckysheet-del-selected_t").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(Store.luckysheetRightHeadClickIs == "row"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - else if(Store.luckysheetRightHeadClickIs == "column"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - return; - } - - let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0], - ed_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1]; - luckysheetdeletetable(Store.luckysheetRightHeadClickIs, st_index, ed_index); - }); - $("#luckysheet-delRows").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(Store.luckysheetRightHeadClickIs == "row"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - else if(Store.luckysheetRightHeadClickIs == "column"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - return; - } - - let st_index = Store.luckysheet_select_save[0].row[0], - ed_index = Store.luckysheet_select_save[0].row[1]; - luckysheetdeletetable('row', st_index, ed_index); - }) - $("#luckysheet-delCols").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 1){ - if(Store.luckysheetRightHeadClickIs == "row"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - else if(Store.luckysheetRightHeadClickIs == "column"){ - if(isEditMode()){ - alert("不能对多重选择区域执行此操作,请选择单个区域,然后再试"); - } - else{ - tooltip.info("不能对多重选择区域执行此操作,请选择单个区域,然后再试", ""); - } - } - return; - } - - let st_index = Store.luckysheet_select_save[0].column[0], - ed_index = Store.luckysheet_select_save[0].column[1]; - luckysheetdeletetable('column', st_index, ed_index); - }) - - //隐藏、显示行 - $("#luckysheet-hidRows").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - let cfg = $.extend(true, {}, Store.config); - if(cfg["rowhidden"] == null){ - cfg["rowhidden"] = {}; - } - - 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]; - - for(let r = r1; r <= r2; r++){ - cfg["rowhidden"][r] = 0; - } - } - - //保存撤销 - if(Store.clearjfundo){ - let redo = {}; - redo["type"] = "showHidRows"; - 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["rowhidden"], { "k": "rowhidden" }); - - //行高、列宽 刷新 - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); - }) - $("#luckysheet-showHidRows").click(function (event) { - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - let cfg = $.extend(true, {}, Store.config); - if(cfg["rowhidden"] == null){ - return; - } - - 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]; - - for(let r = r1; r <= r2; r++){ - delete cfg["rowhidden"][r]; - } - } - - //保存撤销 - if(Store.clearjfundo){ - let redo = {}; - redo["type"] = "showHidRows"; - 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["rowhidden"], { "k": "rowhidden" }); - - //行高、列宽 刷新 - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); - }) - - //清除单元格内容 - $("#luckysheet-delete-text").click(function(){ - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - if(Store.luckysheet_select_save.length > 0){ - let d = editor.deepCopyFlowData(Store.flowdata); - - let has_PartMC = false; - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - if(hasPartMC(Store.config, r1, r2, c1, c2)){ - has_PartMC = true; - break; - } - } - - if(has_PartMC){ - if(isEditMode()){ - alert("无法对部分合并单元格执行此操作"); - } - else{ - tooltip.info("无法对部分合并单元格执行此操作", ""); - } - - return; - } - - 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]; - let c1 = Store.luckysheet_select_save[s].column[0], - c2 = Store.luckysheet_select_save[s].column[1]; - - for(let r = r1; r <= r2; r++){ - for(let c = c1; c <= c2; c++){ - if(pivotTable.isPivotRange(r, c)){ - continue; - } - - if(getObjType(d[r][c]) == "object"){ - delete d[r][c]["m"]; - delete d[r][c]["v"]; - - if(d[r][c]["f"] != null){ - delete d[r][c]["f"]; - formula.delFunctionGroup(r, c, Store.currentSheetIndex); - - delete d[r][c]["spl"]; - } - } - else{ - d[r][c] = null; - } - } - } - } - - jfrefreshgrid(d, Store.luckysheet_select_save); - } - }); - - //行高列宽设置 - $("#luckysheet-rows-cols-changesize").click(function(){ - $("#luckysheet-rightclick-menu").hide(); - $("#" + Store.container).attr("tabindex", 0).focus(); - - let size = parseInt($(this).siblings("input[type='number']").val().trim()); - - if(size < 0 || size > 255){ - if(isEditMode()){ - alert("数值必须在0 ~ 255之间"); - } - else{ - tooltip.info("数值必须在0 ~ 255之间", ""); - } - - return; - } - - let cfg = $.extend(true, {}, Store.config); - let type; - - if(Store.luckysheetRightHeadClickIs == "row"){ - type = "resizeR"; - - if(cfg["rowlen"] == null){ - cfg["rowlen"] = {}; - } - - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - let r1 = Store.luckysheet_select_save[s].row[0]; - let r2 = Store.luckysheet_select_save[s].row[1]; - - for(let r = r1; r <= r2; r++){ - cfg["rowlen"][r] = size; - } - } - } - else if(Store.luckysheetRightHeadClickIs == "column"){ - type = "resizeC"; - - if(cfg["columlen"] == null){ - cfg["columlen"] = {}; - } - - for(let s = 0; s < Store.luckysheet_select_save.length; s++){ - let c1 = Store.luckysheet_select_save[s].column[0]; - let c2 = Store.luckysheet_select_save[s].column[1]; - - for(let c = c1; c <= c2; c++){ - cfg["columlen"][c] = size; - } - } - } - - if (Store.clearjfundo) { - Store.jfundo = []; - Store.jfredo.push({ - "type": "resize", - "ctrlType": type, - "config": $.extend(true, {}, Store.config), - "curconfig": $.extend(true, {}, cfg), - "sheetIndex": Store.currentSheetIndex - }); - } - - //config - Store.config = cfg; - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; - - if(Store.luckysheetRightHeadClickIs == "row"){ - server.saveParam("cg", Store.currentSheetIndex, cfg["rowlen"], { "k": "rowlen" }); - jfrefreshgrid_rhcw(Store.flowdata.length, null); - } - else if(Store.luckysheetRightHeadClickIs == "column"){ - server.saveParam("cg", Store.currentSheetIndex, cfg["columlen"], { "k": "columlen" }); - jfrefreshgrid_rhcw(null, Store.flowdata[0].length); - } - }); - - //模态框拖动 - $(document).on("mousedown", "div.luckysheet-modal-dialog", function (e) { - if (!$(e.target).is(".luckysheet-modal-dialog")) { - return; - } - - Store.luckysheet_model_move_state = true; - - Store.luckysheet_model_move_obj = $(e.currentTarget); - let toffset = Store.luckysheet_model_move_obj.offset(); - Store.luckysheet_model_xy = [e.pageX - toffset.left, e.pageY - toffset.top]; - }); - - //模态框关闭 - $(document).on("click", ".luckysheet-modal-dialog-title-close, .luckysheet-model-close-btn", function (e) { - //选择文本颜色和单元格颜色弹出框取消 - if($("#textcolorselect").is(":visible")||$("#cellcolorselect").is(":visible")){ - $("#luckysheet-conditionformat-dialog").show(); - } - $(e.currentTarget).parents(".luckysheet-modal-dialog").hide(); - $("#luckysheet-modal-dialog-mask").hide(); - - //函数查找功能所有弹出框关闭和取消 - if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula")){ - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - } - if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm")){ - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - } - if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm-select")){ - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - } - - $("#" + Store.container).attr("tabindex", 0).focus(); - }); - - //排序事件 - let luckysheet_sort_initial = true; - $("#luckysheetorderby").click(function () { - $("body .luckysheet-cols-menu").hide(); - const _locale = locale(); - const locale_sort = _locale.sort; - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert(locale_sort.noRangeError); - } - else{ - tooltip.info(locale_sort.noRangeError, ""); - } - return; - } - - let last = Store.luckysheet_select_save[0]; - let r1 = last["row"][0], r2 = last["row"][1]; - let c1 = last["column"][0], c2 = last["column"][1]; - - if (luckysheet_sort_initial) { - luckysheet_sort_initial = false; - - let content = `
    ${locale_sort.hasTitle}
    + ${locale_sort.addOthers}
    `; - - $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-sort-dialog", "addclass": "", "title": "排序范围", "content": content, "botton": ``})); - - $("#luckysheet-sort-dialog .luckysheet-sort-dialog-additem").click(function () { - let last = Store.luckysheet_select_save[0]; - let r1 = last["row"][0], r2 = last["row"][1]; - let c1 = last["column"][0], c2 = last["column"][1]; - - let option = "", i = $("#luckysheet-sort-dialog table").data("itemcount") + 1; - let t = $("#luckysheet-sort-haveheader").is(':checked'); - - for (let c = c1; c <= c2; c++) { - if (t) { - let v = getcellvalue(r1, c, Store.flowdata, "m"); - - if(v == null){ - v = locale_sort.columnOperation + (c - c1 + 1); - } - - option += ''; - } - else { - option += ''; - } - } - - $("#luckysheet-sort-dialog table").append(` - - ${locale_sort.secondaryTitle} - -
    -
    -
    - - - `); - $("#luckysheet-sort-dialog table").data("itemcount", i); - }); - - $("#luckysheet-sort-haveheader").change(function () { - let last = Store.luckysheet_select_save[0]; - let r1 = last["row"][0], r2 = last["row"][1]; - let c1 = last["column"][0], c2 = last["column"][1]; - - let t = $(this).is(':checked'); - let option = ""; - - for (let c = c1; c <= c2; c++) { - if (t) { - let v = getcellvalue(r1, c, Store.flowdata, "m"); - - if(v == null){ - v = locale_sort.columnOperation + (c - c1 + 1); - } - - option += ''; - } - else { - option += ''; - } - } - - $("#luckysheet-sort-dialog tr select").each(function () { - $(this).html(option); - }); - }); - - //Custom sort - $("#luckysheet-sort-modal-confirm").click(function () { - if(Store.luckysheet_select_save.length > 1){ - if(isEditMode()){ - alert(locale_sort.noRangeError); - } - else{ - tooltip.info(locale_sort.noRangeError, ""); - } - - return; - } - - let d = editor.deepCopyFlowData(Store.flowdata); - - let last = Store.luckysheet_select_save[0]; - let r1 = last["row"][0], r2 = last["row"][1]; - let c1 = last["column"][0], c2 = last["column"][1]; - - //Data has header row - let t = $("#luckysheet-sort-haveheader").is(':checked'); - - let str; - if(t){ - str = r1 + 1; - } - else{ - str = r1; - } - - let hasMc = false; //Whether the sort selection has merged cells - - let data = []; - - for(let r = str; r <= r2; r++){ - let data_row = []; - - for(let c = c1; c <= c2; c++){ - if(d[r][c] != null && d[r][c].mc != null){ - hasMc = true; - break; - } - - data_row.push(d[r][c]); - } - - data.push(data_row); - } - - if(hasMc){ - if(isEditMode()){ - alert(locale_sort.mergeError); - } - else{ - tooltip.info(locale_sort.mergeError, ""); - } - - return; - } - - $($("#luckysheet-sort-dialog table tr").toArray().reverse()).each(function () { - let i = $(this).find("select").val(), - asc = $(this).find('input:radio:checked').val(); - - i -= c1; - - if (asc == "asc") { - asc = true; - } - else { - asc = false; - } - - data = orderbydata([].concat(data), i, asc); - }); - - for(let r = str; r <= r2; r++){ - for(let c = c1; c <= c2; c++){ - d[r][c] = data[r - str][c - c1]; - } - } - - if(Store.config["rowlen"] != null){ - let cfg = $.extend(true, {}, Store.config); - cfg = rowlenByRange(d, str, r2, cfg); - - jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }], cfg, null, true); - } - else{ - jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }]); - } - - $("#luckysheet-sort-dialog").hide(); - $("#luckysheet-modal-dialog-mask").hide(); - }); - } - - let option = ""; - for (let c = c1; c <= c2; c++) { - option += ''; - } - - $("#luckysheet-sort-dialog select").html(option); - - $("#luckysheet-sort-dialog .luckysheet-sort-dialog-tr").remove(); - - $("#luckysheet-sort-haveheader").prop("checked", false); - $("#luckysheet-sort-dialog input:radio:first").prop("checked", "checked"); - - $("#luckysheet-sort-dialog .luckysheet-modal-dialog-title-text").html(locale_sort.sortRangeTitle+"" + chatatABC(c1) + (r1 + 1) + ""+ locale_sort.sortRangeTitleTo +"" + chatatABC(c2) + (r2 + 1) + ""); - - let $t = $("#luckysheet-sort-dialog"), myh = $t.outerHeight(), myw = $t.outerWidth(); - let winw = $(window).width(), winh = $(window).height(); - let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop(); - - $("#luckysheet-sort-dialog-tablec").css("max-height", (winh - myh) / 2); - $("#luckysheet-sort-dialog").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 2 }).show(); - $("#luckysheet-modal-dialog-mask").show(); - - if (r1 < r2) { - setTimeout(function () { - let flowrowdata1 = Store.flowdata[r1], - flowrowdata2 = Store.flowdata[r1 + 1], - hastitle = false; - - for (let i = c1; i <= c2; i++) { - let isdatatype_r1 = isdatatype(flowrowdata1[i]), - isdatatype_r2 = isdatatype(flowrowdata2[i]); - - if (isdatatype_r1 != isdatatype_r2) { - hastitle = true; - } - } - - if (hastitle) { - $("#luckysheet-sort-haveheader").prop("checked", true).change(); - } - }, 10); - } - }); - - //filter event handler - let hidefilersubmenu = null; - $("#luckysheetfilter").click(createFilter); - - $("#luckysheet-filter-menu").mouseover(function () { - clearTimeout(hidefilersubmenu); - - hidefilersubmenu = setTimeout(function () { - $("#luckysheet-filter-submenu").hide(); - }, 500); - }); - - $("#luckysheet-filter-submenu").mouseover(function () { - clearTimeout(hidefilersubmenu); - }).find(".luckysheet-cols-menuitem").click(function (e) { - $("#luckysheet-filter-selected span").html($(this).find(".luckysheet-cols-menuitem-content").text()).data("value", $(this).data("value")); - $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide(); - - let $type = $(this).data("type"); - let $value = $(this).attr("data-value"); - - if ($type == "2") { - $("#luckysheet-filter-selected span").data("type", "2"); - $("#luckysheet-filter-menu .luckysheet-filter-selected-input2").show(); - $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "number"); - } - else if ($type == "0") { - $("#luckysheet-filter-selected span").data("type", "0"); - } - else { - $("#luckysheet-filter-selected span").data("type", "1"); - $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).show(); - - //若是日期 改变input type类型为date - if($value == "dateequal" || $value == "datelessthan" || $value == "datemorethan"){ - $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "date"); - } - else if($value == "morethan" || $value == "moreequalthan" || $value == "lessthan" || $value == "lessequalthan" || $value == "equal" || $value == "noequal"){ - $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "number"); - } - else{ - $("#luckysheet-filter-menu .luckysheet-filter-selected-input input").prop("type", "text"); - } - } - - $("#luckysheet-filter-byvalue").next().slideUp(); - $("#luckysheet-filter-submenu").hide(); - }); - - $("#luckysheet-filter-bycondition, #luckysheet-filter-byvalue").click(function () { - let $t = $(this); - $t.next().slideToggle(200); - - setTimeout(function () { - if ($t.attr("id") == "luckysheet-filter-bycondition" && $("#luckysheet-filter-bycondition").next().is(":visible")) { - if ($("#luckysheet-filter-selected span").text() != "无") { - $("#luckysheet-filter-byvalue").next().slideUp(200); - } - } - - if ($t.is($("#luckysheet-filter-bycondition"))) { - if ($("#luckysheet-filter-bycondition").next().is(":hidden") && $("#luckysheet-filter-byvalue").next().is(":hidden")) { - $("#luckysheet-filter-byvalue").next().slideDown(200); - } - } - }, 300); - }); - - $("#luckysheet-filter-selected").click(function () { - let $t = $(this), toffset = $t.offset(), $menu = $("#luckysheet-filter-submenu"); - $menu.hide(); - - let winH = $(window).height(), winW = $(window).width(); - let menuW = $menu.width(), menuH = $menu.height(); - let top = toffset.top, left = toffset.left, mheight = winH - toffset.top - 20; - - if (toffset.left + menuW > winW) { - left = toffset.left - menuW; - } - - if (toffset.top > winH / 2) { - top = winH - toffset.top; - - if (top < 0) { - top = 0; - } - - mheight = toffset.top - 20; - } - - $menu.css({ "top": top, "left": left, "height": mheight }).show(); - clearTimeout(hidefilersubmenu); - }); - - //筛选按钮点击事件 - $("#luckysheet-cell-main").on("click", ".luckysheet-filter-options", function (e) { - let $t = $(e.currentTarget), - toffset = $t.offset(), - $menu = $("#luckysheet-filter-menu"), - winH = $(window).height(), - winW = $(window).width(); - - let st_r = $t.data("str"), - ed_r = $t.data("edr"), - cindex = $t.data("cindex"), - st_c = $t.data("stc"), - ed_c = $t.data("edc"), - rowhidden = $t.data("rowhidden") == "" ? {} : JSON.parse($t.data("rowhidden").replace(/\'/g, '"')); - - $("body .luckysheet-cols-menu").hide(); - $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - $("#luckysheet-filter-byvalue-input").val(""); - $("#luckysheet-filter-bycondition").next().hide(); - $("#luckysheet-filter-byvalue").next().show(); - - $menu.data("str", st_r); - $menu.data("edr", ed_r); - $menu.data("cindex", cindex); - $menu.data("stc", st_c); - $menu.data("edc", ed_c); - - $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide().find("input").val(); - $("#luckysheet-filter-selected span").data("type", "0").data("type", null).text("无"); - - let byconditiontype = $t.data("byconditiontype"); - $("#luckysheet-filter-selected span").data("value", $t.data("byconditionvalue")).data("type", byconditiontype).text($t.data("byconditiontext")); - - if (byconditiontype == "2") { - let $input = $("#luckysheet-filter-menu .luckysheet-filter-selected-input2").show().find("input"); - $input.eq(0).val($t.data("byconditionvalue1")); - $input.eq(1).val($t.data("byconditionvalue2")); - } - else if (byconditiontype == "1") { - $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).show().find("input").val($t.data("byconditionvalue1")); - } - - $("#luckysheet-filter-orderby-asc").off("click").on("click", function () { - orderbydatafiler(st_r, st_c, ed_r, ed_c, cindex, true); - }); - - $("#luckysheet-filter-orderby-desc").off("click").on("click", function () { - orderbydatafiler(st_r, st_c, ed_r, ed_c, cindex, false); - }); - - $("#luckysheet-filter-byvalue-select").empty().html('
    数据量大!请稍后
    '); - - let rowhiddenother = {}; //其它筛选列的隐藏行 - $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not(this).each(function () { - let $t = $(this), rh = $t.data("rowhidden"); - - if (rh == "") { - return true; - } - - rh = JSON.parse(rh.replace(/\'/g, '"')); - - for (let r in rh) { - rowhiddenother[r] = 0; - } - }); - - let data = Store.flowdata; - - setTimeout(function () { - //日期值 - let dvmap = {}; - let dvmap_uncheck = {}; - - //除日期以外的值 - let vmap = {}; - let vmap_uncheck = {}; - - for (let r = st_r + 1; r <= ed_r; r++) { - if(r in rowhiddenother){ - continue; - } - - if(Store.flowdata[r] == null){ - continue; - } - - let cell = Store.flowdata[r][cindex]; - - if(cell != null && !isRealNull(cell.v) && cell.ct != null && cell.ct.t == "d" ){ //单元格是日期 - let v = update("YYYY-MM-DD", cell.v); - - let y = v.split("-")[0]; - let m = v.split("-")[1]; - let d = v.split("-")[2]; - - if(!(y in dvmap)){ - dvmap[y] = {}; - } - - if(!(m in dvmap[y])){ - dvmap[y][m] = {}; - } - - if(!(d in dvmap[y][m])){ - dvmap[y][m][d] = 0; - } - - dvmap[y][m][d]++; - - if(r in rowhidden){ - dvmap_uncheck[y] = 0; - dvmap_uncheck[m] = 0; - dvmap_uncheck[d] = 0; - } - } - else{ - let v, m; - if(cell == null || isRealNull(cell.v)){ - v = null; - m = null; - } - else{ - v = cell.v; - m = cell.m; - } - - if(!(v in vmap)){ - vmap[v] = {}; - } - - if(!(m in vmap[v])){ - vmap[v][m] = 0; - } - - vmap[v][m]++; - - if(r in rowhidden){ - vmap_uncheck[v + "#$$$#" + m] = 0; - } - } - } - - //遍历数据加到页面 - let item = []; - - if(JSON.stringify(dvmap).length > 2){ - for(let y in dvmap){ - let ysum = 0; - let monthHtml = ''; - - for(let m in dvmap[y]){ - let msum = 0; - let dayHtml = ''; - - for(let d in dvmap[y][m]){ - let dayL = dvmap[y][m][d]; - msum += dayL; - - //月 小于 10 - let mT; - if(Number(m) < 10){ - mT = "0" + Number(m); - } - else{ - mT = m; - } - - //日 小于 10 - let dT; - if(Number(d) < 10){ - dT = "0" + Number(d); - } - else{ - dT = d; - } - - //日是否选中状态 - if((y in dvmap_uncheck) && (m in dvmap_uncheck) && (d in dvmap_uncheck)){ - dayHtml += '
    ' + - '' + - '' + - '( ' + dayL + ' )' + - '
    '; - } - else{ - dayHtml += '
    ' + - '' + - '' + - '( ' + dayL + ' )' + - '
    '; - } - } - - ysum += msum; - - //月 小于 10 - let mT2; - if(Number(m) < 10){ - mT2 = "0" + Number(m); - } - else{ - mT2 = m; - } - - //月是否选中状态 - if((y in dvmap_uncheck) && (m in dvmap_uncheck)){ - monthHtml += '
    ' + - '
    ' + - '' + - '' + - '' + - '( ' + msum + ' )' + - '
    ' + - '
    ' + dayHtml + '
    ' + - '
    '; - } - else{ - monthHtml += '
    ' + - '
    ' + - '' + - '' + - '' + - '( ' + msum + ' )' + - '
    ' + - '
    ' + dayHtml + '
    ' + - '
    '; - } - } - - //年是否选中状态 - let yearHtml; - if(y in dvmap_uncheck){ - yearHtml = '
    ' + - '
    ' + - '' + - '' + - '' + - '( ' + ysum + ' )' + - '
    ' + - '
    ' + monthHtml + '
    ' + - '
    '; - } - else{ - yearHtml = '
    ' + - '
    ' + - '' + - '' + - '' + - '( ' + ysum + ' )' + - '
    ' + - '
    ' + monthHtml + '
    ' + - '
    '; - } - - item.unshift(yearHtml); - } - } - - if(JSON.stringify(vmap).length > 2){ - let vmapKeys = Object.keys(vmap); - vmapKeys = orderbydata1D(vmapKeys, true); - - for(let i = 0; i < vmapKeys.length; i++){ - let v = vmapKeys[i]; - - for(let x in vmap[v]){ - let text; - if((v + "#$$$#" + x) == "null#$$$#null"){ - text = "(空白)"; - } - else{ - text = x; - } - - //是否选中状态 - let dataHtml; - if((v + "#$$$#" + x) in vmap_uncheck){ - dataHtml = '
    ' + - '' + - '' + - '( ' + vmap[v][x] + ' )' + - '
    '; - } - else{ - dataHtml = '
    ' + - '' + - '' + - '( ' + vmap[v][x] + ' )' + - '
    '; - } - - item.push(dataHtml); - } - } - } - - $("#luckysheet-filter-byvalue-select").html("
    " + item.join("") + "
    "); - }, 1); - - showrightclickmenu($menu, toffset.left, toffset.top + 20); - - e.stopPropagation(); - return false; - }); - - //按颜色筛选 - $("#luckysheet-filter-orderby-color").hover( - function(){ - //遍历筛选列颜色 - let $menu = $("#luckysheet-filter-menu"); - let st_r = $menu.data("str"), - ed_r = $menu.data("edr"), - cindex = $menu.data("cindex"), - st_c = $menu.data("stc"), - ed_c = $menu.data("edc"); - let bgMap = {}; //单元格颜色 - let fcMap = {}; //字体颜色 - - let af_compute = alternateformat.getComputeMap(); - let cf_compute = conditionformat.getComputeMap(); - - for (let r = st_r + 1; r <= ed_r; r++) { - let cell = Store.flowdata[r][cindex]; - - //单元格颜色 - let bg = menuButton.checkstatus(Store.flowdata, r, cindex , "bg"); - - let checksAF = alternateformat.checksAF(r, cindex, af_compute); - if(checksAF != null){//若单元格有交替颜色 - bg = checksAF[1]; - } - - let checksCF = conditionformat.checksCF(r, cindex, cf_compute); - if(checksCF != null && checksCF["cellColor"] != null){//若单元格有条件格式 - bg = checksCF["cellColor"]; - } - - if(bg.indexOf("rgb") > -1){ - bg = rgbTohex(bg); - } - - if(bg.length == 4){ - bg = bg.substr(0, 1) + bg.substr(1, 1).repeat(2) + bg.substr(2, 1).repeat(2) + bg.substr(3, 1).repeat(2); - } - - //字体颜色 - let fc = menuButton.checkstatus(Store.flowdata, r, cindex , "fc"); - - if(checksAF != null){//若单元格有交替颜色 - fc = checksAF[0]; - } - - if(checksCF != null && checksCF["textColor"] != null){//若单元格有条件格式 - fc = checksCF["textColor"]; - } - - if(fc.indexOf("rgb") > -1){ - fc = rgbTohex(fc); - } - - if(fc.length == 4){ - fc = fc.substr(0, 1) + fc.substr(1, 1).repeat(2) + fc.substr(2, 1).repeat(2) + fc.substr(3, 1).repeat(2); - } - - if(Store.config != null && Store.config["rowhidden"] != null && r in Store.config["rowhidden"]){ - bgMap[bg] = 1; - - if(cell != null && !isRealNull(cell.v)){ - fcMap[fc] = 1; - } - } - else{ - bgMap[bg] = 0; - - if(cell != null && !isRealNull(cell.v)){ - fcMap[fc] = 0; - } - } - } - // - let filterBgColorHtml = ''; - if(JSON.stringify(bgMap).length > 2 && Object.keys(bgMap).length > 1){ - let bgColorItemHtml = ''; - for(let b in bgMap){ - if(bgMap[b] == 0){ - bgColorItemHtml += '
    '; - } - else{ - bgColorItemHtml += '
    '; - } - } - filterBgColorHtml = '
    按单元格颜色筛选
    ' + bgColorItemHtml + '
    '; - } - - let filterFcColorHtml = ''; - if(JSON.stringify(fcMap).length > 2 && Object.keys(fcMap).length > 1){ - let fcColorItemHtml = ''; - for(let f in fcMap){ - if(fcMap[f] == 0){ - fcColorItemHtml += '
    '; - } - else{ - fcColorItemHtml += '
    '; - } - } - filterFcColorHtml = '
    按字体颜色筛选
    ' + fcColorItemHtml + '
    '; - } - // - let content; - if(filterBgColorHtml == '' && filterFcColorHtml == ''){ - content = '
    本列仅包含一种颜色
    '; - } - else{ - content = filterBgColorHtml + filterFcColorHtml + '
    '; - } - //颜色筛选子菜单 - $("#luckysheet-filter-orderby-color-submenu").remove(); - $("body").append('
    '+content+'
    '); - let $t = $("#luckysheet-filter-orderby-color-submenu").end(); - let $con = $(this).parent(); - let winW = $(window).width(), winH = $(window).height(); - let menuW = $con.width(), - myh = $t.height() + 25, - myw = $t.width() + 5; - let offset = $(this).offset(); - let top = offset.top, left = offset.left + menuW; - - if (left + myw > winW) { - left = offset.left - myw; - } - - if (top + myh > winH) { - top = winH - myh; - } - - $("#luckysheet-filter-orderby-color-submenu").css({ "top": top, "left": left }).show(); - }, - function(){ - submenuhide = setTimeout(function () { $("#luckysheet-filter-orderby-color-submenu").hide(); }, 200); - } - ); - - $(document).on("mouseover mouseleave", "#luckysheet-filter-orderby-color-submenu", function(e){ - if (e.type === "mouseover") { - clearTimeout(submenuhide); - } - else { - $(this).hide(); - } - }); - $(document).on("click", "#luckysheet-filter-orderby-color-submenu .item label", function(){ - $(this).siblings("input[type='checkbox']").click(); - }); - $(document).off("click.orderbyColorConfirm").on("click.orderbyColorConfirm", "#luckysheet-filter-orderby-color-submenu #luckysheet-filter-orderby-color-confirm", function(){ - let bg_colorMap = {}; - let fc_colorMap = {}; - - $("#luckysheet-filter-orderby-color-submenu .item").each(function(i, e){ - if($(e).find("input[type='checkbox']").is(":checked")){ - let color = $(this).find("label").attr("title"); - let $id = $(this).closest(".box").attr("id"); - - if($id == "filterBgColor"){ - bg_colorMap[color] = 0; - } - else if($id == "filterFcColor"){ - fc_colorMap[color] = 0; - } - } - }); - - let bg_filter; - if($("#luckysheet-filter-orderby-color-submenu #filterBgColor").length > 0){ - bg_filter = true; - } - else{ - bg_filter = false; - } - - let fc_filter; - if($("#luckysheet-filter-orderby-color-submenu #filterFcColor").length > 0){ - fc_filter = true; - } - else{ - fc_filter = false; - } - - let $menu = $("#luckysheet-filter-menu"); - let st_r = $menu.data("str"), - ed_r = $menu.data("edr"), - cindex = $menu.data("cindex"), - st_c = $menu.data("stc"), - ed_c = $menu.data("edc"); - - let rowhiddenother = {}; //其它筛选列的隐藏行 - $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not($("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c).get(0)).each(function () { - let $t = $(this), rh = $t.data("rowhidden"); - - if (rh == "") { - return true; - } - - rh = JSON.parse(rh); - - for (let r in rh) { - rowhiddenother[r] = 0; - } - }); - - let filterdata = {}; - let rowhidden = {}; - let caljs = {}; - - let af_compute = alternateformat.getComputeMap(); - let cf_compute = conditionformat.getComputeMap(); - - for (let r = st_r + 1; r <= ed_r; r++) { - if(r in rowhiddenother){ - continue; - } - - if(Store.flowdata[r] == null){ - continue; - } - - let cell = Store.flowdata[r][cindex]; - - //单元格颜色 - let bg = menuButton.checkstatus(Store.flowdata, r, cindex , "bg"); - - let checksAF = alternateformat.checksAF(r, cindex, af_compute); - if(checksAF != null){//若单元格有交替颜色 - bg = checksAF[1]; - } - - let checksCF = conditionformat.checksCF(r, cindex, cf_compute); - if(checksCF != null && checksCF["cellColor"] != null){//若单元格有条件格式 - bg = checksCF["cellColor"]; - } - - if(bg.indexOf("rgb") > -1){ - bg = rgbTohex(bg); - } - - if(bg.length == 4){ - bg = bg.substr(0, 1) + bg.substr(1, 1).repeat(2) + bg.substr(2, 1).repeat(2) + bg.substr(3, 1).repeat(2); - } - - //文本颜色 - let fc = menuButton.checkstatus(Store.flowdata, r, cindex , "fc"); - - if(checksAF != null){//若单元格有交替颜色 - fc = checksAF[0]; - } - - if(checksCF != null && checksCF["textColor"] != null){//若单元格有条件格式 - fc = checksCF["textColor"]; - } - - if(fc.indexOf("rgb") > -1){ - fc = rgbTohex(fc); - } - - if(fc.length == 4){ - fc = fc.substr(0, 1) + fc.substr(1, 1).repeat(2) + fc.substr(2, 1).repeat(2) + fc.substr(3, 1).repeat(2); - } - - if(bg_filter && fc_filter){ - if(!(bg in bg_colorMap) && (!(fc in fc_colorMap) || cell == null || isRealNull(cell.v))){ - rowhidden[r] = 0; - } - } - else if(bg_filter){ - if(!(bg in bg_colorMap)){ - rowhidden[r] = 0; - } - } - else if(fc_filter){ - if(!(fc in fc_colorMap) || cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - } - } - - let $top = $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c); - - let optionstate = Object.keys(rowhidden).length > 0; - - let rowhiddenall = $.extend(true, rowhiddenother, rowhidden), - rowhidenPre = json.parseJsonParm($top.data("rowhidden")); - - labelFilterOptionState($top, optionstate, rowhidden, caljs, true, st_r, ed_r, cindex, st_c, ed_c); - - let cfg = $.extend(true, {}, Store.config); - cfg["rowhidden"] = rowhiddenall; - - //保存撤销 - if(Store.clearjfundo){ - let redo = {}; - redo["type"] = "datachangeAll_filter"; - redo["sheetIndex"] = Store.currentSheetIndex; - - redo["config"] = $.extend(true, {}, Store.config); - redo["curconfig"] = cfg; - - redo["optionstate"] = optionstate; - redo["optionsindex"] = cindex - st_c; - - redo["rowhidden"] = $.extend(true, {}, rowhidden); - redo["rowhidenPre"] = $.extend(true, {}, rowhidenPre); - - if (caljs != null) { - redo["caljs"] = caljs; - } - - Store.jfundo = []; - Store.jfredo.push(redo); - } - - //config - Store.config = cfg; - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; - - server.saveParam("cg", Store.currentSheetIndex, cfg["rowhidden"], { "k": "rowhidden" }); - - //行高、列宽 刷新 - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); - - $("#luckysheet-filter-menu, #luckysheet-filter-submenu, #luckysheet-filter-orderby-color-submenu").hide(); - cleargridelement(); - }); - - //点击复选框 - $(document).off("click.filterCheckbox1").on("click.filterCheckbox1", "#luckysheet-filter-byvalue-select .textBox",function(){ - if($(this).attr("data-check") == "true"){ - $(this).attr("data-check", "false"); - $(this).find("input[type='checkbox']").removeAttr("checked"); - } - else{ - $(this).attr("data-check", "true"); - $(this).find("input[type='checkbox']").prop("checked", true); - } - }) - $(document).off("click.filterCheckbox2").on("click.filterCheckbox2", "#luckysheet-filter-byvalue-select .year",function(){ - if($(this).attr("data-check") == "true"){ - $(this).attr("data-check", "false"); - $(this).parents(".yearBox").find(".month").attr("data-check", "false"); - $(this).parents(".yearBox").find(".day").attr("data-check", "false"); - $(this).parents(".yearBox").find("input[type='checkbox']").removeAttr("checked"); - } - else{ - $(this).attr("data-check", "true"); - $(this).parents(".yearBox").find(".month").attr("data-check", "true"); - $(this).parents(".yearBox").find(".day").attr("data-check", "true"); - $(this).parents(".yearBox").find("input[type='checkbox']").prop("checked", true); - } - }) - $(document).off("click.filterCheckbox3").on("click.filterCheckbox3", "#luckysheet-filter-byvalue-select .month",function(){ - //月份 对应的 天 - if($(this).attr("data-check") == "true"){ - $(this).attr("data-check", "false"); - $(this).parents(".monthBox").find(".day").attr("data-check", "false"); - $(this).parents(".monthBox").find("input[type='checkbox']").removeAttr("checked"); - } - else{ - $(this).attr("data-check", "true"); - $(this).parents(".monthBox").find(".day").attr("data-check", "true"); - $(this).parents(".monthBox").find("input[type='checkbox']").prop("checked", true); - } - //月份 对应的 年份 - let yearDayAllCheck = true; - let $yearDay = $(this).parents(".yearBox").find(".day"); - $yearDay.each(function(i,e){ - if($(e).attr("data-check") == "true"){ - - } - else{ - yearDayAllCheck = false; - } - }); - if(yearDayAllCheck){ - $(this).parents(".yearBox").find(".year").attr("data-check", "true"); - $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true); - } - else{ - $(this).parents(".yearBox").find(".year").attr("data-check", "false"); - $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked"); - } - }) - $(document).off("click.filterCheckbox4").on("click.filterCheckbox4", "#luckysheet-filter-byvalue-select .day",function(){ - if($(this).attr("data-check") == "true"){ - $(this).attr("data-check", "false"); - $(this).find("input[type='checkbox']").removeAttr("checked"); - } - else{ - $(this).attr("data-check", "true"); - $(this).find("input[type='checkbox']").prop("checked", true); - } - //天 对应的 月份 - let monthDayAllCheck = true; - let $monthDay = $(this).parents(".monthBox").find(".day"); - $monthDay.each(function(i,e){ - if($(e).attr("data-check") == "true"){ - - } - else{ - monthDayAllCheck = false; - } - }); - if(monthDayAllCheck){ - $(this).parents(".monthBox").find(".month").attr("data-check", "true"); - $(this).parents(".monthBox").find(".month input[type='checkbox']").prop("checked", true); - } - else{ - $(this).parents(".monthBox").find(".month").attr("data-check", "false"); - $(this).parents(".monthBox").find(".month input[type='checkbox']").removeAttr("checked"); - } - //天 对应的 年份 - let yearDayAllCheck = true; - let $yearDay = $(this).parents(".yearBox").find(".day"); - $yearDay.each(function(i,e){ - if($(e).attr("data-check") == "true"){ - - } - else{ - yearDayAllCheck = false; - } - }); - if(yearDayAllCheck){ - $(this).parents(".yearBox").find(".year").attr("data-check", "true"); - $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true); - } - else{ - $(this).parents(".yearBox").find(".year").attr("data-check", "false"); - $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked"); - } - }) - - //日期 三级下拉显示 - $(document).off("click.filterYearDropdown").on("click.filterYearDropdown", "#luckysheet-filter-byvalue-select .yearBox .fa-caret-right",function(event){ - let $p = $(this).parents(".luckysheet-mousedown-cancel"); - if($p.hasClass("year")){ - $(this).parents(".yearBox").find(".monthList").slideToggle(); - } - if($p.hasClass("month")){ - $(this).parents(".monthBox").find(".dayList").slideToggle(); - } - - event.stopPropagation(); - }); - - //全选 - $("#luckysheet-filter-byvalue-btn-all").click(function () { - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").prop("checked", true); - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "true"); - }); - - //清除 - $("#luckysheet-filter-byvalue-btn-clear").click(function () { - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").removeAttr("checked"); - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "false"); - }); - - //反选 - $("#luckysheet-filter-byvalue-btn-contra").click(function () { - let $input = $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']"); - $input.each(function(i, e){ - if($(e).is(":checked")){ - $(e).removeAttr("checked"); - $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "false"); - } - else{ - $(e).prop("checked", true); - $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "true"); - } - }); - //天 对应的 月份 - let $month = $("#luckysheet-filter-byvalue-select .ListBox .monthBox"); - $month.each(function(index, event){ - let monthDayAllCheck = true; - let $monthDay = $(event).find(".day input[type='checkbox']"); - $monthDay.each(function(i,e){ - if($(e).is(":checked")){ - - } - else{ - monthDayAllCheck = false; - } - }); - if(monthDayAllCheck){ - $(event).find(".month input[type='checkbox']").prop("checked", true); - $(event).attr("data-check", "true"); - } - else{ - $(event).find(".month input[type='checkbox']").removeAttr("checked"); - $(event).attr("data-check", "false"); - } - }); - //天 对应的 年份 - let $year = $("#luckysheet-filter-byvalue-select .ListBox .yearBox"); - $year.each(function(index, event){ - let yearDayAllCheck = true; - let $yearDay = $(event).find(".day input[type='checkbox']"); - $yearDay.each(function(i,e){ - if($(e).is(":checked")){ - - } - else{ - yearDayAllCheck = false; - } - }); - if(yearDayAllCheck){ - $(event).find(".year input[type='checkbox']").prop("checked", true); - $(event).attr("data-check", "true"); - } - else{ - $(event).find(".year input[type='checkbox']").removeAttr("checked"); - $(event).attr("data-check", "false"); - } - }); - }); - - //清除筛选 - $("#luckysheet-filter-initial").click(function () { - $("#luckysheet-filter-menu .luckysheet-filter-selected-input").hide().find("input").val(); - $("#luckysheet-filter-selected span").data("type", "0").data("type", null).text("无"); - - $('#luckysheet-filter-selected-sheet' + Store.currentSheetIndex + ', #luckysheet-filter-options-sheet' + Store.currentSheetIndex).remove(); - $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - - let redo = {}; - redo["type"] = "datachangeAll_filter_clear"; - redo["sheetIndex"] = Store.currentSheetIndex; - - redo["config"] = $.extend(true, {}, Store.config); - Store.config["rowhidden"] = {}; - redo["curconfig"] = $.extend(true, {}, Store.config); - - redo["filter_save"] = $.extend(true, {}, Store.luckysheet_filter_save); - - let optiongroups = []; - $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").each(function () { - let $t = $(this); - - let optionstate = $t.hasClass("luckysheet-filter-options-active"); - let rowhidden = json.parseJsonParm($t.data("rowhidden")); - let caljs = json.parseJsonParm($t.data("caljs")); - - optiongroups.push({ - "optionstate":optionstate, - "rowhidden": rowhidden, - "caljs":caljs, - "str": $t.data("str"), - "edr": $t.data("edr"), - "cindex": $t.data("cindex"), - "stc": $t.data("stc"), - "edc": $t.data("edc") - }); - }); - redo["optiongroups"] = optiongroups; - - Store.jfundo = []; - Store.jfredo.push(redo); - - //清除筛选发送给后台 - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter = null; - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].filter_select = null; - - server.saveParam("fsc", Store.currentSheetIndex, null); - - //config - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; - - server.saveParam("cg", Store.currentSheetIndex, {}, { "k": "rowhidden" }); - - //行高、列宽 刷新 - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); - }); - - //按照值进行筛选 - $("#luckysheet-filter-byvalue-input").on('input propertychange', function () { - let v = $(this).val().toString(); - $("#luckysheet-filter-byvalue-select .ListBox .luckysheet-mousedown-cancel").show(); - - if(v != ""){ - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").each(function(i, e){ - if($(e).closest(".day").length > 0){ - let day = $(e).siblings("label").text().toString(); - let month = $(e).closest(".monthBox").find(".month label").text().toString(); - let year = $(e).closest(".yearBox").find(".year label").text().toString(); - let itemV = year + "-" + month + "-" + day; - - if(itemV.indexOf(v) == -1){ - $(e).closest(".day").hide(); - - //天 对应的 月份 - let $monthDay = $(e).closest(".dayList").find(".day:visible"); - if($monthDay.length == 0){ - $(e).closest(".monthBox").find(".month").hide(); - } - - //天 对应的 年份 - let $yearDay = $(e).closest(".monthList").find(".day:visible"); - if($yearDay.length == 0){ - $(e).closest(".yearBox").find(".year").hide(); - } - } - } - - if($(e).closest(".textBox").length > 0){ - let itemV = $(e).siblings("label").text().toString(); - - if(itemV.indexOf(v) == -1){ - $(e).parents(".textBox").hide(); - } - } - }); - } - }); - - //筛选取消 - $("#luckysheet-filter-cancel").click(function () { - $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - }); - - //筛选 确认 - $("#luckysheet-filter-confirm").click(function () { - let $menu = $("#luckysheet-filter-menu"); - let st_r = $menu.data("str"), - ed_r = $menu.data("edr"), - cindex = $menu.data("cindex"), - st_c = $menu.data("stc"), - ed_c = $menu.data("edc"); - - let rowhiddenother = {}; //其它筛选列的隐藏行 - $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").not($("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c).get(0)).each(function () { - let $t = $(this), rh = $t.data("rowhidden"); - - if (rh == "") { - return true; - } - - rh = JSON.parse(rh.replace(/\'/g, '"')); - - for (let r in rh) { - rowhiddenother[r] = 0; - } - }); - - let filterdata = {}; - let rowhidden = {}; - let caljs = {}; - - if ($("#luckysheet-filter-bycondition").next().is(":visible") && $("#luckysheet-filter-byvalue").next().is(":hidden") && $("#luckysheet-filter-selected span").data("value") != "null") { - let $t = $("#luckysheet-filter-selected span"); - let type = $t.data("type"), value = $t.data("value"); - - caljs["value"] = value; - caljs["text"] = $t.text(); - - if (type == "0") { - caljs["type"] = "0"; - } - else if (type == "2") { - let $input = $("#luckysheet-filter-menu .luckysheet-filter-selected-input2 input"); - caljs["type"] = "2"; - caljs["value1"] = $input.eq(0).val(); - caljs["value2"] = $input.eq(1).val(); - } - else { - caljs["type"] = "1"; - caljs["value1"] = $("#luckysheet-filter-menu .luckysheet-filter-selected-input").eq(0).find("input").val(); - } - - for (let r = st_r + 1; r <= ed_r; r++) { - if(r in rowhiddenother){ - continue; - } - - if(Store.flowdata[r] == null){ - continue; - } - - let cell = Store.flowdata[r][cindex]; - - if (value == "cellnull") { //单元格为空 - if(cell != null && !isRealNull(cell.v)){ - rowhidden[r] = 0; - } - } - else if (value == "cellnonull") { //单元格有数据 - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - } - else if (value == "textinclude") { //文本包含 - let value1 = caljs["value1"]; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else{ - if(cell.m.indexOf(value1) == -1){ - rowhidden[r] = 0; - } - } - } - else if (value == "textnotinclude") { //文本不包含 - let value1 = caljs["value1"]; - - if(cell == null || isRealNull(cell.v)){ - - } - else{ - if(cell.m.indexOf(value1) > -1){ - rowhidden[r] = 0; - } - } - } - else if (value == "textstart") { //文本开头为 - let value1 = caljs["value1"], valuelen = value1.length; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else{ - if(cell.m.substr(0, valuelen) != value1){ - rowhidden[r] = 0; - } - } - } - else if (value == "textend") { //文本结尾为 - let value1 = caljs["value1"], valuelen = value1.length; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else{ - if(valuelen > cell.m.length || cell.m.substr(cell.m.length - valuelen, valuelen) != value1){ - rowhidden[r] = 0; - } - } - } - else if (value == "textequal") { //文本等于 - let value1 = caljs["value1"]; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else{ - if(cell.m != value1){ - rowhidden[r] = 0; - } - } - } - else if (value == "dateequal") { //日期等于 - let value1 = genarate(caljs["value1"])[2]; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "d"){ - if(parseInt(cell.v) != value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "datelessthan") { //日期早于 - let value1 = genarate(caljs["value1"])[2]; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "d"){ - if(parseInt(cell.v) >= value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "datemorethan") { //日期晚于 - let value1 = genarate(caljs["value1"])[2]; - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "d"){ - if(parseInt(cell.v) <= value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "morethan") { //大于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v <= value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "moreequalthan") { //大于等于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v < value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "lessthan") { //小于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v >= value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "lessequalthan") { //小于等于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v > value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "equal") { //等于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v != value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "noequal") { //不等于 - let value1 = parseFloat(caljs["value1"]); - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v == value1){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "include") { //介于 - let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]); - - let min, max; - if(value1 < value2){ - min = value1; - max = value2; - } - else{ - max = value1; - min = value2; - } - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v < min || cell.v > max){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - else if (value == "noinclude") { //不在其中 - let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]); - - let min, max; - if(value1 < value2){ - min = value1; - max = value2; - } - else{ - max = value1; - min = value2; - } - - if(cell == null || isRealNull(cell.v)){ - rowhidden[r] = 0; - } - else if(cell.ct != null && cell.ct.t == "n"){ - if(cell.v >= min && cell.v <= max){ - rowhidden[r] = 0; - } - } - else{ - rowhidden[r] = 0; - } - } - } - } - else { - $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']").each(function(i, e){ - if($(e).is(":visible") && $(e).is(":checked")){ - return true; - } - - if($(e).closest(".day").length > 0){ - let day = $(e).siblings("label").text(); - if(Number(day) < 10){ - day = "0" + Number(day); - } - - let month = $(e).closest(".monthBox").find(".month label").text().replace("月", ""); - if(Number(month) < 10){ - month = "0" + Number(month); - } - - let year = $(e).closest(".yearBox").find(".year label").text().replace("年", ""); - - let itemV = "日期格式#$$$#" + year + "-" + month + "-" + day; - - filterdata[itemV] = "1"; - } - - if($(e).closest(".textBox").length > 0){ - let itemV = $(e).closest(".textBox").data("filter"); - - filterdata[itemV] = "1"; - } - }); - - for (let r = st_r + 1; r <= ed_r; r++) { - if(r in rowhiddenother){ - continue; - } - - if(Store.flowdata[r] == null){ - continue; - } - - let cell = Store.flowdata[r][cindex]; - - let value; - if(cell == null || isRealNull(cell.v)){ - value = "null#$$$#null"; - } - else if(cell.ct != null && cell.ct.t == "d"){ - let fmt = update("YYYY-MM-DD", cell.v); - value = "日期格式#$$$#" + fmt; - } - else{ - value = cell.v + "#$$$#" + cell.m; - } + let binStr = atob(dataURI.split(",")[1]), + len = binStr.length, + arr = new Uint8Array(len); - if(value in filterdata){ - rowhidden[r] = 0; - } - } + for(let i = 0; i < len; i++){ + arr[i] = binStr.charCodeAt(i); } - let $top = $("#luckysheet-filter-options-sheet" + Store.currentSheetIndex + " .luckysheet-filter-options").eq(cindex - st_c); - - let optionstate = $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']:visible:checked").length < $("#luckysheet-filter-byvalue-select .ListBox input[type='checkbox']:visible").length || $("#luckysheet-filter-byvalue-input").val().length > 0 || ($("#luckysheet-filter-bycondition").next().is(":visible") && $("#luckysheet-filter-byvalue").next().is(":hidden") && $("#luckysheet-filter-selected span").data("value") != "null"); + let blob = new Blob([arr]); - let rowhiddenall = $.extend(true, rowhiddenother, rowhidden), - rowhidenPre = json.parseJsonParm($top.data("rowhidden")); + let element = document.createElement('a'); + element.setAttribute('href', URL.createObjectURL(blob)); + element.setAttribute('download', locale_screenshot.screenshotImageName+'.png'); - labelFilterOptionState($top, optionstate, rowhidden, caljs, true, st_r, ed_r, cindex, st_c, ed_c); + element.style.display = 'none'; + document.body.appendChild(element); - let cfg = $.extend(true, {}, Store.config); - cfg["rowhidden"] = rowhiddenall; + element.click(); - //保存撤销 - if(Store.clearjfundo){ - let redo = {}; - redo["type"] = "datachangeAll_filter"; - redo["sheetIndex"] = Store.currentSheetIndex; + let clickHandler; + element.addEventListener('click', clickHandler = function(){ + requestAnimationFrame(function(){ + URL.revokeObjectURL(element.href); + }); - redo["config"] = $.extend(true, {}, Store.config); - redo["curconfig"] = cfg; + element.removeAttribute('href'); + element.removeEventListener('click', clickHandler); + }) - redo["optionstate"] = optionstate; - redo["optionsindex"] = cindex - st_c; + document.body.removeChild(element); + }) + + //菜单栏 分列按钮 + $("#luckysheet-splitColumn-btn-title").click(function(){ + if(Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0){ + return; + } - redo["rowhidden"] = $.extend(true, {}, rowhidden); - redo["rowhidenPre"] = $.extend(true, {}, rowhidenPre); + const locale_splitText = _locale.splitText; - if (caljs != null) { - redo["caljs"] = caljs; - } + if(Store.luckysheet_select_save.length > 1){ + tooltip.info(locale_splitText.tipNoMulti, ""); + return; + } - Store.jfundo = []; - Store.jfredo.push(redo); + if(Store.luckysheet_select_save[0].column[0] != Store.luckysheet_select_save[0].column[1]){ + tooltip.info(locale_splitText.tipNoMultiColumn, ""); + return; } - //config - Store.config = cfg; - Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + splitColumn.createDialog(); + splitColumn.init(); + }); - server.saveParam("cg", Store.currentSheetIndex, cfg["rowhidden"], { "k": "rowhidden" }); + //冻结行列 + $("#luckysheet-freezen-btn-horizontal").click(function () { + if($.trim($(this).text())==locale().freezen.freezenCancel){ + if (luckysheetFreezen.freezenverticaldata != null) { + luckysheetFreezen.cancelFreezenVertical(); + luckysheetFreezen.createAssistCanvas(); + luckysheetrefreshgrid(); + } - //行高、列宽 刷新 - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + if (luckysheetFreezen.freezenhorizontaldata != null) { + luckysheetFreezen.cancelFreezenHorizontal(); + luckysheetFreezen.createAssistCanvas(); + luckysheetrefreshgrid(); + } - $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); - cleargridelement(); - }); + luckysheetFreezen.scrollAdapt(); + } + else{ + if (luckysheetFreezen.freezenverticaldata != null) { + luckysheetFreezen.cancelFreezenVertical(); + luckysheetFreezen.createAssistCanvas(); + luckysheetrefreshgrid(); + } - //左上角返回按钮 - $("#luckysheet_info_detail_title").click(function(){ - window.open(luckysheetConfigsetting.myFolderUrl, "_self"); + if (luckysheetFreezen.freezenhorizontaldata == null) { + luckysheetFreezen.createFreezenHorizontal(); + luckysheetFreezen.createAssistCanvas(); + } + } }); - $("#luckysheet_info_detail_input").val(server.title).css("width", getByteLen(server.title) * 10).keydown(function(){ - let ctrlKey = event.ctrlKey; - let altKey = event.altKey; - let shiftKey = event.shiftKey; - let kcode = event.keyCode; - let $t = $(this); - if(kcode == keycode.ENTER){ - $t.blur().change(); - } - }).bind('input propertychange', function() { - let $t = $(this); - let inputlen = getByteLen($t.val())*10; - let updatelen = $("#luckysheet_info_detail_update").outerWidth(); - let savelen = $("#luckysheet_info_detail_save").outerWidth(); - let userlen = $("#luckysheet_info_detail_user").parent().outerWidth()+60; - let containerlen = $("#" + Store.container).outerWidth(); - let otherlen = 100; - - let minuslen = containerlen- savelen - updatelen - userlen - otherlen; - if(inputlen > minuslen){ - $("#luckysheet_info_detail_input").css("width", minuslen); + $("#luckysheet-freezen-btn-vertical").click(function () { + if (luckysheetFreezen.freezenverticaldata != null) { + luckysheetFreezen.cancelFreezenVertical(); + luckysheetrefreshgrid(); } - else{ - $("#luckysheet_info_detail_input").css("width", inputlen); + else { + luckysheetFreezen.createFreezenVertical(); } - }).change(function(){ - server.saveParam("na", null, $(this).val()); + luckysheetFreezen.createAssistCanvas(); }); - //公式栏处理 - $("#luckysheet-functionbox-cell").focus(function () { - if(isEditMode()){//此模式下禁用公式栏 - return; - } + $("#luckysheet-rightclick-menu input").on("keydown", function (e) { + e.stopPropagation(); + }); - if(Store.luckysheet_select_save.length > 0){ - let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + $("#luckysheet-modal-dialog-mask").on("click dbclick mousedown mousemove mouseup", function (e) { + e.stopPropagation(); + e.preventDefault(); + }); - let row_index = last["row_focus"], col_index = last["column_focus"]; - let row = Store.visibledatarow[row_index], - row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; - let col = Store.visibledatacolumn[col_index], - col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; - - let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); - if(!!margeset){ - row = margeset.row[1]; - row_pre = margeset.row[0]; - row_index = margeset.row[2]; - col = margeset.column[1]; - col_pre = margeset.column[0]; - col_index = margeset.column[2]; - } - - luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, null, true); - formula.rangeResizeTo = $("#luckysheet-functionbox-cell"); - } - }).keydown(function (event) { - if(isEditMode()){//此模式下禁用公式栏 - return; + let copychange = function () { + if (document.hidden || document.webkitHidden || document.msHidden) { + Store.iscopyself = false; } + } - let ctrlKey = event.ctrlKey; - let altKey = event.altKey; - let shiftKey = event.shiftKey; - let kcode = event.keyCode; - let $inputbox = $("#luckysheet-input-box"); + $(document).on("visibilitychange webkitvisibilitychange msvisibilitychange", copychange).mouseleave(function () { + Store.iscopyself = false; + }).mousedown(function (event) { + //有批注在编辑时 + luckysheetPostil.removeActivePs(); - if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { - if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { - formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); - } - else { - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - Store.luckysheet_select_save = [{ "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], "row_focus": Store.luckysheetCellUpdate[0], "column_focus": Store.luckysheetCellUpdate[1] }]; - luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); - $("#luckysheet-functionbox-cell").blur(); - } - event.preventDefault(); + if (!$(event.target).hasClass("luckysheet-mousedown-cancel") && $(event.target).filter("[class*='sp-palette']").length == 0 && $(event.target).filter("[class*='sp-thumb']").length == 0 && $(event.target).filter("[class*='sp-']").length == 0) { + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-cols-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide(); + $("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide(); + //$("body > luckysheet-menuButton").hide(); + Store.luckysheet_cols_menu_status = false; } - else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { - formula.dontupdate(); + + //点击功能栏时 如果是单元格编辑模式 则退出编辑模式 + if($(event.target).closest("#luckysheet-wa-editor").length > 0 && parseInt($("#luckysheet-input-box").css("top")) > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); - event.preventDefault(); - } - else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { - formula.setfreezonFuc(event); - event.preventDefault(); - } - else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { - if ($("#luckysheet-formula-search-c").is(":visible")) { - let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").prev(); - if ($up.length == 0) { - $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").last(); - } - $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); - $up.addClass("luckysheet-formula-search-item-active"); - event.preventDefault(); - } - } - else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { - if ($("#luckysheet-formula-search-c").is(":visible")) { - let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); - if ($up.length == 0) { - $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); - } - $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); - $up.addClass("luckysheet-formula-search-item-active"); - event.preventDefault(); - } - } - else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { - formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); - } - else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { - formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); - } - else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { - formula.functionInputHanddler($("#luckysheet-rich-text-editor"), $("#luckysheet-functionbox-cell"), kcode); - } - }).click(function () { - if(isEditMode()){//此模式下禁用公式栏 - return; } - - formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); }); - //公式栏 取消(X)按钮 - $("#luckysheet-wa-functionbox-cancel").click(function () { - if (!$(this).hasClass("luckysheet-wa-calculate-active")) { - return; - } - //若有参数弹出框,隐藏 - if($("#luckysheet-search-formula-parm").is(":visible")){ - $("#luckysheet-search-formula-parm").hide(); - } - //若有参数选取范围弹出框,隐藏 - if($("#luckysheet-search-formula-parm-select").is(":visible")){ - $("#luckysheet-search-formula-parm-select").hide(); - } + //表格左上角点击 全选表格 + $("#luckysheet-left-top").mousedown(function (event) { + $("#luckysheet-wa-functionbox-confirm").click(); + Store.luckysheet_select_status = false; + + Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0 }]; + selectHightlightShow(); + + clearTimeout(Store.countfuncTimeout); + Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500); - formula.dontupdate(); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + event.stopPropagation(); }); - //公式栏 确认()按钮 - $("#luckysheet-wa-functionbox-confirm").click(function () { - if (!$(this).hasClass("luckysheet-wa-calculate-active")) { - return; - } - //若有参数弹出框,隐藏 - if($("#luckysheet-search-formula-parm").is(":visible")){ - $("#luckysheet-search-formula-parm").hide(); - } - //若有参数选取范围弹出框,隐藏 - if($("#luckysheet-search-formula-parm-select").is(":visible")){ - $("#luckysheet-search-formula-parm-select").hide(); - } - formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); - luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + //回退 重做 按钮 + $("#luckysheet-icon-undo").click(function (event) { + controlHistory.redo(event); + }); + $("#luckysheet-icon-redo").click(function (event) { + controlHistory.undo(event); }); - //公式栏 fx按钮 - $("#luckysheet-wa-functionbox-fx").click(function () { - //点击函数查找弹出框 - if(Store.luckysheet_select_save.length == 0){ - if(isEditMode()){ - alert("请选择单元格插入函数"); - } - else{ - tooltip.info("请选择单元格插入函数",""); - } + + //模态框拖动 + $(document).on("mousedown", "div.luckysheet-modal-dialog", function (e) { + if (!$(e.target).is(".luckysheet-modal-dialog")) { return; } - let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; - - let row_index = last["row_focus"], col_index = last["column_focus"]; - let row = Store.visibledatarow[row_index], - row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; - let col = Store.visibledatacolumn[col_index], - col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; - - luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); - - let cell = Store.flowdata[row_index][col_index]; - if(cell != null && cell.f != null){ - //单元格有计算 - let functionStr = formula.getfunctionParam(cell.f); - if(functionStr.fn != null){ - //有函数公式 - insertFormula.formulaParmDialog(functionStr.fn, functionStr.param); - } - else{ - //无函数公式 - insertFormula.formulaListDialog(); - } - } - else{ - //单元格无计算 - $("#luckysheet-rich-text-editor").html('='); - $("#luckysheet-functionbox-cell").html($("#luckysheet-rich-text-editor").html()); - insertFormula.formulaListDialog(); - } + Store.luckysheet_model_move_state = true; - insertFormula.init(); + Store.luckysheet_model_move_obj = $(e.currentTarget); + let toffset = Store.luckysheet_model_move_obj.offset(); + Store.luckysheet_model_xy = [e.pageX - toffset.left, e.pageY - toffset.top]; }); - //公式选区操作 - $("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-copy", function (event) { - formula.rangeMove = true; - Store.luckysheet_scroll_status = true; - formula.rangeMoveObj = $(this).parent(); - formula.rangeMoveIndex = $(this).parent().attr("rangeindex"); - - let mouse = mouseposition(event.pageX, event.pageY); - let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft(); - let y = mouse[1] + $("#luckysheet-cell-main").scrollTop(); - $("#luckysheet-formula-functionrange-highlight-" + formula.rangeMoveIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); - - let type = $(this).data("type"); - if (type == "top") { - y += 3; + //模态框关闭 + $(document).on("click", ".luckysheet-modal-dialog-title-close, .luckysheet-model-close-btn", function (e) { + //选择文本颜色和单元格颜色弹出框取消 + if($("#textcolorselect").is(":visible")||$("#cellcolorselect").is(":visible")){ + $("#luckysheet-conditionformat-dialog").show(); } - else if (type == "right") { - x -= 3; + $(e.currentTarget).parents(".luckysheet-modal-dialog").hide(); + $("#luckysheet-modal-dialog-mask").hide(); + + //函数查找功能所有弹出框关闭和取消 + if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula")){ + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); } - else if (type == "bottom") { - y -= 3; + if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm")){ + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); } - else if (type == "left") { - x += 3; + if($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm-select")){ + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); } - let row_index = rowLocation(y)[2]; - let col_index = colLocation(x)[2]; - - formula.rangeMovexy = [row_index, col_index]; - $("#luckysheet-sheettable").css("cursor", "move"); - event.stopPropagation(); + $("#" + Store.container).attr("tabindex", 0).focus(); }); - $("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-highlight", function (e) { - formula.rangeResize = $(this).data("type");//开始状态resize - formula.rangeResizeIndex = $(this).parent().attr("rangeindex"); - - let mouse = mouseposition(e.pageX, e.pageY), - scrollLeft = $("#luckysheet-cell-main").scrollLeft(), - scrollTop = $("#luckysheet-cell-main").scrollTop(); - let x = mouse[0] + scrollLeft; - let y = mouse[1] + scrollTop; - formula.rangeResizeObj = $(this).parent(); - $("#luckysheet-formula-functionrange-highlight-" + formula.rangeResizeIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); - - if (formula.rangeResize == "lt") { - x += 3; - y += 3; - } - else if (formula.rangeResize == "lb") { - x += 3; - y -= 3; - } - else if (formula.rangeResize == "rt") { - x -= 3; - y += 3; - } - else if (formula.rangeResize == "rb") { - x -= 3; - y -= 3; - } - let row_location = rowLocation(y), - row = row_location[1], - row_pre = row_location[0], - row_index = row_location[2]; - let col_location = colLocation(x), - col = col_location[1], - col_pre = col_location[0], - col_index = col_location[2]; - let position = formula.rangeResizeObj.position(); - formula.rangeResizexy = [ - col_pre, - row_pre, - formula.rangeResizeObj.width(), - formula.rangeResizeObj.height(), - position.left + scrollLeft, - position.top + scrollTop, col, row - ]; - formula.rangeResizeWinH = $("#luckysheet-cell-main")[0].scrollHeight; - formula.rangeResizeWinW = $("#luckysheet-cell-main")[0].scrollWidth; - Store.luckysheet_scroll_status = true; - event.stopPropagation(); + //左上角返回按钮 + $("#luckysheet_info_detail_title").click(function(){ + window.open(luckysheetConfigsetting.myFolderUrl, "_self"); }); + //图表选区mousedown $("#luckysheet-chart-rangeShow").on("mousedown.chartRangeShowMove", ".luckysheet-chart-rangeShow-move", function(event){ Store.chart_selection.rangeMove = true; @@ -10025,10 +3903,20 @@ export default function luckysheetHandler() { luckysheetConfigsetting.pageInfo.currentPage++; if(luckysheetConfigsetting.pageInfo.totalPage == (luckysheetConfigsetting.pageInfo.currentPage)){ $("#luckysheet-bottom-page-next").hide(); - $("#luckysheet-bottom-page-info").html('共'+luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,'+'已显示全部数据'); + let pageInfoFull = replaceHtml(locale_info.pageInfoFull,{ + total:luckysheetConfigsetting.total, + totalPage:luckysheetConfigsetting.pageInfo.totalPage, + }); + $("#luckysheet-bottom-page-info").html(pageInfoFull); } else{ - $("#luckysheet-bottom-page-info").html('共'+luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页'); + let pageInfo = replaceHtml(locale_info.pageInfo,{ + total:luckysheetConfigsetting.total, + totalPage:luckysheetConfigsetting.pageInfo.totalPage, + currentPage:luckysheetConfigsetting.pageInfo.currentPage + + }); + $("#luckysheet-bottom-page-info").html(pageInfo); } }); }).mousedown(function(e){ diff --git a/src/controllers/insertFormula.js b/src/controllers/insertFormula.js index 16f464fd9..8687450c7 100644 --- a/src/controllers/insertFormula.js +++ b/src/controllers/insertFormula.js @@ -1,6 +1,6 @@ import { luckysheet_getcelldata } from '../function/func'; -import functionlist from '../function/functionlist'; -import luckysheet_function from '../function/luckysheet_function'; +// import functionlist from '../function/functionlist'; +// import Store.luckysheet_function from '../function/Store.luckysheet_function'; import formula from '../global/formula'; import { isRealNum, isRealNull } from '../global/validate'; import { modelHTML } from './constant'; @@ -20,6 +20,7 @@ const insertFormula = { $(document).off("keyup.fxSFLI").on("keyup.fxSFLI", "#searchFormulaListInput", function(){ $("#formulaTypeList").empty(); let txt = $(this).val().toUpperCase(); + let functionlist = Store.functionlist; if(txt == ""){ //若没有查找内容则根据类别筛选 @@ -67,16 +68,16 @@ const insertFormula = { formula.data_parm_index = parmIndex; let formulatxt = $(this).parents("#luckysheet-search-formula-parm").find(".luckysheet-modal-dialog-title-text").text(); - let parmLen = luckysheet_function[formulatxt].p.length; + let parmLen = Store.luckysheet_function[formulatxt].p.length; let parmDetail, parmRepeat; if(parmIndex >= parmLen){ - parmDetail = luckysheet_function[formulatxt].p[parmLen - 1].detail; - parmRepeat = luckysheet_function[formulatxt].p[parmLen - 1].repeat; + parmDetail = Store.luckysheet_function[formulatxt].p[parmLen - 1].detail; + parmRepeat = Store.luckysheet_function[formulatxt].p[parmLen - 1].repeat; } else{ - parmDetail = luckysheet_function[formulatxt].p[parmIndex].detail; - parmRepeat = luckysheet_function[formulatxt].p[parmIndex].repeat; + parmDetail = Store.luckysheet_function[formulatxt].p[parmIndex].detail; + parmRepeat = Store.luckysheet_function[formulatxt].p[parmIndex].repeat; } //参数选区显示,参数值显示 @@ -193,7 +194,7 @@ const insertFormula = { "id": "luckysheet-search-formula", "addclass": "luckysheet-search-formula", "title": "", - "content": "
    ", + "content": "
    ", "botton": '', "style": "z-index:100003" })); @@ -209,6 +210,7 @@ const insertFormula = { }, formulaListByType: function(type){ $("#formulaTypeList").empty(); + let functionlist = Store.functionlist; for(let i = 0; i < functionlist.length; i++){ if((type == "-1" && functionlist[i].t > 14) || functionlist[i].t == type){ @@ -225,7 +227,8 @@ const insertFormula = { let _locale = locale(); let locale_formulaMore = _locale.formulaMore; - let locale_button = _locale.button + let locale_button = _locale.button; + let functionlist = Store.functionlist; for(let i = 0; i < functionlist.length; i++){ if(functionlist[i].n == formulaTxt.toUpperCase()){ @@ -428,7 +431,7 @@ const insertFormula = { $("#luckysheet-search-formula-parm .parmBox").each(function(i, e){ let parmtxt = $(e).find(".txt input").val(); - let parmRequire = luckysheet_function[formulatxt].p[i].require; + let parmRequire = Store.luckysheet_function[formulatxt].p[i].require; if(parmtxt == "" && parmRequire == "m"){ isVal = false; diff --git a/src/controllers/keyboard.js b/src/controllers/keyboard.js new file mode 100644 index 000000000..05137df30 --- /dev/null +++ b/src/controllers/keyboard.js @@ -0,0 +1,917 @@ +import luckysheetConfigsetting from './luckysheetConfigsetting'; +import menuButton from './menuButton'; +import conditionformat from './conditionformat'; +import server from './server'; +import luckysheetupdateCell from './updateCell'; +import { keycode } from './constant'; +import { + luckysheetMoveHighlightCell, + luckysheetMoveHighlightCell2, + luckysheetMoveHighlightRange, + luckysheetMoveHighlightRange2 +} from './sheetMove'; +import { selectHightlightShow, selectIsOverlap } from './select'; +import selection from './selection'; +import searchReplace from './searchReplace'; +import controlHistory from './controlHistory'; + +import { + getByteLen, + luckysheetactiveCell, +} from '../utils/util'; +import { getSheetIndex } from '../methods/get'; +import { hasPartMC, isEditMode } from '../global/validate'; +import formula from '../global/formula'; +import cleargridelement from '../global/cleargridelement'; +import tooltip from '../global/tooltip'; +import locale from '../locale/locale'; +import Store from '../store'; + + +let luckysheet_shiftkeydown = false; + +function formulaMoveEvent(dir, ctrlKey, shiftKey){ + if ($("#luckysheet-formula-search-c").is(":visible")) { + let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); + if ($up.length == 0) { + $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); + } + + $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); + $up.addClass("luckysheet-formula-search-item-active"); + + event.preventDefault(); + } + else{ + if($("#luckysheet-formula-functionrange-select").is(":visible")){ + if(ctrlKey && shiftKey){ + luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); + } + else if(ctrlKey){ + luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); + } + else if(shiftKey){ + let dir_n = dir, step = 1; + if(dir == 'up'){ + dir_n = 'down'; + step = -1; + } + if(dir == 'left'){ + dir_n = 'right'; + step = -1; + } + + luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); + } + else{ + let dir_n = dir, step = 1; + if(dir == 'up'){ + dir_n = 'down'; + step = -1; + } + if(dir == 'left'){ + dir_n = 'right'; + step = -1; + } + + luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); + } + } + else if(formula.israngeseleciton()){ + let anchor = $(window.getSelection().anchorNode); + + if(anchor.parent().next().text() == null || anchor.parent().next().text() == ""){ + let vText = $("#luckysheet-input-box #luckysheet-input-box-index").text(); + let range = formula.getcellrange(vText); + + if(range == null){ + range = formula.getcellrange($("#luckysheet-input-box-index").text()); + } + + let r1 = range["row"][0], r2 = range["row"][1]; + let c1 = range["column"][0], c2 = range["column"][1]; + + let row = Store.visibledatarow[r2], + row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; + let col = Store.visibledatacolumn[c2], + col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; + + formula.func_selectedrange = { + "left": col_pre, + "width": col - col_pre - 1, + "top": row_pre, + "height": row - row_pre - 1, + "left_move": col_pre, + "width_move": col - col_pre - 1, + "top_move": row_pre, + "height_move": row - row_pre - 1, + "row": [r1, r2], + "column": [c1, c2], + "row_focus": r1, + "column_focus": c1 + }; + + formula.rangeSetValue({ "row": [r1, r2], "column": [c1, c2] }); + + formula.rangestart = true; + formula.rangedrag_column_start = false; + formula.rangedrag_row_start = false; + + if(ctrlKey && shiftKey){ + luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); + } + else if(ctrlKey){ + luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); + } + else if(shiftKey){ + let dir_n = dir, step = 1; + if(dir == 'up'){ + dir_n = 'down'; + step = -1; + } + if(dir == 'left'){ + dir_n = 'right'; + step = -1; + } + + luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); + } + else{ + let dir_n = dir, step = 1; + if(dir == 'up'){ + dir_n = 'down'; + step = -1; + } + if(dir == 'left'){ + dir_n = 'right'; + step = -1; + } + + luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); + } + } + } + else if(!ctrlKey && !shiftKey){ + let anchor = $(window.getSelection().anchorNode); + let anchorOffset = window.getSelection().anchorOffset; + + if(dir == 'up'){ + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + + event.preventDefault(); + } + } + else if(dir == 'down'){ + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + + event.preventDefault(); + } + } + else if(dir == 'left'){ + if(anchor.parent().is("span") && anchor.parent().prev().length == 0 && anchorOffset == 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchorOffset == 1){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchorOffset == 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + + event.preventDefault(); + } + } + else if(dir == 'right'){ + if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } + else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + + event.preventDefault(); + } + } + } + } +} + +export function keyboardInitial(){ + const _locale = locale(); + const locale_drag = _locale.drag; + + //单元格编辑输入 + $("#luckysheet-input-box").click(function () { + formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); + }).add("#" + Store.container).on("keydown", function (event) { + if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { + return; + } + + let ctrlKey = event.ctrlKey; + let altKey = event.altKey; + let shiftKey = event.shiftKey; + let kcode = event.keyCode; + + if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("sp-input") || (parseInt($("#luckysheet-input-box").css("top")) > 0 && $(event.target).closest(".luckysheet-input-box").length > 0 && kcode != keycode.ENTER && kcode != keycode.TAB && kcode != keycode.UP && kcode != keycode.DOWN && kcode != keycode.LEFT && kcode != keycode.RIGHT)) { + let anchor = $(window.getSelection().anchorNode); + + if(anchor.parent().is("#luckysheet-helpbox-cell") || anchor.is("#luckysheet-helpbox-cell")){ + if(kcode == keycode.ENTER){ + let helpboxValue = $("#luckysheet-helpbox-cell").text(); + + if(formula.iscelldata(helpboxValue)){ + let cellrange = formula.getcellrange(helpboxValue); + + Store.luckysheet_select_save = [{ "row": cellrange["row"], "column": cellrange["column"], "row_focus": cellrange["row"][0], "column_focus": cellrange["column"][0] }]; + selectHightlightShow(); + + $("#luckysheet-helpbox-cell").blur(); + + let scrollLeft = $("#luckysheet-cell-main").scrollLeft(), + scrollTop = $("#luckysheet-cell-main").scrollTop(); + let winH = $("#luckysheet-cell-main").height(), + winW = $("#luckysheet-cell-main").width(); + + let row = Store.visibledatarow[cellrange["row"][1]], + row_pre = cellrange["row"][0] - 1 == -1 ? 0 : Store.visibledatarow[cellrange["row"][0] - 1]; + let col = Store.visibledatacolumn[cellrange["column"][1]], + col_pre = cellrange["column"][0] - 1 == -1 ? 0 : Store.visibledatacolumn[cellrange["column"][0] - 1]; + + if (col - scrollLeft - winW + 20 > 0) { + $("#luckysheet-scrollbar-x").scrollLeft(col - winW + 20); + } + else if (col_pre - scrollLeft - 20 < 0) { + $("#luckysheet-scrollbar-x").scrollLeft(col_pre - 20); + } + + if (row - scrollTop - winH + 20 > 0) { + $("#luckysheet-scrollbar-y").scrollTop(row - winH + 20); + } + else if (row_pre - scrollTop - 20 < 0) { + $("#luckysheet-scrollbar-y").scrollTop(row_pre - 20); + } + } + } + } + + return; + } + + let $inputbox = $("#luckysheet-input-box"); + + if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { + if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { + formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); + } + else { + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + Store.luckysheet_select_save = [{ + "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], + "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], + "row_focus": Store.luckysheetCellUpdate[0], + "column_focus": Store.luckysheetCellUpdate[1] + }]; + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + } + + //若有参数弹出框,隐藏 + if($("#luckysheet-search-formula-parm").is(":visible")){ + $("#luckysheet-search-formula-parm").hide(); + } + //若有参数选取范围弹出框,隐藏 + if($("#luckysheet-search-formula-parm-select").is(":visible")){ + $("#luckysheet-search-formula-parm-select").hide(); + } + event.preventDefault(); + } + else if (kcode == keycode.TAB) { + if (parseInt($inputbox.css("top")) > 0) { + return; + } + + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + event.preventDefault(); + } + else if(kcode == keycode.F2){ + if (parseInt($inputbox.css("top")) > 0) { + return; + } + + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + let row = Store.visibledatarow[row_index], + row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; + let col = Store.visibledatacolumn[col_index], + col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + + luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); + event.preventDefault(); + } + else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { + formula.setfreezonFuc(event); + event.preventDefault(); + } + else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.ENTER) { + if($(event.target).hasClass("formulaInputFocus") || $("#luckysheet-conditionformat-dialog").is(":visible")){ + return; + } + else if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible")) { + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + let row = Store.visibledatarow[row_index], + row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; + let col = Store.visibledatacolumn[col_index], + col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + + let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); + if(!!margeset){ + row = margeset.row[1]; + row_pre = margeset.row[0]; + row_index = margeset.row[2]; + col = margeset.column[1]; + col_pre = margeset.column[0]; + col_index = margeset.column[2]; + } + + luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); + event.preventDefault(); + } + } + else { + if (ctrlKey || event.metaKey) { + if (shiftKey) { + if (!luckysheet_shiftkeydown) { + Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); + Store.luckysheet_shiftkeydown = true; + } + + //Ctrl + shift + 方向键 调整选区 + if (kcode == keycode.UP) { + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightRange2("up", "rangeOfSelect"); + } + else if (kcode == keycode.DOWN) { + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightRange2("down", "rangeOfSelect"); + } + else if (kcode == keycode.LEFT) { + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightRange2("left", "rangeOfSelect"); + } + else if (kcode == keycode.RIGHT) { + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightRange2("right", "rangeOfSelect"); + } + } + else if (kcode == 66) {//Ctrl + B 加粗 + $("#luckysheet-icon-bold").click(); + } + else if (kcode == 67) {//Ctrl + C 复制 + //复制时存在格式刷状态,取消格式刷 + if(menuButton.luckysheetPaintModelOn){ + menuButton.cancelPaintModel(); + } + + if(Store.luckysheet_select_save.length == 0){ + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noMerge); + } + else{ + tooltip.info(locale_drag.noMerge, ""); + } + return; + } + } + + //多重选区 有条件格式时 提示 + let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save; + if(Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0){ + let hasCF = false; + + let cf_compute = conditionformat.getComputeMap(); + + label: + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + if(hasCF){ + break; + } + + let r1 = Store.luckysheet_select_save[s].row[0], + r2 = Store.luckysheet_select_save[s].row[1]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + for(let r = r1; r <= r2; r++){ + for(let c = c1; c <= c2; c++){ + if(conditionformat.checksCF(r, c, cf_compute) != null){ + hasCF = true; + continue label; + } + } + } + } + + if(hasCF){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + } + + //多重选区 行不一样且列不一样时 提示 + if(Store.luckysheet_select_save.length > 1){ + let isSameRow = true, + str_r = luckysheet_select_save[0].row[0], + end_r = luckysheet_select_save[0].row[1]; + let isSameCol = true, + str_c = luckysheet_select_save[0].column[0], + end_c = luckysheet_select_save[0].column[1]; + + for(let s = 1; s < luckysheet_select_save.length; s++){ + if(luckysheet_select_save[s].row[0] != str_r || luckysheet_select_save[s].row[1] != end_r){ + isSameRow = false; + } + if(luckysheet_select_save[s].column[0] != str_c || luckysheet_select_save[s].column[1] != end_c){ + isSameCol = false; + } + } + + if((!isSameRow && !isSameCol) || selectIsOverlap()){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + } + + selection.copy(event); + + Store.luckysheet_paste_iscut = false; + luckysheetactiveCell(); + + event.stopPropagation(); + return; + } + else if (kcode == 70) {//Ctrl + F 查找 + searchReplace.createDialog(0); + searchReplace.init(); + + $("#luckysheet-search-replace #searchInput input").focus(); + } + else if (kcode == 72) {//Ctrl + H 替换 + searchReplace.createDialog(1); + searchReplace.init(); + + $("#luckysheet-search-replace #searchInput input").focus(); + } + else if (kcode == 73) {//Ctrl + I 斜体 + $("#luckysheet-icon-italic").click(); + } + else if (kcode == 86) {//Ctrl + V 粘贴 + if(isEditMode()){//此模式下禁用粘贴 + return; + } + + if($(event.target).hasClass("formulaInputFocus")){ + return; + } + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noPaste); + } + else{ + tooltip.info(locale_drag.noPaste, ""); + } + return; + } + + selection.isPasteAction = true; + luckysheetactiveCell(); + + event.stopPropagation(); + return; + } + else if (kcode == 88) {//Ctrl + X 剪切 + //复制时存在格式刷状态,取消格式刷 + if(menuButton.luckysheetPaintModelOn){ + menuButton.cancelPaintModel(); + } + + if(Store.luckysheet_select_save.length == 0){ + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(luckysheetConfigsetting.editMode){ + alert(_locale_drag.noMerge); + } + else{ + tooltip.info(_locale_drag.noMerge, ""); + } + return; + } + } + + //多重选区时 提示 + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + selection.copy(event); + + Store.luckysheet_paste_iscut = true; + luckysheetactiveCell(); + + event.stopPropagation(); + return; + } + else if (kcode == 90) {//Ctrl + Z 撤销 + controlHistory.redo(event); + luckysheetactiveCell(); + event.stopPropagation(); + return; + } + else if (kcode == 89) {//Ctrl + Y 重做 + controlHistory.undo(event); + luckysheetactiveCell(); + event.stopPropagation(); + return; + } + else if (kcode == keycode.UP) {//Ctrl + up 调整单元格 + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell2("up", "rangeOfSelect"); + } + else if (kcode == keycode.DOWN) {//Ctrl + down 调整单元格 + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell2("down", "rangeOfSelect"); + } + else if (kcode == keycode.LEFT) {//Ctrl + top 调整单元格 + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell2("left", "rangeOfSelect"); + } + else if (kcode == keycode.RIGHT) {//Ctrl + right 调整单元格 + if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell2("right", "rangeOfSelect"); + } + else if (String.fromCharCode(kcode).toLocaleUpperCase() == "A") {//Ctrl + A 全选 + $("#luckysheet-left-top").trigger("mousedown"); + $(document).trigger("mouseup"); + } + + event.preventDefault(); + return; + } + else if (shiftKey && (kcode == keycode.UP || kcode == keycode.DOWN || kcode == keycode.LEFT || kcode == keycode.RIGHT || (altKey && (kcode == 53 || kcode == 101)))) { + if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus")) { + return; + } + + if (!luckysheet_shiftkeydown) { + Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); + Store.luckysheet_shiftkeydown = true; + } + + //shift + 方向键 调整选区 + if (kcode == keycode.UP) { + if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ + return; + } + + luckysheetMoveHighlightRange("down", -1, "rangeOfSelect"); + } + else if (kcode == keycode.DOWN) { + if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ + return; + } + + luckysheetMoveHighlightRange("down", 1, "rangeOfSelect"); + } + else if (kcode == keycode.LEFT) { + if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ + return; + } + + luckysheetMoveHighlightRange("right", -1, "rangeOfSelect"); + } + else if (kcode == keycode.RIGHT) { + if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ + return; + } + + luckysheetMoveHighlightRange("right", 1, "rangeOfSelect"); + } + else if (altKey && (kcode == 53 || kcode == 101)) { + //Alt + Shift + 5(删除线) + $("#luckysheet-icon-strikethrough").click(); + } + + event.preventDefault(); + } + else if (kcode == keycode.ESC) { + if(menuButton.luckysheetPaintModelOn){ + menuButton.cancelPaintModel(); + } + else{ + cleargridelement(event); + event.preventDefault(); + } + + selectHightlightShow(); + } + else if (kcode == keycode.DELETE) { + $("#luckysheet-delete-text").click(); + + event.preventDefault(); + } + else if (kcode == keycode.UP) { + if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.DOWN) { + if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.LEFT) { + if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.RIGHT) { + if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { + return; + } + + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + event.preventDefault(); + } + else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || kcode == 0 || (event.ctrlKey && kcode == 86)) { + if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible") && (kcode != keycode.CAPSLOCK && kcode != keycode.WIN && kcode != 18)) { + let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; + + let row_index = last["row_focus"], col_index = last["column_focus"]; + let row = Store.visibledatarow[row_index], + row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; + let col = Store.visibledatacolumn[col_index], + col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; + + let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); + if(!!margeset){ + row = margeset.row[1]; + row_pre = margeset.row[0]; + row_index = margeset.row[2]; + col = margeset.column[1]; + col_pre = margeset.column[0]; + col_index = margeset.column[2]; + } + + luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, true); + if(kcode == 8){ + $("#luckysheet-rich-text-editor").html("
    "); + } + formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); + } + } + } + + luckysheetactiveCell(); + + event.stopPropagation(); + }); + + //单元格编辑 keydown (公式 上下左右键移动) + $("#" + Store.container).add("#luckysheet-input-box").keydown(function (event) { + if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { + return; + } + + let ctrlKey = event.ctrlKey; + let altKey = event.altKey; + let shiftKey = event.shiftKey; + let kcode = event.keyCode; + + let $inputbox = $("#luckysheet-input-box"); + if (kcode == keycode.ESC && parseInt($("#luckysheet-input-box").css("top")) > 0) { + formula.dontupdate(); + luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); + event.preventDefault(); + } + else if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { + if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { + formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); + event.preventDefault(); + } + } + else if(kcode == keycode.TAB && parseInt($inputbox.css("top")) > 0){ + if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { + formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); + } + else{ + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); + } + + event.preventDefault(); + } + else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { + formula.setfreezonFuc(event); + event.preventDefault(); + } + else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { + formulaMoveEvent("up", ctrlKey, shiftKey); + } + else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { + formulaMoveEvent("down", ctrlKey, shiftKey); + } + else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { + formulaMoveEvent("left", ctrlKey, shiftKey); + } + else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { + formulaMoveEvent("right", ctrlKey, shiftKey); + } + else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { + formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); + } + }).keyup(function (e) { + let kcode = e.keyCode; + + if (!e.shiftKey && kcode == 16) { + Store.luckysheet_shiftkeydown = false; + Store.luckysheet_shiftpositon = null; + } + + //输入框中文输入后 shift 和 空格 处理 + if(parseInt($("#luckysheet-input-box").css("top")) > 0 && (kcode == 13 || kcode == 16 || kcode == 32)){ + formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); + } + + e.preventDefault(); + }); + + //top workBook rename + $("#luckysheet_info_detail_input").val(server.title).css("width", getByteLen(server.title) * 10).keydown(function(){ + let ctrlKey = event.ctrlKey; + let altKey = event.altKey; + let shiftKey = event.shiftKey; + let kcode = event.keyCode; + let $t = $(this); + if(kcode == keycode.ENTER){ + $t.blur().change(); + } + }).bind('input propertychange', function() { + let $t = $(this); + let inputlen = getByteLen($t.val())*10; + let updatelen = $("#luckysheet_info_detail_update").outerWidth(); + let savelen = $("#luckysheet_info_detail_save").outerWidth(); + let userlen = $("#luckysheet_info_detail_user").parent().outerWidth()+60; + let containerlen = $("#" + Store.container).outerWidth(); + let otherlen = 100; + + let minuslen = containerlen- savelen - updatelen - userlen - otherlen; + if(inputlen > minuslen){ + $("#luckysheet_info_detail_input").css("width", minuslen); + } + else{ + $("#luckysheet_info_detail_input").css("width", inputlen); + } + }).change(function(){ + server.saveParam("na", null, $(this).val()); + }); +} \ No newline at end of file diff --git a/src/controllers/matrixOperation.js b/src/controllers/matrixOperation.js new file mode 100644 index 000000000..382e90796 --- /dev/null +++ b/src/controllers/matrixOperation.js @@ -0,0 +1,1241 @@ +import selection from './selection'; +import { + numFormat, +} from '../utils/util'; +import { hasPartMC, isEditMode } from '../global/validate'; +import { getdatabyselection, getcellvalue } from '../global/getdata'; +import tooltip from '../global/tooltip'; +import editor from '../global/editor'; +import Store from '../store'; + +export function initialMatrixOperation(){ + //右键功能键 + //复制为json格式字符串,首行为标题 + $("#luckysheet-copy-json-head").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + + if (getdata.length == 1) { + let obj = {}; + for (let i = 0; i < getdata[0].length; i++) { + obj[getcellvalue(0, i, getdata)] = ""; + } + arr.push(obj); + } + else { + for (let r = 1; r < getdata.length; r++) { + let obj = {}; + for (let c = 0; c < getdata[0].length; c++) { + if(getcellvalue(0, c, getdata) == undefined){ + obj[""] = getcellvalue(r, c, getdata); + }else{ + obj[getcellvalue(0, c, getdata)] = getcellvalue(r, c, getdata); + } + } + arr.push(obj); + } + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为json格式字符串,无标题,采用ABCD作为标题 + $("#luckysheet-copy-json-nohead").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + let st = Store.luckysheet_select_save[0]["column"][0]; + for (let r = 0; r < getdata.length; r++) { + let obj = {}; + for (let c = 0; c < getdata[0].length; c++) { + obj[chatatABC(c + st)] = getcellvalue(r, c, getdata); + } + arr.push(obj); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为一维数组 + $("#luckysheet-copy-array1").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + for (let r = 0; r < getdata.length; r++) { + for (let c = 0; c < getdata[0].length; c++) { + arr.push(getcellvalue(r, c, getdata)); + } + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为二维数组 + $("#luckysheet-copy-array2").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + for (let r = 0; r < getdata.length; r++) { + let a = []; + for (let c = 0; c < getdata[0].length; c++) { + a.push(getcellvalue(r, c, getdata)); + } + arr.push(a); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为多维数组 + $("#luckysheet-copy-arraymore-confirm").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + + for (let r = 0; r < getdata.length; r++) { + for (let c = 0; c < getdata[0].length; c++) { + arr.push(getdata[r][c]); + } + } + + let row = $("#luckysheet-copy-arraymore-row").val(), col = $("#luckysheet-copy-arraymore-col").val(); + + if (row == "" && col == "") { + selection.copybyformat(event, JSON.stringify(arr)); + $("body .luckysheet-cols-menu").hide(); + return; + } + + if (row == "") { + row = 1; + } + else { + row = parseInt(row); + if (row == null) { + row = 1; + } + } + + if (col == "") { + col = 1; + } + else { + col = parseInt(col); + if (col == null) { + col = 1; + } + } + + if(row.toString() == "NaN" || col.toString() == "NaN"){ + if(isEditMode()){ + alert(locale_drag.inputCorrect); + } + else{ + tooltip.info(locale_drag.inputCorrect, ""); + } + return; + } + + if(row < 1 || col < 1){ + if(isEditMode()){ + alert(locale_drag.notLessOne); + } + else{ + tooltip.info(locale_drag.notLessOne, ""); + } + return; + } + + let arrlen = arr.length, i = 0, ret = []; + for (let r = 0; r < row; r++) { + let a = []; + for (let c = 0; c < col; c++) { + a.push(arr[i++]); + if (i >= arrlen) { + selection.copybyformat(event, JSON.stringify(ret)); + $("body .luckysheet-cols-menu").hide(); + return; + } + } + ret.push(a); + } + + selection.copybyformat(event, JSON.stringify(ret)); + }); + + //复制为对角线 + $("#luckysheet-copy-diagonal").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + + let clen = getdata[0].length; + for (let r = 0; r < getdata.length; r++) { + if (r >= clen) { + break; + } + arr.push(getdata[r][r]); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为反对角线 + $("#luckysheet-copy-antidiagonal").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + + let clen = getdata[0].length; + for (let r = 0; r < getdata.length; r++) { + if (r >= clen) { + break; + } + arr.push(getdata[r][clen - r - 1]); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为对角偏移n列 + $("#luckysheet-copy-diagonaloffset").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + + let clen = getdata[0].length, + offset = parseInt($("#luckysheet-copy-diagonaloffset-value").val()); + + if(offset.toString() == "NaN"){ + if(isEditMode()){ + alert(locale_drag.inputCorrect); + } + else{ + tooltip.info(locale_drag.inputCorrect, ""); + } + return; + } + + if(offset < 0){ + if(isEditMode()){ + alert(locale_drag.offsetColumnLessZero); + } + else{ + tooltip.info(locale_drag.offsetColumnLessZero, ""); + } + return; + } + + if (offset == null) { + offset = 1; + } + + for (let r = 0; r < getdata.length; r++) { + if (r + offset >= clen) { + break; + } + arr.push(getdata[r][r + offset]); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //复制为布尔值 + $("#luckysheet-copy-boolvalue").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + //复制范围内包含部分合并单元格,提示 + if(Store.config["merge"] != null){ + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); + + if(has_PartMC){ + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + return; + } + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + let arr = []; + if (getdata.length == 0) { + return; + } + for (let r = 0; r < getdata.length; r++) { + let a = []; + for (let c = 0; c < getdata[0].length; c++) { + let bool = false; + + if(getObjType(getdata[r][c]) == "object"){ + let v = getdata[r][c].v; + } + else{ + let v = getdata[r][c]; + } + + if (v == null || v == "") { + bool = false; + } + else { + v = parseInt(v); + if (v == null || v > 0) { + bool = true; + } + else { + bool = false; + } + } + a.push(bool); + } + arr.push(a); + } + + selection.copybyformat(event, JSON.stringify(arr)); + }); + + //矩阵操作选区 翻转 上下 + $("#luckysheet-matrix-turn-up").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + for (let r = getdata.length - 1; r >= 0; r--) { + let a = []; + for (let c = 0; c < getdata[0].length; c++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandler(arr); + }); + + //矩阵操作选区 翻转 左右 + $("#luckysheet-matrix-turn-left").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + for (let r = 0; r < getdata.length; r++) { + let a = []; + for (let c = getdata[0].length - 1; c >= 0; c--) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandler(arr); + }); + + //矩阵操作选区 翻转 顺时针 + $("#luckysheet-matrix-turn-cw").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + for (let c = 0; c < getdata[0].length; c++) { + let a = []; + for (let r = getdata.length - 1; r >= 0; r--) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandlerD(arr); + }); + + //矩阵操作选区 翻转 逆时针 + $("#luckysheet-matrix-turn-anticw").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + for (let c = getdata[0].length - 1; c >= 0; c--) { + let a = []; + for (let r = 0; r < getdata.length; r++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandlerD(arr); + }); + + //矩阵操作选区 转置 + $("#luckysheet-matrix-turn-trans").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + for (let c = 0; c < getdata[0].length; c++) { + let a = []; + for (let r = 0; r < getdata.length; r++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandlerD(arr); + }); + + let jfnqrt = function (x, p) { + if (x == 0) + return 0; + let x0, x1; + x0 = x; + x1 = ((p - 1) * x0 / p) + (x / (Math.pow(x0, p - 1) * p));//利用迭代法求解 + while (Math.abs(x1 - x0) > 0.000001) { + x0 = x1; + x1 = ((p - 1) * x0 / p) + (x / (Math.pow(x0, p - 1) * p)); + } + return x1; + } + + //矩阵操作选区 矩阵计算 + $("#luckysheet-matrix-cal-confirm").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let caltype = $("#luckysheet-matrix-cal-type").val(), + calvalue = parseInt($("#luckysheet-matrix-cal-value").val()); + + if(calvalue.toString() == "NaN"){ + if(isEditMode()){ + alert(locale_drag.inputCorrect); + } + else{ + tooltip.info(locale_drag.inputCorrect, ""); + } + return; + } + + if (calvalue == null) { + calvalue = 2; + } + + let arr = []; + + for (let r = 0; r < getdata.length; r++) { + let a = []; + + for (let c = 0; c < getdata[0].length; c++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + if (parseInt(value) != null && getdata[r][c].ct != undefined && getdata[r][c].ct.t == "n") { + if (caltype == "minus") { + value.v = value.v - calvalue; + } + else if (caltype == "multiply") { + value.v = value.v * calvalue; + } + else if (caltype == "divided") { + value.v = numFormat(value.v / calvalue, 4); + } + else if (caltype == "power") { + value.v = Math.pow(value.v, calvalue); + } + else if (caltype == "root") { + if (calvalue == 2) { + value.v = numFormat(Math.sqrt(value.v), 4); + } + else if (calvalue == 3 && Math.cbrt) { + value.v = numFormat(Math.cbrt(value.v), 4); + } + else { + value.v = numFormat(jfnqrt(value.v, calvalue), 4); + } + } + else if (caltype == "log") { + value.v = numFormat(Math.log(value.v) * 10000 / Math.log(Math.abs(calvalue)), 4); + } + else { + value.v = value.v + calvalue; + } + + if(value.v == null){ + value.m = ""; + } + else{ + value.m = value.v.toString(); + } + } + } + a.push(value); + } + arr.push(a); + } + + editor.controlHandler(arr); + }); + + //矩阵操作选区 删除两端0值 按行 + $("#luckysheet-matrix-delezero-row").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + let getdatalen = getdata[0].length; + for (let r = 0; r < getdata.length; r++) { + let a = [], stdel = true, eddel = true; + for (let c = 0; c < getdatalen; c++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + if ((value.v == "0" || value.v == 0) && stdel) { + continue; + } + else { + stdel = false; + } + } + a.push(value); + } + + let a1 = []; + if (a.length == getdatalen) { + a1 = a; + } + else { + for (let c = a.length - 1; c >= 0; c--) { + let value = ""; + if (a[c] != null) { + value = a[c]; + if ((value.v == "0" || value.v == 0) && eddel) { + continue; + } + else { + eddel = false; + } + } + a1.unshift(value); + } + + let l = getdatalen - a1.length; + for (let c1 = 0; c1 < l; c1++) { + a1.push(""); + } + } + arr.push(a1); + } + + editor.controlHandler(arr); + }); + + //矩阵操作选区 删除两端0值 按列 + $("#luckysheet-matrix-delezero-column").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + let getdatalen = getdata.length, collen = getdata[0].length; + for (let c = 0; c < collen; c++) { + let a = [], stdel = true, eddel = true; + for (let r = 0; r < getdatalen; r++) { + let value = ""; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + if ((value.v == "0" || value.v == 0) && stdel) { + continue; + } + else { + stdel = false; + } + } + a.push(value); + } + + let a1 = []; + if (a.length == getdatalen) { + a1 = a; + } + else { + for (let r = a.length - 1; r >= 0; r--) { + let value = ""; + if (a[r] != null) { + value = a[r]; + if ((value.v == "0" || value.v == 0) && eddel) { + continue; + } + else { + eddel = false; + } + } + a1.unshift(value); + } + + let l = getdatalen - a1.length; + for (let r1 = 0; r1 < l; r1++) { + a1.push(""); + } + } + arr.push(a1); + } + + let arr1 = []; + for (let c = 0; c < arr[0].length; c++) { + let a = []; + for (let r = 0; r < arr.length; r++) { + let value = ""; + if (arr[r] != null && arr[r][c] != null) { + value = arr[r][c]; + } + a.push(value); + } + arr1.push(a); + } + + editor.controlHandler(arr1); + }); + + //矩阵操作选区 删除重复值 按行 + $("#luckysheet-matrix-delerpt-row").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + let getdatalen = getdata[0].length; + for (let r = 0; r < getdata.length; r++) { + let a = [], repeat = {}; + + for (let c = 0; c < getdatalen; c++) { + let value = null; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + + if(value.v in repeat){ + repeat[value.v].push(value); + } + else{ + repeat[value.v] = []; + repeat[value.v].push(value); + } + } + } + + for (let c = 0; c < getdatalen; c++) { + let value = null; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + + if(repeat[value.v].length == 1){ + a.push(value); + } + } + } + + let l = getdatalen - a.length; + for (let c1 = 0; c1 < l; c1++) { + a.push(null); + } + arr.push(a); + } + + editor.controlHandler(arr); + }); + + //矩阵操作选区 删除重复值 按列 + $("#luckysheet-matrix-delerpt-column").click(function (event) { + $("body .luckysheet-cols-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + return; + } + + let getdata = getdatabyselection(Store.luckysheet_select_save[0]); + if (getdata.length == 0) { + return; + } + + let arr = []; + let getdatalen = getdata.length, collen = getdata[0].length; + for (let c = 0; c < collen; c++) { + let a = [], repeat = {}; + + for (let r = 0; r < getdatalen; r++) { + let value = null; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + + if(value.v in repeat){ + repeat[value.v].push(value); + } + else{ + repeat[value.v] = []; + repeat[value.v].push(value); + } + } + } + + for (let r = 0; r < getdatalen; r++) { + let value = null; + if (getdata[r] != null && getdata[r][c] != null) { + value = getdata[r][c]; + + if(repeat[value.v].length == 1){ + a.push(value); + } + } + } + + a1 = a; + let l = getdatalen - a1.length; + for (let r1 = 0; r1 < l; r1++) { + a1.push(null); + } + arr.push(a1); + } + + let arr1 = []; + for (let c = 0; c < arr[0].length; c++) { + let a = []; + for (let r = 0; r < arr.length; r++) { + let value = null; + if (arr[r] != null && arr[r][c] != null) { + value = arr[r][c]; + } + a.push(value); + } + arr1.push(a); + } + + editor.controlHandler(arr1); + }); +} \ No newline at end of file diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js index af19b5eda..e37b712a4 100644 --- a/src/controllers/menuButton.js +++ b/src/controllers/menuButton.js @@ -2108,131 +2108,132 @@ const menuButton = { $("#luckysheet-icon-conditionformat").click(function(){ let menuButtonId = $(this).attr("id") + "-menuButton"; let $menuButton = $("#" + menuButtonId); + + const conditionformat_text = locale().conditionformat; if($menuButton.length == 0){ let itemdata = [ - {"text": "突出显示单元格规则", "value": "highlightCellRule", "example": "more"}, - {"text": "项目选取规则", "value": "projectSelectRule", "example": "more"}, - {"text": "数据条", "value": "dataBar", "example": "more"}, - {"text": "色阶", "value": "colorGradation", "example": "more"}, - {"text": "图标集", "value": "icons", "example": ""}, - {"text": "", "value": "split", "example": ""}, - {"text": "新建规则", "value": "newRule", "example": ""}, - {"text": "清除规则", "value": "deleteRule", "example": "more"}, - {"text": "管理规则", "value": "administerRule", "example": ""} + { "text": conditionformat_text.highlightCellRules, "value": "highlightCellRule", "example": "more" }, + { "text": conditionformat_text.itemSelectionRules, "value": "projectSelectRule", "example": "more" }, + { "text": conditionformat_text.dataBar, "value": "dataBar", "example": "more" }, + { "text": conditionformat_text.colorGradation, "value": "colorGradation", "example": "more" }, + { "text": conditionformat_text.icons, "value": "icons", "example": "" }, + { "text": "", "value": "split", "example": "" }, + { "text": conditionformat_text.newRule, "value": "newRule", "example": "" }, + { "text": conditionformat_text.deleteRule, "value": "deleteRule", "example": "more" }, + { "text": conditionformat_text.manageRules, "value": "administerRule", "example": "" } ]; let itemset = _this.createButtonMenu(itemdata); let menu = replaceHtml(_this.menu, {"id": "conditionformat", "item": itemset, "subclass": "", "sub": ""}); //突出显示单元格规则子菜单 let subitemdata = [ - {"text": "大于", "value": "greaterThan", "example": ">"}, - {"text": "小于", "value": "lessThan", "example": "<"}, - {"text": "介于", "value": "betweenness", "example": "[]"}, - {"text": "等于", "value": "equal", "example": "="}, - {"text": "文本包含", "value": "textContains", "example": "()"}, - {"text": "发生日期", "value": "occurrenceDate", "example": "昨天"}, - {"text": "重复值", "value": "duplicateValue", "example": "##"} + { "text": conditionformat_text.greaterThan, "value": "greaterThan", "example": ">" }, + { "text": conditionformat_text.lessThan, "value": "lessThan", "example": "<" }, + { "text": conditionformat_text.between, "value": "betweenness", "example": "[]" }, + { "text": conditionformat_text.equal, "value": "equal", "example": "=" }, + { "text": conditionformat_text.textContains, "value": "textContains", "example": "()" }, + { "text": conditionformat_text.occurrence, "value": "occurrenceDate", "example": conditionformat_text.yesterday }, + { "text": conditionformat_text.duplicateValue, "value": "duplicateValue", "example": "##" } ]; let subitemset = _this.createButtonMenu(subitemdata); let submenu = replaceHtml(_this.menu, {"id": "highlightCellRule", "item": subitemset, "subclass": "luckysheet-menuButton-sub"}); //项目选取规则子菜单 let subitemdata2 = [ - {"text": "前 10 项", "value": "top10", "example": "前10项"}, - {"text": "前 10%", "value": "top10%", "example": "前10%"}, - {"text": "最后 10 项", "value": "last10", "example": "后10项"}, - {"text": "最后 10%", "value": "last10%", "example": "后10%"}, - {"text": "高于平均值", "value": "AboveAverage", "example": "高于均值"}, - {"text": "低于平均值", "value": "SubAverage", "example": "低于均值"} + { "text": conditionformat_text.top10, "value": "top10", "example": conditionformat_text.top10 }, + { "text": conditionformat_text.top10_percent, "value": "top10%", "example": conditionformat_text.top10_percent }, + { "text": conditionformat_text.last10, "value": "last10", "example": conditionformat_text.last10 }, + { "text": conditionformat_text.last10_percent, "value": "last10%", "example": conditionformat_text.last10_percent }, + { "text": conditionformat_text.aboveAverage, "value": "AboveAverage", "example": conditionformat_text.aboveAverage }, + { "text": conditionformat_text.belowAverage, "value": "SubAverage", "example": conditionformat_text.belowAverage } ]; let subitemset2 = _this.createButtonMenu(subitemdata2); let submenu2 = replaceHtml(_this.menu, {"id": "projectSelectRule", "item": subitemset2, "subclass": "luckysheet-menuButton-sub"}); //数据条子菜单 - let submenu3 = ''; + let submenu3 = ``; //色阶 - let submenu4 = ''; + let submenu4 = ``; //清除规则子菜单 let subitemdata6 = [ - // {"text":"清除所选单元格的规则", "value":"", "example":""}, - {"text":"清除整个工作表的规则", "value":"delSheet", "example":""} + { "text": conditionformat_text.deleteSheetRule, "value": "delSheet", "example": "" } ]; let subitemset6 = _this.createButtonMenu(subitemdata6); let submenu6 = replaceHtml(_this.menu, {"id": "deleteRule", "item": subitemset6, "subclass":"luckysheet-menuButton-sub"}); @@ -2251,10 +2252,10 @@ const menuButton = { if(itemvalue == "icons"){ if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择应用范围"); + alert(conditionformat_text.pleaseSelectRange); } else{ - tooltip.info("请选择应用范围", ""); + tooltip.info(conditionformat_text.pleaseSelectRange, ""); } return; } @@ -2265,10 +2266,10 @@ const menuButton = { else if(itemvalue == "newRule"){ if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择应用范围"); + alert(conditionformat_text.pleaseSelectRange); } else{ - tooltip.info("请选择应用范围", ""); + tooltip.info(conditionformat_text.pleaseSelectRange, ""); } return; } @@ -2329,108 +2330,107 @@ const menuButton = { if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择条件格式的应用范围"); + alert(conditionformat_text.pleaseSelectRange); } else{ - tooltip.info("请选择条件格式的应用范围", ""); + tooltip.info(conditionformat_text.pleaseSelectRange, ""); } return; } else{ - let textCellColorHtml = conditionformat.textCellColorHtml; + let textCellColorHtml = conditionformat.textCellColorHtml(); let title, content; switch(itemvalue){ case "greaterThan": - title = "条件格式——大于"; - content = '
    ' + - '
    为大于以下值的单元格设置格式:
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_greaterThan; + content = `
    +
    ${conditionformat_text.conditionformat_greaterThan_title}:
    +
    + + +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "lessThan": - title = "条件格式——小于"; - content = '
    ' + - '
    为小于以下值的单元格设置格式:
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_lessThan; + content = `
    +
    ${conditionformat_text.conditionformat_lessThan_title}:
    +
    + + +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "betweenness": - title = "条件格式——介于"; - content = '
    ' + - '
    为介于以下值的单元格设置格式:
    ' + - '
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_betweenness; + content = `
    +
    ${conditionformat_text.conditionformat_betweenness_title}:
    +
    +
    + + +
    +
    ${conditionformat_text.to}
    +
    + + +
    +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "equal": - title = "条件格式——等于"; - content = '
    ' + - '
    为等于以下值的单元格设置格式:
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_equal; + content = `
    +
    ${conditionformat_text.conditionformat_equal_title}:
    +
    + + +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "textContains": - title = "条件格式——文本包含"; - content = '
    ' + - '
    为包含以下文本的单元格设置格式:
    ' + - '
    ' + - '' + - '' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_textContains; + content = `
    +
    ${conditionformat_text.conditionformat_textContains_title}:
    +
    + + +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "occurrenceDate": - title = "条件格式——发生日期"; - content = '
    ' + - '
    为包含以下日期的单元格设置格式:
    ' + - '
    ' + - '' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_occurrenceDate; + content = `
    +
    ${conditionformat_text.conditionformat_occurrenceDate_title}:
    +
    + +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "duplicateValue": - title = "条件格式——重复值"; - content = '
    ' + - '
    为包含以下类型值的单元格设置格式:
    ' + - '' + - '' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_duplicateValue; + content = `
    +
    ${conditionformat_text.conditionformat_duplicateValue_title}:
    + +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; } @@ -2448,93 +2448,93 @@ const menuButton = { if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择条件格式的应用范围"); + alert(conditionformat_text.pleaseSelectRange); } else{ - tooltip.info("请选择条件格式的应用范围", ""); + tooltip.info(conditionformat_text.pleaseSelectRange, ""); } return; } else{ - let textCellColorHtml = conditionformat.textCellColorHtml; + let textCellColorHtml = conditionformat.textCellColorHtml(); let title, content; switch(itemvalue){ case "top10": - title = "条件格式——前 10 项"; - content = '
    ' + - '
    为值最大的那些单元格设置格式:
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '
    ' + - '
    ' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_top10; + content = `
    +
    ${conditionformat_text.conditionformat_top10_title}:
    +
    +
    ${conditionformat_text.top}
    +
    + +
    +
    ${conditionformat_text.oneself}
    +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "top10%": - title = "条件格式——前 10%"; - content = '
    ' + - '
    为值最大的那些单元格设置格式:
    ' + - '
    ' + - '
    ' + - '
    ' + - '' + - '
    ' + - '
    %
    ' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_top10_percent; + content = `
    +
    ${conditionformat_text.conditionformat_top10_title}:
    +
    +
    ${conditionformat_text.top}
    +
    + +
    +
    %
    +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "last10": - title = "条件格式——最后 10 项"; - content = '
    ' + - '
    为值最小的那些单元格设置格式:
    ' + - '
    ' + - '
    最后
    ' + - '
    ' + - '' + - '
    ' + - '
    ' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_last10; + content = `
    +
    ${conditionformat_text.conditionformat_last10_title}:
    +
    +
    ${conditionformat_text.last}
    +
    + +
    +
    ${conditionformat_text.oneself}
    +
    +
    ${conditionformat_text.setAs}:
    + ${textCellColorHtml} +
    `; break; case "last10%": - title = "条件格式——最后 10%"; - content = '
    ' + - '
    为值最小的那些单元格设置格式:
    ' + - '
    ' + - '
    最后
    ' + - '
    ' + - '' + - '
    ' + - '
    %
    ' + - '
    ' + - '
    设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_last10_percent; + content = `
    +
    ${conditionformat_text.conditionformat_last10_title}:
    +
    +
    ${conditionformat_text.last}
    +
    + +
    +
    %
    +
    +
    设置为:
    + ${textCellColorHtml} +
    `; break; case "AboveAverage": - title = "条件格式——高于平均值"; - content = '
    ' + - '
    为高于平均值的单元格设置格式:
    ' + - '
    针对选定区域,设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_AboveAverage; + content = `
    +
    ${conditionformat_text.conditionformat_AboveAverage_title}:
    +
    ${conditionformat_text.setAsByArea}:
    + ${textCellColorHtml} +
    `; break; case "SubAverage": - title = "条件格式——低于平均值"; - content = '
    ' + - '
    为低于平均值的单元格设置格式:
    ' + - '
    针对选定区域,设置为:
    ' + - textCellColorHtml + - '
    '; + title = conditionformat_text.conditionformat_SubAverage; + content = `
    +
    ${conditionformat_text.conditionformat_SubAverage_title}:
    +
    ${conditionformat_text.setAsByArea}:
    + ${textCellColorHtml} +
    `; break; } diff --git a/src/controllers/orderBy.js b/src/controllers/orderBy.js new file mode 100644 index 000000000..f8550401b --- /dev/null +++ b/src/controllers/orderBy.js @@ -0,0 +1,273 @@ + +import { modelHTML } from './constant'; + +import { selectHightlightShow } from './select'; + +import { + replaceHtml, + chatatABC, +} from '../utils/util'; +import { rowlenByRange } from '../global/getRowlen'; +import { isEditMode } from '../global/validate'; +import cleargridelement from '../global/cleargridelement'; +import { + jfrefreshgrid, +} from '../global/refresh'; +import { getcellvalue } from '../global/getdata'; +import { orderbydata, sortColumnSeletion } from '../global/sort'; +import tooltip from '../global/tooltip'; +import editor from '../global/editor'; +import { isdatatype } from '../global/datecontroll'; +import Store from '../store'; +import locale from '../locale/locale'; + + +export function orderByInitial(){ + const _locale = locale(); + //菜单栏 排序按钮 + $("#luckysheetorderbyasc, #luckysheetorderbyasc_t").mousedown(function (event) { + cleargridelement(event); + sortColumnSeletion(Store.orderbyindex, true); + selectHightlightShow(); + }); + + $("#luckysheetorderbydesc, #luckysheetorderbydesc_t").click(function (event) { + cleargridelement(event); + sortColumnSeletion(Store.orderbyindex, false); + selectHightlightShow(); + }); + + //排序事件 + let luckysheet_sort_initial = true; + $("#luckysheetorderby").click(function () { + $("body .luckysheet-cols-menu").hide(); + const locale_sort = _locale.sort; + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_sort.noRangeError); + } + else{ + tooltip.info(locale_sort.noRangeError, ""); + } + return; + } + + let last = Store.luckysheet_select_save[0]; + let r1 = last["row"][0], r2 = last["row"][1]; + let c1 = last["column"][0], c2 = last["column"][1]; + + if (luckysheet_sort_initial) { + luckysheet_sort_initial = false; + + let content = `
    ${locale_sort.hasTitle}
    + ${locale_sort.addOthers}
    `; + + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-sort-dialog", "addclass": "", "title": _locale.sort.sortTitle, "content": content, "botton": ``})); + + $("#luckysheet-sort-dialog .luckysheet-sort-dialog-additem").click(function () { + let last = Store.luckysheet_select_save[0]; + let r1 = last["row"][0], r2 = last["row"][1]; + let c1 = last["column"][0], c2 = last["column"][1]; + + let option = "", i = $("#luckysheet-sort-dialog table").data("itemcount") + 1; + let t = $("#luckysheet-sort-haveheader").is(':checked'); + + for (let c = c1; c <= c2; c++) { + if (t) { + let v = getcellvalue(r1, c, Store.flowdata, "m"); + + if(v == null){ + v = locale_sort.columnOperation + (c - c1 + 1); + } + + option += ''; + } + else { + option += ''; + } + } + + $("#luckysheet-sort-dialog table").append(` + + ${locale_sort.secondaryTitle} + +
    +
    +
    + + + `); + $("#luckysheet-sort-dialog table").data("itemcount", i); + }); + + $("#luckysheet-sort-haveheader").change(function () { + let last = Store.luckysheet_select_save[0]; + let r1 = last["row"][0], r2 = last["row"][1]; + let c1 = last["column"][0], c2 = last["column"][1]; + + let t = $(this).is(':checked'); + let option = ""; + + for (let c = c1; c <= c2; c++) { + if (t) { + let v = getcellvalue(r1, c, Store.flowdata, "m"); + + if(v == null){ + v = locale_sort.columnOperation + (c - c1 + 1); + } + + option += ''; + } + else { + option += ''; + } + } + + $("#luckysheet-sort-dialog tr select").each(function () { + $(this).html(option); + }); + }); + + //Custom sort + $("#luckysheet-sort-modal-confirm").click(function () { + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_sort.noRangeError); + } + else{ + tooltip.info(locale_sort.noRangeError, ""); + } + + return; + } + + let d = editor.deepCopyFlowData(Store.flowdata); + + let last = Store.luckysheet_select_save[0]; + let r1 = last["row"][0], r2 = last["row"][1]; + let c1 = last["column"][0], c2 = last["column"][1]; + + //Data has header row + let t = $("#luckysheet-sort-haveheader").is(':checked'); + + let str; + if(t){ + str = r1 + 1; + } + else{ + str = r1; + } + + let hasMc = false; //Whether the sort selection has merged cells + + let data = []; + + for(let r = str; r <= r2; r++){ + let data_row = []; + + for(let c = c1; c <= c2; c++){ + if(d[r][c] != null && d[r][c].mc != null){ + hasMc = true; + break; + } + + data_row.push(d[r][c]); + } + + data.push(data_row); + } + + if(hasMc){ + if(isEditMode()){ + alert(locale_sort.mergeError); + } + else{ + tooltip.info(locale_sort.mergeError, ""); + } + + return; + } + + $($("#luckysheet-sort-dialog table tr").toArray().reverse()).each(function () { + let i = $(this).find("select").val(), + asc = $(this).find('input:radio:checked').val(); + + i -= c1; + + if (asc == "asc") { + asc = true; + } + else { + asc = false; + } + + data = orderbydata([].concat(data), i, asc); + }); + + for(let r = str; r <= r2; r++){ + for(let c = c1; c <= c2; c++){ + d[r][c] = data[r - str][c - c1]; + } + } + + if(Store.config["rowlen"] != null){ + let cfg = $.extend(true, {}, Store.config); + cfg = rowlenByRange(d, str, r2, cfg); + + jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }], cfg, null, true); + } + else{ + jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }]); + } + + $("#luckysheet-sort-dialog").hide(); + $("#luckysheet-modal-dialog-mask").hide(); + }); + } + + let option = ""; + for (let c = c1; c <= c2; c++) { + option += ''; + } + + $("#luckysheet-sort-dialog select").html(option); + + $("#luckysheet-sort-dialog .luckysheet-sort-dialog-tr").remove(); + + $("#luckysheet-sort-haveheader").prop("checked", false); + $("#luckysheet-sort-dialog input:radio:first").prop("checked", "checked"); + + $("#luckysheet-sort-dialog .luckysheet-modal-dialog-title-text").html(locale_sort.sortRangeTitle+"" + chatatABC(c1) + (r1 + 1) + ""+ locale_sort.sortRangeTitleTo +"" + chatatABC(c2) + (r2 + 1) + ""); + + let $t = $("#luckysheet-sort-dialog"), myh = $t.outerHeight(), myw = $t.outerWidth(); + let winw = $(window).width(), winh = $(window).height(); + let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop(); + + $("#luckysheet-sort-dialog-tablec").css("max-height", (winh - myh) / 2); + $("#luckysheet-sort-dialog").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 2 }).show(); + $("#luckysheet-modal-dialog-mask").show(); + + if (r1 < r2) { + setTimeout(function () { + let flowrowdata1 = Store.flowdata[r1], + flowrowdata2 = Store.flowdata[r1 + 1], + hastitle = false; + + for (let i = c1; i <= c2; i++) { + let isdatatype_r1 = isdatatype(flowrowdata1[i]), + isdatatype_r2 = isdatatype(flowrowdata2[i]); + + if (isdatatype_r1 != isdatatype_r2) { + hastitle = true; + } + } + + if (hastitle) { + $("#luckysheet-sort-haveheader").prop("checked", true).change(); + } + }, 10); + } + }); +} \ No newline at end of file diff --git a/src/controllers/pivotTable.js b/src/controllers/pivotTable.js index 888e12908..aea4af5f9 100644 --- a/src/controllers/pivotTable.js +++ b/src/controllers/pivotTable.js @@ -873,7 +873,7 @@ const pivotTable = { if (_this.initial) { _this.initial = false; - $("body").append(luckysheetPivotTableHTML); + $("body").append(luckysheetPivotTableHTML()); $("#luckysheet-modal-dialog-slider-close").click(function () { $("#luckysheet-modal-dialog-slider-pivot").hide(); luckysheetsizeauto(); diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js new file mode 100644 index 000000000..5ba87e118 --- /dev/null +++ b/src/controllers/rowColumnOperation.js @@ -0,0 +1,1620 @@ + +import pivotTable from './pivotTable'; +import luckysheetPostil from './postil'; +import menuButton from './menuButton'; +import server from './server'; +import { selectHightlightShow, luckysheet_count_show } from './select'; +import { + getObjType, + showrightclickmenu, +} from '../utils/util'; +import { getSheetIndex, getRangetxt } from '../methods/get'; +import { + rowLocation, + rowLocationByIndex, + colLocation, + colLocationByIndex, + mouseposition +} from '../global/location'; +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 { + jfrefreshgrid, + jfrefreshgridall, + jfrefreshgrid_rhcw, +} from '../global/refresh'; +import { getcellvalue } from '../global/getdata'; +import tooltip from '../global/tooltip'; +import editor from '../global/editor'; +import locale from '../locale/locale'; +import Store from '../store'; + + + +export function rowColumnOperationInitial(){ + + + //表格行标题 mouse事件 + $("#luckysheet-rows-h").mousedown(function (event) { + //有批注在编辑时 + luckysheetPostil.removeActivePs(); + + let mouse = mouseposition(event.pageX, event.pageY); + let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); + + let row_location = rowLocation(y), + row = row_location[1], + row_pre = row_location[0], + row_index = row_location[2]; + let col_index = Store.visibledatacolumn.length - 1, + col = Store.visibledatacolumn[col_index], col_pre = 0; + + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + + //mousedown是右键 + if (event.which == "3") { + let isright = false; + + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + let obj_s = Store.luckysheet_select_save[s]; + + if(obj_s["row"] != null && (row_index >= obj_s["row"][0] && row_index <= obj_s["row"][1]) && (obj_s["column"][0] == 0 && obj_s["column"][1] == Store.flowdata[0].length - 1)){ + isright = true; + break; + } + } + + if(isright){ + return; + } + } + + let top = row_pre, height = row - row_pre - 1; + let rowseleted = [row_index, row_index]; + + Store.luckysheet_scroll_status = true; + + //公式相关 + let $input = $("#luckysheet-input-box"); + if (parseInt($input.css("top")) > 0) { + if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton() || $("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) { + //公式选区 + let changeparam = menuButton.mergeMoveMain([0, col_index], rowseleted, {"row_focus": row_index, "column_focus": 0}, top, height, col_pre, col); + if(changeparam != null){ + //columnseleted = changeparam[0]; + rowseleted = changeparam[1]; + top = changeparam[2]; + height = changeparam[3]; + //left = changeparam[4]; + //width = changeparam[5]; + } + + if(event.shiftKey){ + let last = formula.func_selectedrange; + + let top = 0, height = 0, rowseleted = []; + if (last.top > row_pre) { + top = row_pre; + height = last.top + last.height - row_pre; + + if(last.row[1] > last.row_focus){ + last.row[1] = last.row_focus; + } + + rowseleted = [row_index, last.row[1]]; + } + else if (last.top == row_pre) { + top = row_pre; + height = last.top + last.height - row_pre; + rowseleted = [row_index, last.row[0]]; + } + else { + top = last.top; + height = row - last.top - 1; + + if(last.row[0] < last.row_focus){ + last.row[0] = last.row_focus; + } + + rowseleted = [last.row[0], row_index]; + } + + let changeparam = menuButton.mergeMoveMain([0, col_index], rowseleted, {"row_focus": row_index, "column_focus": 0}, top, height, col_pre, col); + if(changeparam != null){ + // columnseleted = changeparam[0]; + rowseleted = changeparam[1]; + top = changeparam[2]; + height = changeparam[3]; + // left = changeparam[4]; + // width = changeparam[5]; + } + + last["row"] = rowseleted; + + last["top_move"] = top; + last["height_move"] = height; + + formula.func_selectedrange = last; + } + else if(event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ","){ + //按住ctrl 选择选区时 先处理上一个选区 + let vText = $("#luckysheet-rich-text-editor").text() + ","; + if(vText.length > 0 && vText.substr(0, 1) == "="){ + vText = formula.functionHTMLGenerate(vText); + + if (window.getSelection) { // all browsers, except IE before version 9 + let currSelection = window.getSelection(); + formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset]; + } + else { // Internet Explorer before version 9 + let textRange = document.selection.createRange(); + formula.functionRangeIndex = textRange; + } + + $("#luckysheet-rich-text-editor").html(vText); + + formula.canceFunctionrangeSelected(); + formula.createRangeHightlight(); + } + + formula.rangestart = false; + formula.rangedrag_column_start = false; + formula.rangedrag_row_start = false; + + $("#luckysheet-functionbox-cell").html(vText); + formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); + + //再进行 选区的选择 + formula.israngeseleciton(); + formula.func_selectedrange = { + "left": colLocationByIndex(0)[0], + "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, + "top": top, + "height": height, + "left_move": col_pre, + "width_move": col - col_pre - 1, + "top_move": top, + "height_move": height, + "row": rowseleted, + "column": [0, col_index], + "row_focus": row_index, + "column_focus": 0 + } + } + else{ + formula.func_selectedrange = { + "left": colLocationByIndex(0)[0], + "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, + "top": top, + "height": height, + "left_move": col_pre, + "width_move": col - col_pre - 1, + "top_move": top, + "height_move": height, + "row": rowseleted, + "column": [0, col_index], + "row_focus": row_index, + "column_focus": 0 + } + } + + if(formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()){ + formula.rangeSetValue({ "row": rowseleted, "column": [null, null] }); + } + else if($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")){//if公式生成器 + let range = getRangetxt(Store.currentSheetIndex, { "row": rowseleted, "column": [0, col_index] }, Store.currentSheetIndex); + $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range); + } + + formula.rangedrag_row_start = true; + formula.rangestart = false; + formula.rangedrag_column_start = false; + + $("#luckysheet-formula-functionrange-select").css({ + "left": col_pre, + "width": col - col_pre - 1, + "top": top, + "height": height + }).show(); + $("#luckysheet-formula-help-c").hide(); + + luckysheet_count_show(col_pre, top, col - col_pre - 1, height, rowseleted, [0, col_index]); + + setTimeout(function(){ + let currSelection = window.getSelection(); + let anchorOffset = currSelection.anchorNode; + + let $editor; + if($("#luckysheet-search-formula-parm").is(":visible")||$("#luckysheet-search-formula-parm-select").is(":visible")){ + $editor = $("#luckysheet-rich-text-editor"); + formula.rangechangeindex = formula.data_parm_index; + } + else{ + $editor = $(anchorOffset).closest("div"); + } + + let $span = $editor.find("span[rangeindex='" + formula.rangechangeindex + "']"); + + formula.setCaretPosition($span.get(0), 0, $span.html().length); + }, 1); + + return; + } + else { + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + Store.luckysheet_rows_selected_status = true; + } + } + else { + Store.luckysheet_rows_selected_status = true; + } + + if (Store.luckysheet_rows_selected_status) { + if(event.shiftKey){ + //按住shift点击行索引选取范围 + let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个 + + let top = 0, height = 0, rowseleted = []; + if (last.top > row_pre) { + top = row_pre; + height = last.top + last.height - row_pre; + + if(last.row[1] > last.row_focus){ + last.row[1] = last.row_focus; + } + + rowseleted = [row_index, last.row[1]]; + } + else if (last.top == row_pre) { + top = row_pre; + height = last.top + last.height - row_pre; + rowseleted = [row_index, last.row[0]]; + } + else { + top = last.top; + height = row - last.top - 1; + + if(last.row[0] < last.row_focus){ + last.row[0] = last.row_focus; + } + + rowseleted = [last.row[0], row_index]; + } + + last["row"] = rowseleted; + + last["top_move"] = top; + last["height_move"] = height; + + Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last; + } + else if(event.ctrlKey){ + Store.luckysheet_select_save.push({ + "left": colLocationByIndex(0)[0], + "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, + "top": top, + "height": height, + "left_move": col_pre, + "width_move": col - col_pre - 1, + "top_move": top, + "height_move": height, + "row": rowseleted, + "column": [0, col_index], + "row_focus": row_index, + "column_focus": 0 + }); + } + else{ + Store.luckysheet_select_save = []; + Store.luckysheet_select_save.push({ + "left": colLocationByIndex(0)[0], + "width": colLocationByIndex(0)[1] - colLocationByIndex(0)[0] - 1, + "top": top, + "height": height, + "left_move": col_pre, + "width_move": col - col_pre - 1, + "top_move": top, + "height_move": height, + "row": rowseleted, + "column": [0, col_index], + "row_focus": row_index, + "column_focus": 0 + }); + } + + selectHightlightShow(); + + if(server.allowUpdate){ + //允许编辑后的后台更新时 + server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save); + } + } + + $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1])); + + setTimeout(function () { + clearTimeout(Store.countfuncTimeout); + countfunc(); + }, 101); + }).mousemove(function (event) { + if (Store.luckysheet_rows_selected_status || Store.luckysheet_rows_change_size || Store.luckysheet_select_status) { + $("#luckysheet-rows-h-hover").hide(); + return; + } + + let mouse = mouseposition(event.pageX, event.pageY); + let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); + + let row_location = rowLocation(y), + row = row_location[1], + row_pre = row_location[0], + row_index = row_location[2]; + + $("#luckysheet-rows-h-hover").css({ "top": row_pre, "height": row - row_pre - 1, "display": "block" }); + + if (y < row - 1 && y >= row - 5) { + $("#luckysheet-rows-change-size").css({ "top": row - 3, "opacity": 0 }); + } + else { + $("#luckysheet-rows-change-size").css("opacity", 0); + } + }).mouseleave(function (event) { + $("#luckysheet-rows-h-hover").hide(); + $("#luckysheet-rows-change-size").css("opacity", 0); + }).mouseup(function (event) { + if (event.which == 3) { + if(isEditMode()){ //非编辑模式下禁止右键功能框 + return; + } + + $("#luckysheet-cols-rows-shift").hide(); + Store.luckysheetRightHeadClickIs = "row"; + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.row); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.height); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.top); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.bottom); + + $("#luckysheet-cols-rows-add").show(); + $("#luckysheet-cols-rows-data").show(); + $("#luckysheet-cols-rows-shift").hide(); + $("#luckysheet-cols-rows-handleincell").hide(); + + showrightclickmenu($("#luckysheet-rightclick-menu"), $(this).offset().left + 46, event.pageY); + Store.luckysheet_cols_menu_status = true; + + //行高默认值 + let cfg = $.extend(true, {}, Store.config); + if(cfg["rowlen"] == null){ + cfg["rowlen"] = {}; + } + + let first_rowlen = cfg["rowlen"][Store.luckysheet_select_save[0].row[0]] == null ? Store.defaultrowlen : cfg["rowlen"][Store.luckysheet_select_save[0].row[0]]; + let isSame = true; + + for(let i = 0; i < Store.luckysheet_select_save.length; i++){ + let s = Store.luckysheet_select_save[i]; + let r1 = s.row[0], r2 = s.row[1]; + + for(let r = r1; r <= r2; r++){ + let rowlen = cfg["rowlen"][r] == null ? Store.defaultrowlen : cfg["rowlen"][r]; + + if(rowlen != first_rowlen){ + isSame = false; + break; + } + } + } + + if(isSame){ + $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_rowlen); + } + else{ + $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(""); + } + } + }); + + //表格列标题 mouse事件 + $("#luckysheet-cols-h-c").mousedown(function (event) { + //有批注在编辑时 + luckysheetPostil.removeActivePs(); + + let mouse = mouseposition(event.pageX, event.pageY); + let x = mouse[0] + $(this).scrollLeft(); + + let row_index = Store.visibledatarow.length - 1, + row = Store.visibledatarow[row_index], row_pre = 0; + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + + Store.orderbyindex = col_index;//排序全局函数 + + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide(); + + //mousedown是右键 + if (event.which == "3") { + let isright = false; + + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + let obj_s = Store.luckysheet_select_save[s]; + + if(obj_s["column"] != null && (col_index >= obj_s["column"][0] && col_index <= obj_s["column"][1]) && (obj_s["row"][0] == 0 && obj_s["row"][1] == Store.flowdata.length - 1)){ + isright = true; + break; + } + } + + if(isright){ + return; + } + } + + let left = col_pre, width = col - col_pre - 1; + let columnseleted = [col_index, col_index]; + + Store.luckysheet_scroll_status = true; + + //公式相关 + let $input = $("#luckysheet-input-box"); + if (parseInt($input.css("top")) > 0) { + if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton() || $("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) { + //公式选区 + let changeparam = menuButton.mergeMoveMain(columnseleted, [0, row_index], {"row_focus": 0, "column_focus": col_index}, row_pre, row, left, width); + if(changeparam != null){ + columnseleted = changeparam[0]; + //rowseleted= changeparam[1]; + //top = changeparam[2]; + //height = changeparam[3]; + left = changeparam[4]; + width = changeparam[5]; + } + + if(event.shiftKey){ + let last = formula.func_selectedrange; + + let left = 0, width = 0, columnseleted = []; + if (last.left > col_pre) { + left = col_pre; + width = last.left + last.width - col_pre; + + if(last.column[1] > last.column_focus){ + last.column[1] = last.column_focus; + } + + columnseleted = [col_index, last.column[1]]; + } + else if (last.left == col_pre) { + left = col_pre; + width = last.left + last.width - col_pre; + columnseleted = [col_index, last.column[0]]; + } + else { + left = last.left; + width = col - last.left - 1; + + if(last.column[0] < last.column_focus){ + last.column[0] = last.column_focus; + } + + columnseleted = [last.column[0], col_index]; + } + + let changeparam = menuButton.mergeMoveMain(columnseleted , [0, row_index], {"row_focus": 0, "column_focus": col_index}, row_pre, row, left, width); + if(changeparam != null){ + columnseleted = changeparam[0]; + //rowseleted= changeparam[1]; + //top = changeparam[2]; + //height = changeparam[3]; + left = changeparam[4]; + width = changeparam[5]; + } + + last["column"] = columnseleted; + + last["left_move"] = left; + last["width_move"] = width; + + formula.func_selectedrange = last; + } + else if(event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ","){ + //按住ctrl 选择选区时 先处理上一个选区 + let vText = $("#luckysheet-rich-text-editor").text() + ","; + if(vText.length > 0 && vText.substr(0, 1) == "="){ + vText = formula.functionHTMLGenerate(vText); + + if (window.getSelection) { // all browsers, except IE before version 9 + let currSelection = window.getSelection(); + formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset]; + } + else { // Internet Explorer before version 9 + let textRange = document.selection.createRange(); + formula.functionRangeIndex = textRange; + } + + $("#luckysheet-rich-text-editor").html(vText); + + formula.canceFunctionrangeSelected(); + formula.createRangeHightlight(); + } + + formula.rangestart = false; + formula.rangedrag_column_start = false; + formula.rangedrag_row_start = false; + + $("#luckysheet-functionbox-cell").html(vText); + formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); + + //再进行 选区的选择 + formula.israngeseleciton(); + formula.func_selectedrange = { + "left": left, + "width": width, + "top": rowLocationByIndex(0)[0], + "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, + "left_move": left, + "width_move": width, + "top_move": row_pre, + "height_move": row - row_pre - 1, + "row": [0, row_index], + "column": columnseleted, + "row_focus": 0, + "column_focus": col_index + } + } + else{ + formula.func_selectedrange = { + "left": left, + "width": width, + "top": rowLocationByIndex(0)[0], + "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, + "left_move": left, + "width_move": width, + "top_move": row_pre, + "height_move": row - row_pre - 1, + "row": [0, row_index], + "column": columnseleted, + "row_focus": 0, + "column_focus": col_index + } + } + + if(formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()){ + formula.rangeSetValue({ "row": [null, null], "column": columnseleted }); + } + else if($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")){//if公式生成器 + let range = getRangetxt(Store.currentSheetIndex, { "row": [0, row_index], "column": columnseleted }, Store.currentSheetIndex); + $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range); + } + + formula.rangedrag_column_start = true; + formula.rangestart = false; + formula.rangedrag_row_start = false; + + $("#luckysheet-formula-functionrange-select").css({ + "left": left, + "width": width, + "top": row_pre, + "height": row - row_pre - 1 + }).show(); + $("#luckysheet-formula-help-c").hide(); + + luckysheet_count_show(left, row_pre, width, row - row_pre - 1, [0, row_index], columnseleted); + + return; + } + else { + formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); + Store.luckysheet_cols_selected_status = true; + } + } + else { + Store.luckysheet_cols_selected_status = true; + } + + if (Store.luckysheet_cols_selected_status) { + if(event.shiftKey){ + //按住shift点击列索引选取范围 + let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个 + + let left = 0, width = 0, columnseleted = []; + if (last.left > col_pre) { + left = col_pre; + width = last.left + last.width - col_pre; + + if(last.column[1] > last.column_focus){ + last.column[1] = last.column_focus; + } + + columnseleted = [col_index, last.column[1]]; + } + else if (last.left == col_pre) { + left = col_pre; + width = last.left + last.width - col_pre; + columnseleted = [col_index, last.column[0]]; + } + else { + left = last.left; + width = col - last.left - 1; + + if(last.column[0] < last.column_focus){ + last.column[0] = last.column_focus; + } + + columnseleted = [last.column[0], col_index]; + } + + last["column"] = columnseleted; + + last["left_move"] = left; + last["width_move"] = width; + + Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last; + } + else if(event.ctrlKey){ + //选区添加 + Store.luckysheet_select_save.push({ + "left": left, + "width": width, + "top": rowLocationByIndex(0)[0], + "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, + "left_move": left, + "width_move": width, + "top_move": row_pre, + "height_move": row - row_pre - 1, + "row": [0, row_index], + "column": columnseleted, + "row_focus": 0, + "column_focus": col_index + }); + } + else{ + Store.luckysheet_select_save = []; + Store.luckysheet_select_save.push({ + "left": left, + "width": width, + "top": rowLocationByIndex(0)[0], + "height": rowLocationByIndex(0)[1] - rowLocationByIndex(0)[0] - 1, + "left_move": left, + "width_move": width, + "top_move": row_pre, + "height_move": row - row_pre - 1, + "row": [0, row_index], + "column": columnseleted, + "row_focus": 0, + "column_focus": col_index + }); + } + + selectHightlightShow(); + + if(server.allowUpdate){ + //允许编辑后的后台更新时 + server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save); + } + } + + $("#luckysheet-helpbox-cell").text(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1])); + + setTimeout(function () { + clearTimeout(Store.countfuncTimeout); + countfunc(); + }, 101); + + if (Store.luckysheet_cols_menu_status) { + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-cols-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + Store.luckysheet_cols_menu_status = false; + } + event.stopPropagation(); + }).mousemove(function (event) { + if (Store.luckysheet_cols_selected_status || Store.luckysheet_select_status) { + $("#luckysheet-cols-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + return; + } + + if (Store.luckysheet_cols_menu_status || Store.luckysheet_cols_change_size) { + return; + } + + let mouse = mouseposition(event.pageX, event.pageY); + let x = mouse[0] + $("#luckysheet-cols-h-c").scrollLeft(); + + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + + $("#luckysheet-cols-h-hover").css({ "left": col_pre, "width": col - col_pre - 1, "display": "block" }); + $("#luckysheet-cols-menu-btn").css({ "left": col - 19, "display": "block" }); + + $("#luckysheet-cols-change-size").css({ "left": col - 5 }); + if (x < col && x >= col - 5) { + $("#luckysheet-cols-change-size").css({ "opacity": 0 }); + $("#luckysheet-cols-menu-btn").hide(); + } + else { + $("#luckysheet-change-size-line").hide(); + $("#luckysheet-cols-change-size").css("opacity", 0); + } + }).mouseleave(function (event) { + if (Store.luckysheet_cols_menu_status || Store.luckysheet_cols_change_size) { + return; + } + + $("#luckysheet-cols-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + $("#luckysheet-cols-change-size").css("opacity", 0); + }).mouseup(function (event) { + if (event.which == 3) { + if(isEditMode()){ //非编辑模式下禁止右键功能框 + return; + } + + Store.luckysheetRightHeadClickIs = "column"; + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.width); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right); + + $("#luckysheet-cols-rows-add").show(); + $("#luckysheet-cols-rows-data").show(); + $("#luckysheet-cols-rows-shift").hide(); + $("#luckysheet-cols-rows-handleincell").hide(); + + showrightclickmenu($("#luckysheet-rightclick-menu"), event.pageX, $(this).offset().top + 18); + Store.luckysheet_cols_menu_status = true; + + //列宽默认值 + let cfg = $.extend(true, {}, Store.config); + if(cfg["columlen"] == null){ + cfg["columlen"] = {}; + } + + let first_collen = cfg["columlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columlen"][Store.luckysheet_select_save[0].column[0]]; + let isSame = true; + + for(let i = 0; i < Store.luckysheet_select_save.length; i++){ + let s = Store.luckysheet_select_save[i]; + let c1 = s.column[0], c2 = s.column[1]; + + for(let c = c1; c <= c2; c++){ + let collen = cfg["columlen"][c] == null ? Store.defaultcollen : cfg["columlen"][c]; + + if(collen != first_collen){ + isSame = false; + break; + } + } + } + + if(isSame){ + $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_collen); + } + else{ + $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(""); + } + } + }); + + + //表格行标题 改变行高按钮 + $("#luckysheet-rows-change-size").mousedown(function (event) { + //有批注在编辑时 + luckysheetPostil.removeActivePs(); + + $("#luckysheet-input-box").hide(); + $("#luckysheet-rows-change-size").css({ "opacity": 1 }); + + let mouse = mouseposition(event.pageX, event.pageY); + let y = mouse[1] + $("#luckysheet-rows-h").scrollTop(); + + let scrollLeft = $("#luckysheet-cell-main").scrollLeft(); + let winW = $("#luckysheet-cell-main").width(); + + let row_location = rowLocation(y), + row = row_location[1], + row_pre = row_location[0], + row_index = row_location[2]; + + Store.luckysheet_rows_change_size = true; + Store.luckysheet_scroll_status = true; + $("#luckysheet-change-size-line").css({ + "height": "1px", + "border-width": + "0 0px 1px 0", + "top": row - 3, + "left": 0, + "width": scrollLeft + winW, + "display": "block", + "cursor": "ns-resize" + }); + $("#luckysheet-sheettable, #luckysheet-rows-h, #luckysheet-rows-h canvas").css("cursor", "ns-resize"); + Store.luckysheet_rows_change_size_start = [row_pre, row_index]; + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-rows-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + event.stopPropagation(); + }); + + //表格列标题 改变列宽按钮 + $("#luckysheet-cols-change-size").mousedown(function (event) { + //有批注在编辑时 + luckysheetPostil.removeActivePs(); + + $("#luckysheet-input-box").hide(); + $("#luckysheet-cols-change-size").css({ "opacity": 1 }); + + let mouse = mouseposition(event.pageX, event.pageY); + let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft(); + let scrollTop = $("#luckysheet-cell-main").scrollTop(); + let winH = $("#luckysheet-cell-main").height(); + let x = mouse[0] + scrollLeft; + + let row_index = Store.visibledatarow.length - 1, + row = Store.visibledatarow[row_index], row_pre = 0; + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + + Store.luckysheet_cols_change_size = true; + Store.luckysheet_scroll_status = true; + $("#luckysheet-change-size-line").css({ + "height": winH + scrollTop, + "border-width": "0 1px 0 0", + "top": 0, + "left": col - 3, + "width": "1px", + "display": "block", + "cursor": "ew-resize" + }); + $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "ew-resize"); + Store.luckysheet_cols_change_size_start = [col_pre, col_index]; + $("#luckysheet-rightclick-menu").hide(); + $("#luckysheet-cols-h-hover").hide(); + $("#luckysheet-cols-menu-btn").hide(); + Store.luckysheet_cols_dbclick_times = 0; + event.stopPropagation(); + }).dblclick(function () { + luckysheetcolsdbclick(); + }); + + $("#luckysheet-cols-menu-btn").click(function (event) { + let $menu = $("#luckysheet-rightclick-menu"); + let offset = $(this).offset(); + $("#luckysheet-cols-rows-shift").show(); + Store.luckysheetRightHeadClickIs = "column"; + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left); + $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right); + + $("#luckysheet-cols-rows-add").show(); + $("#luckysheet-cols-rows-data").hide(); + $("#luckysheet-cols-rows-shift").show(); + $("#luckysheet-cols-rows-handleincell").hide(); + + showrightclickmenu($menu, offset.left, offset.top + 18); + Store.luckysheet_cols_menu_status = true; + }); + + //向左增加列,向上增加行 + $("#luckysheet-add-lefttop, #luckysheet-add-lefttop_t").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(locale_info.tipInputNumberLimit); + } + else{ + tooltip.info(locale_info.tipInputNumberLimit, ""); + } + return; + } + + let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0]; + luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "lefttop"); + }); + $("#luckysheet-addTopRows").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(llocale_info.tipInputNumberLimit); + } + else{ + tooltip.info(llocale_info.tipInputNumberLimit, ""); + } + return; + } + + let st_index = Store.luckysheet_select_save[0].row[0]; + luckysheetextendtable('row', st_index, value, "lefttop"); + }) + $("#luckysheet-addLeftCols").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(llocale_info.tipInputNumberLimit); + } + else{ + tooltip.info(llocale_info.tipInputNumberLimit, ""); + } + return; + } + + let st_index = Store.luckysheet_select_save[0].column[0]; + luckysheetextendtable('column', st_index, value, "lefttop"); + }) + + //向右增加列,向下增加行 + $("#luckysheet-add-rightbottom, #luckysheet-add-rightbottom_t").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(llocale_info.tipInputNumberLimit); + } + else{ + tooltip.info(llocale_info.tipInputNumberLimit, ""); + } + + return; + } + + let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1]; + luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "rightbottom"); + }); + $("#luckysheet-addBottomRows").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(llocale_info.tipInputNumberLimit); + } + else{ + tooltip.info(llocale_info.tipInputNumberLimit, ""); + } + + return; + } + + let st_index = Store.luckysheet_select_save[0].row[1]; + luckysheetextendtable('row', st_index, value, "rightbottom"); + }); + $("#luckysheet-addRightCols").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + + return; + } + + let $t = $(this), value = $t.parent().find("input").val(); + if (!isRealNum(value)) { + if(isEditMode()){ + alert(locale_info.tipInputNumber); + } + else{ + tooltip.info(locale_info.tipInputNumber, ""); + } + + return; + } + + value = parseInt(value); + + if (value < 1 || value > 100) { + if(isEditMode()){ + alert(llocale_info.tipInputNumberLimit); + } + else{ + tooltip.info(llocale_info.tipInputNumberLimit, ""); + } + + return; + } + + let st_index = Store.luckysheet_select_save[0].column[1]; + luckysheetextendtable('column', st_index, value, "rightbottom"); + }); + + //删除选中行列 + $("#luckysheet-del-selected, #luckysheet-del-selected_t").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(Store.luckysheetRightHeadClickIs == "row"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + else if(Store.luckysheetRightHeadClickIs == "column"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + return; + } + + let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0], + ed_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1]; + luckysheetdeletetable(Store.luckysheetRightHeadClickIs, st_index, ed_index); + }); + $("#luckysheet-delRows").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(Store.luckysheetRightHeadClickIs == "row"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + else if(Store.luckysheetRightHeadClickIs == "column"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + return; + } + + let st_index = Store.luckysheet_select_save[0].row[0], + ed_index = Store.luckysheet_select_save[0].row[1]; + luckysheetdeletetable('row', st_index, ed_index); + }) + $("#luckysheet-delCols").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 1){ + if(Store.luckysheetRightHeadClickIs == "row"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + else if(Store.luckysheetRightHeadClickIs == "column"){ + if(isEditMode()){ + alert(locale_drag.noMulti); + } + else{ + tooltip.info(locale_drag.noMulti, ""); + } + } + return; + } + + let st_index = Store.luckysheet_select_save[0].column[0], + ed_index = Store.luckysheet_select_save[0].column[1]; + luckysheetdeletetable('column', st_index, ed_index); + }) + + //隐藏、显示行 + $("#luckysheet-hidRows").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + let cfg = $.extend(true, {}, Store.config); + if(cfg["rowhidden"] == null){ + cfg["rowhidden"] = {}; + } + + 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]; + + for(let r = r1; r <= r2; r++){ + cfg["rowhidden"][r] = 0; + } + } + + //保存撤销 + if(Store.clearjfundo){ + let redo = {}; + redo["type"] = "showHidRows"; + 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["rowhidden"], { "k": "rowhidden" }); + + //行高、列宽 刷新 + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + }) + $("#luckysheet-showHidRows").click(function (event) { + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + let cfg = $.extend(true, {}, Store.config); + if(cfg["rowhidden"] == null){ + return; + } + + 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]; + + for(let r = r1; r <= r2; r++){ + delete cfg["rowhidden"][r]; + } + } + + //保存撤销 + if(Store.clearjfundo){ + let redo = {}; + redo["type"] = "showHidRows"; + 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["rowhidden"], { "k": "rowhidden" }); + + //行高、列宽 刷新 + jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); + }) + + //清除单元格内容 + $("#luckysheet-delete-text").click(function(){ + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + if(Store.luckysheet_select_save.length > 0){ + let d = editor.deepCopyFlowData(Store.flowdata); + + let has_PartMC = false; + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + if(hasPartMC(Store.config, r1, r2, c1, c2)){ + has_PartMC = true; + break; + } + } + + if(has_PartMC){ + if(isEditMode()){ + alert(locale_drag.noPartMerge); + } + else{ + tooltip.info(locale_drag.noPartMerge, ""); + } + + return; + } + + 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]; + let c1 = Store.luckysheet_select_save[s].column[0], + c2 = Store.luckysheet_select_save[s].column[1]; + + for(let r = r1; r <= r2; r++){ + for(let c = c1; c <= c2; c++){ + if(pivotTable.isPivotRange(r, c)){ + continue; + } + + if(getObjType(d[r][c]) == "object"){ + delete d[r][c]["m"]; + delete d[r][c]["v"]; + + if(d[r][c]["f"] != null){ + delete d[r][c]["f"]; + formula.delFunctionGroup(r, c, Store.currentSheetIndex); + + delete d[r][c]["spl"]; + } + } + else{ + d[r][c] = null; + } + } + } + } + + jfrefreshgrid(d, Store.luckysheet_select_save); + } + }); + + //行高列宽设置 + $("#luckysheet-rows-cols-changesize").click(function(){ + $("#luckysheet-rightclick-menu").hide(); + $("#" + Store.container).attr("tabindex", 0).focus(); + + let size = parseInt($(this).siblings("input[type='number']").val().trim()); + + if(size < 0 || size > 255){ + if(isEditMode()){ + alert(llocale_info.tipRowHeightLimit); + } + else{ + tooltip.info(llocale_info.tipRowHeightLimit, ""); + } + + return; + } + + let cfg = $.extend(true, {}, Store.config); + let type; + + if(Store.luckysheetRightHeadClickIs == "row"){ + type = "resizeR"; + + if(cfg["rowlen"] == null){ + cfg["rowlen"] = {}; + } + + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + let r1 = Store.luckysheet_select_save[s].row[0]; + let r2 = Store.luckysheet_select_save[s].row[1]; + + for(let r = r1; r <= r2; r++){ + cfg["rowlen"][r] = size; + } + } + } + else if(Store.luckysheetRightHeadClickIs == "column"){ + type = "resizeC"; + + if(cfg["columlen"] == null){ + cfg["columlen"] = {}; + } + + for(let s = 0; s < Store.luckysheet_select_save.length; s++){ + let c1 = Store.luckysheet_select_save[s].column[0]; + let c2 = Store.luckysheet_select_save[s].column[1]; + + for(let c = c1; c <= c2; c++){ + cfg["columlen"][c] = size; + } + } + } + + if (Store.clearjfundo) { + Store.jfundo = []; + Store.jfredo.push({ + "type": "resize", + "ctrlType": type, + "config": $.extend(true, {}, Store.config), + "curconfig": $.extend(true, {}, cfg), + "sheetIndex": Store.currentSheetIndex + }); + } + + //config + Store.config = cfg; + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + + if(Store.luckysheetRightHeadClickIs == "row"){ + server.saveParam("cg", Store.currentSheetIndex, cfg["rowlen"], { "k": "rowlen" }); + jfrefreshgrid_rhcw(Store.flowdata.length, null); + } + else if(Store.luckysheetRightHeadClickIs == "column"){ + server.saveParam("cg", Store.currentSheetIndex, cfg["columlen"], { "k": "columlen" }); + jfrefreshgrid_rhcw(null, Store.flowdata[0].length); + } + }); +} + + +function luckysheetcolsdbclick() { + Store.luckysheet_cols_change_size = false; + $("#luckysheet-change-size-line").hide(); + $("#luckysheet-cols-change-size").css("opacity", 0); + $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default"); + + let mouse = mouseposition(event.pageX, event.pageY); + let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft(); + let x = mouse[0] + scrollLeft; + let winW = $(window).width(); + + let row_index = Store.visibledatarow.length - 1, + row = Store.visibledatarow[row_index], + row_pre = 0; + let col_location = colLocation(x), + col = col_location[1], + col_pre = col_location[0], + col_index = col_location[2]; + Store.luckysheet_cols_change_size_start = [col_pre, col_index]; + let dataflow = $("#luckysheetTableContent").get(0).getContext("2d"); + let cfg = $.extend(true, {}, Store.config); + + let matchColumn = {}; + 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]; + + if (col_index < c1 || col_index > c2) { + if(col_index in matchColumn){//此列已计算过 + continue; + } + + x = -Infinity; + let countret = 0; + let fontsize = 13; + for (let r = 0; r < Store.flowdata.length; r++) { + if (countret >= 15) { + break; + } + + let value = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata); + let mask = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata, "m"); + + if(mask != null){ + value = mask; + } + + let cell = Store.flowdata[r][Store.luckysheet_cols_change_size_start[1]]; + if(getObjType(cell) == "object" && ("fs" in cell)){ + if(cell.fs > fontsize){ + fontsize = cell.fs; + } + } + + if (value == null || value.toString().length == 0) { + countret++; + continue; + } + let textMetrics = dataflow.measureText(value).width; + if (textMetrics > x) { + x = textMetrics; + } + } + + let size = x + fontsize * 1.5; + if ((x + 3) < 30) { + size = 30; + } + + if (x >= winW - 100 + scrollLeft) { + size = winW - 100 + scrollLeft; + } + + if (cfg["columlen"] == null) { + cfg["columlen"] = {}; + } + + cfg["columlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size); + + matchColumn[col_index] = 1; + } + else { + for (let c = c1; c <= c2; c++) { + if(c in matchColumn){//此列已计算过 + continue; + } + + x = -Infinity; + let countret = 0; + let fontsize = 13; + for (let r = 0; r < Store.flowdata.length; r++) { + if (countret >= 15) { + break; + } + let value = getcellvalue(r, c, Store.flowdata); + + let cell = Store.flowdata[r][c]; + if(getObjType(cell) == "object" && ("fs" in cell)){ + if(cell.fs > fontsize){ + fontsize = cell.fs; + } + } + + if (isRealNull(value)) { + countret++; + continue; + } + + let textMetrics = dataflow.measureText(value).width; + if (textMetrics > x) { + x = textMetrics; + } + } + + let size = x + fontsize*1.5;; + if ((x + 3) < 30) { + size = 30; + } + + if (x >= winW - 100 + scrollLeft) { + size = winW - 100 + scrollLeft; + } + + if (cfg["columlen"] == null) { + cfg["columlen"] = {}; + } + cfg["columlen"][c] = Math.ceil(size); + + matchColumn[c] = 1; + } + } + } + + jfrefreshgridall(Store.flowdata[0].length, Store.flowdata.length, Store.flowdata, cfg, Store.luckysheet_select_save, "resizeC", "columlen"); +} \ No newline at end of file diff --git a/src/controllers/searchReplace.js b/src/controllers/searchReplace.js index da3ac20e8..9d64f119a 100644 --- a/src/controllers/searchReplace.js +++ b/src/controllers/searchReplace.js @@ -21,6 +21,7 @@ const luckysheetSearchReplace = { const _locale = locale(); const locale_findAndReplace = _locale.findAndReplace; + const locale_button = _locale.button; let content = '
    ' + ''+ locale_findAndReplace.find +'' + @@ -58,8 +59,9 @@ const luckysheetSearchReplace = { "addclass": "luckysheet-search-replace", "title": "", "content": content, - "botton": '', - "style": "z-index:100003" + "botton": '', + "style": "z-index:100003", + "close":locale_button.close })); let $t = $("#luckysheet-search-replace").find(".luckysheet-modal-dialog-content").css("min-width", 500).end(), myh = $t.outerHeight(), diff --git a/src/controllers/select.js b/src/controllers/select.js index 006f3ec72..03a4078bb 100644 --- a/src/controllers/select.js +++ b/src/controllers/select.js @@ -5,6 +5,7 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location'; import browser from '../global/browser'; import { getSheetIndex, getRangetxt } from '../methods/get'; import Store from '../store'; +import locale from '../locale/locale'; //公式函数 选区实体框 function seletedHighlistByindex(id, r1, r2, c1, c2) { @@ -21,7 +22,7 @@ function seletedHighlistByindex(id, r1, r2, c1, c2) { }); } -//选区 +//Set selection highlight function selectHightlightShow() { $("#luckysheet-cell-selected-boxs").show(); $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove(); @@ -347,6 +348,9 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet let scrollWidth = $("#luckysheet-cell-main").scrollLeft(), scrollHeight = $("#luckysheet-cell-main").scrollTop(); + const _locale = locale(); + const locale_info = _locale.info; + if (rowl >= 4) { let leftv = left - 25; if (leftv < 0) { @@ -362,7 +366,7 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet topv = scrollHeight + drawHeight / 2; } - $("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block" }).html("
    " + rowl.toString().split("").join("
    ") + "
    "); + $("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block" }).html("
    " + rowl.toString().split("").join("
    ") + "
    "+locale_info.row+"
    "); } else { $("#luckysheet-row-count-show").hide(); @@ -383,7 +387,7 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet leftv = scrollWidth + drawWidth / 2; } - $("#luckysheet-column-count-show").css({ "left": leftv, "top": topv, "display": "block" }).text(coll + "列"); + $("#luckysheet-column-count-show").css({ "left": leftv, "top": topv, "display": "block" }).text(coll + locale_info.column); } else { $("#luckysheet-column-count-show").hide(); diff --git a/src/controllers/sheetBar.js b/src/controllers/sheetBar.js new file mode 100644 index 000000000..4d5300b3d --- /dev/null +++ b/src/controllers/sheetBar.js @@ -0,0 +1,454 @@ + +import sheetmanage from './sheetmanage'; +import server from './server'; +import { sheetselectlistitemHTML, sheetselectlistHTML, keycode } from './constant'; +import { + replaceHtml, + mouseclickposition, +} from '../utils/util'; +import { getSheetIndex } from '../methods/get'; +import { isEditMode } from '../global/validate'; +import formula from '../global/formula'; +import cleargridelement from '../global/cleargridelement'; +import tooltip from '../global/tooltip'; +import locale from '../locale/locale'; +import Store from '../store'; + + + + +//表格底部名称栏区域 相关事件(增、删、改、隐藏显示、颜色等等) +let isInitialSheetConfig = false, luckysheetcurrentSheetitem = null, jfdbclicklagTimeout = null; +function showsheetconfigmenu() { + if (!isInitialSheetConfig) { + isInitialSheetConfig = true; + const _locale = locale(); + let locale_toolbar = _locale.toolbar; + $("#luckysheetsheetconfigcolorur").spectrum({ + showPalette: true, + preferredFormat: "hex", + clickoutFiresChange: false, + showInitial: true, + showInput: true, + flat: true, + hideAfterPaletteSelect: false, + showSelectionPalette: true, + maxPaletteSize: 10, + cancelText: _locale.sheetconfig.cancelText, + chooseText: _locale.sheetconfig.chooseText, + togglePaletteMoreText: locale_toolbar.toolMore, + togglePaletteLessText: locale_toolbar.toolLess, + clearText: locale_toolbar.clearText, + noColorSelectedText: locale_toolbar.noColorSelectedText, + palette: [["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", "rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"], ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)"], ["rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)"], ["rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)"], ["rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)", "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)"], ["rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"], ["#c1232b", "#27727b", "#fcce10", "#e87c25", "#b5c334", "#fe8463", "#9bca63", "#fad860", "#f3a43b", "#60c0dd", "#d7504b", "#c6e579", "#f4e001", "#f0805a", "#26c0c0", "#c12e34", "#e6b600", "#0098d9", "#2b821d", "#005eaa", "#339ca8", "#cda819", "#32a487", "#3fb1e3", "#6be6c1", "#626c91", "#a0a7e6", "#c4ebad", "#96dee8"]], + change: function (color) { + let $input = $(this); + if (color != null) { + color = color.toHexString(); + } + else { + color = "rgb(0, 0, 0)"; + } + + let oldcolor = null; + if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ + oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); + } + + luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); + luckysheetcurrentSheetitem.append('
    '); + let index = getSheetIndex(Store.currentSheetIndex); + Store.luckysheetfile[index].color = color; + server.saveParam("all", Store.currentSheetIndex, color, { "k": "color" }); + + if (Store.clearjfundo) { + let redo = {}; + redo["type"] = "sheetColor"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["oldcolor"] = oldcolor; + redo["color"] = color; + + Store.jfundo = []; + Store.jfredo.push(redo); + } + } + }); + + $("#luckysheetsheetconfigcolorreset").click(function () { + let oldcolor = null; + if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ + oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); + } + + luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); + let index = getSheetIndex(Store.currentSheetIndex); + Store.luckysheetfile[index].color = null; + server.saveParam("all", Store.currentSheetIndex, null, { "k": "color" } ); + + if (Store.clearjfundo) { + let redo = {}; + redo["type"] = "sheetColor"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["oldcolor"] = oldcolor; + redo["color"] = null; + + Store.jfundo = []; + Store.jfredo.push(redo); + } + }); + } + + let index = getSheetIndex(Store.currentSheetIndex); + if (Store.luckysheetfile[index].color != null && Store.luckysheetfile[index].color.length > 0) { + $("#luckysheetsheetconfigcolorur").spectrum("set", Store.luckysheetfile[index].color); + + } + + $("#luckysheetsheetconfigcolorur").parent().find("span, div, button, input, a").addClass("luckysheet-mousedown-cancel"); + setTimeout(function(){ + mouseclickposition($("#luckysheet-rightclick-sheet-menu"), luckysheetcurrentSheetitem.offset().left + luckysheetcurrentSheetitem.width(), luckysheetcurrentSheetitem.offset().top - 18, "leftbottom"); + },1); +} + +let luckysheetsheetrightclick = function ($t, $cur, e) { + clearTimeout(jfdbclicklagTimeout); + if ($cur.hasClass("luckysheet-sheets-item-name") && $cur.attr("contenteditable") == "true") { + return; + } + if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()) { + setTimeout(function () { + formula.setCaretPosition(formula.rangeSetValueTo.get(0), 0, formula.rangeSetValueTo.text().length); + formula.createRangeHightlight(); + $("#luckysheet-input-box-index").find(".luckysheet-input-box-index-sheettxt").remove().end().prepend("" + sheetmanage.getSheetName(formula.rangetosheet) + "!").show(); + $("#luckysheet-input-box-index").css({"left": $("#luckysheet-input-box").css("left"), "top": (parseInt($("#luckysheet-input-box").css("top")) - 20) + "px", "z-index": $("#luckysheet-input-box").css("z-index")}); + }, 1); + } + else { + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").remove(); + } + + $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active"); + $t.addClass("luckysheet-sheets-item-active"); + cleargridelement(e); + sheetmanage.changeSheet($t.data("index")); + + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + + if ($cur.hasClass("luckysheet-sheets-item-menu") || $cur.hasClass("fa-sort-desc") || e.which == "3") { + luckysheetcurrentSheetitem = $cur.closest(".luckysheet-sheets-item"); + showsheetconfigmenu(); + } +} + + +export function initialSheetBar(){ + const _locale = locale(); + const locale_sheetconfig = _locale.sheetconfig; + + $("#luckysheet-sheet-area").on("mousedown", "div.luckysheet-sheets-item", function (e) { + if(isEditMode()){ + // alert("非编辑模式下不允许该操作!"); + return; + } + + let $t = $(this), $cur = $(e.target), $item = $cur.closest(".luckysheet-sheets-item"); + + if (e.which == "3") { + luckysheetsheetrightclick($t, $cur, e); + luckysheetcurrentSheetitem = $item; + showsheetconfigmenu(); + return; + } + + if ($item.hasClass("luckysheet-sheets-item-active") && $item.find(".luckysheet-sheets-item-name").attr("contenteditable") == "false") { + jfdbclicklagTimeout = setTimeout(function () { + Store.luckysheet_sheet_move_status = true; + Store.luckysheet_sheet_move_data = {}; + Store.luckysheet_sheet_move_data.widthlist = []; + + $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").each(function (i) { + if (i == 0) { + Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth())); + } + else { + Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()) + Store.luckysheet_sheet_move_data.widthlist[i - 1]); + } + }); + + Store.luckysheet_sheet_move_data.curindex = $("#luckysheet-sheet-area div.luckysheet-sheets-item").index($item); + let x = e.pageX; + Store.luckysheet_sheet_move_data.curleft = x - $item.offset().left; + Store.luckysheet_sheet_move_data.pageX = x; + Store.luckysheet_sheet_move_data.activeobject = $item; + Store.luckysheet_sheet_move_data.cursorobject = $cur; + let $itemclone = $item.clone().css("visibility", "hidden").attr("id", "luckysheet-sheets-item-clone"); + $item.after($itemclone); + $item.css({ "position": "absolute", "opacity": 0.8, "cursor": "move", "transition": "initial", "z-index": 10 }); + }, 200); + } + }).on("click", "div.luckysheet-sheets-item", function (e) { + if(isEditMode()){ + // alert("非编辑模式下不允许该操作!"); + return; + } + + let $t = $(this), $cur = $(e.target); + luckysheetsheetrightclick($t, $cur, e); + }); + + let luckysheetsheetnameeditor = function ($t) { + $t.attr("contenteditable", "true").addClass("luckysheet-mousedown-cancel").data("oldtxt", $t.text()); + + setTimeout(function () { + if (document.selection) { + let range = document.body.createTextRange(); + range.moveToElementText($t.get(0)); + range.select(); + } else if (window.getSelection) { + let range = document.createRange(); + range.selectNodeContents($t.get(0)); + window.getSelection().removeAllRanges(); + window.getSelection().addRange(range); + } + }, 1); + } + + $("#luckysheet-sheet-area").on("dblclick", "span.luckysheet-sheets-item-name", function (e) { + luckysheetsheetnameeditor($(this)); + }); + + $("#luckysheet-sheet-area").on("blur", "span.luckysheet-sheets-item-name", function (e) { + let $t = $(this); + let txt = $t.text(), oldtxt = $t.data("oldtxt"); + + let index = getSheetIndex(Store.currentSheetIndex); + for (let i = 0; i < Store.luckysheetfile.length; i++) { + if (index != i && Store.luckysheetfile[i].name == txt) { + if(isEditMode()){ + alert(locale_sheetconfig.tipNameRepeat); + } + else{ + tooltip.info("", locale_sheetconfig.tipNameRepeat); + } + $t.text(oldtxt).attr("contenteditable", "false"); + return; + } + } + + let winW = $(window).width(); + + let c_width = 0; + $("#luckysheet-sheet-container-c > div.luckysheet-sheets-item:visible").each(function(){ + c_width += $(this).outerWidth(); + }); + + if (c_width >= winW * 0.7) { + $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); + $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + } + + Store.luckysheetfile[index].name = txt; + server.saveParam("all", Store.currentSheetIndex, txt, { "k": "name" }); + + $t.attr("contenteditable", "false").removeClass("luckysheet-mousedown-cancel"); + + if (Store.clearjfundo) { + let redo = {}; + redo["type"] = "sheetName"; + redo["sheetIndex"] = Store.currentSheetIndex; + + redo["oldtxt"] = oldtxt; + redo["txt"] = txt; + + Store.jfundo = []; + Store.jfredo.push(redo); + } + }); + + $("#luckysheet-sheet-area").on("keydown", "span.luckysheet-sheets-item-name", function (e) { + let kcode = e.keyCode; + let $t = $(this); + if (kcode == keycode.ENTER) { + let index = getSheetIndex(Store.currentSheetIndex); + Store.luckysheetfile[index].name = $t.text(); + $t.attr("contenteditable", "false"); + } + }); + + $("#luckysheetsheetconfigrename").click(function () { + luckysheetsheetnameeditor(luckysheetcurrentSheetitem.find("span.luckysheet-sheets-item-name")); + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheetsheetconfigshow").click(function () { + $("#luckysheet-sheets-m").click(); + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheetsheetconfigmoveleft").click(function () { + if (luckysheetcurrentSheetitem.prevAll(":visible").length > 0) { + luckysheetcurrentSheetitem.insertBefore(luckysheetcurrentSheetitem.prevAll(":visible").eq(0)); + sheetmanage.reOrderAllSheet(); + } + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheetsheetconfigmoveright").click(function () { + if (luckysheetcurrentSheetitem.nextAll(":visible").length > 0) { + luckysheetcurrentSheetitem.insertAfter(luckysheetcurrentSheetitem.nextAll(":visible").eq(0)); + sheetmanage.reOrderAllSheet(); + } + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheetsheetconfigdelete").click(function (e) { + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + + if($("#luckysheet-sheet-container-c .luckysheet-sheets-item:visible").length <= 1){ + if(isEditMode()){ + alert(locale_sheetconfig.noMoreSheet); + } + else{ + tooltip.info(locale_sheetconfig.noMoreSheet, ""); + } + + return; + } + + let index = getSheetIndex(Store.currentSheetIndex); + + tooltip.confirm(locale_sheetconfig.confirmDelete+"【" + Store.luckysheetfile[index].name + "】?", ""+locale_sheetconfig.redoDelete+"", function () { + sheetmanage.deleteSheet(luckysheetcurrentSheetitem.data("index")); + }, null); + + $("#luckysheet-input-box").removeAttr("style"); + }); + + $("#luckysheetsheetconfigcopy").click(function (e) { + sheetmanage.copySheet(luckysheetcurrentSheetitem.data("index"), e); + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheetsheetconfighide").click(function () { + if ($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").length == 1) { + if(isEditMode()){ + alert(locale_sheetconfig.noHide); + } + else{ + tooltip.info("", locale_sheetconfig.noHide); + } + return; + } + sheetmanage.setSheetHide(luckysheetcurrentSheetitem.data("index")); + $("#luckysheet-input-box").removeAttr("style"); + $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); + }); + + $("#luckysheet-sheets-add").click(function (e) { + sheetmanage.addNewSheet(e); + sheetmanage.locationSheet(); + $("#luckysheet-input-box").removeAttr("style"); + }); + + let sheetscrollani = null, sheetscrollstart = 0, sheetscrollend = 0, sheetscrollstep = 150; + $("#luckysheet-sheets-leftscroll").click(function () { + let $c = $("#luckysheet-sheet-container-c"); + sheetscrollstart = $c.scrollLeft(); + sheetscrollend = $c.scrollLeft() - sheetscrollstep; + + if (sheetscrollend <= 0) { + $("#luckysheet-sheet-container .docs-sheet-fade-left").hide(); + } + $("#luckysheet-sheet-container .docs-sheet-fade-right").show(); + + clearInterval(sheetscrollani); + sheetscrollani = setInterval(function () { + sheetscrollstart -= 4; + $c.scrollLeft(sheetscrollstart); + if (sheetscrollstart <= sheetscrollend) { + clearInterval(sheetscrollani); + } + }, 1); + }); + + $("#luckysheet-sheets-rightscroll").click(function () { + let $c = $("#luckysheet-sheet-container-c"); + sheetscrollstart = $c.scrollLeft(); + sheetscrollend = $c.scrollLeft() + sheetscrollstep; + + if (sheetscrollstart > 0) { + $("#luckysheet-sheet-container .docs-sheet-fade-right").hide(); + } + $("#luckysheet-sheet-container .docs-sheet-fade-left").show(); + + clearInterval(sheetscrollani); + sheetscrollani = setInterval(function () { + sheetscrollstart += 4; + $c.scrollLeft(sheetscrollstart); + if (sheetscrollstart >= sheetscrollend) { + clearInterval(sheetscrollani); + } + }, 1); + }); + + let initialOpenSheet = true; + $("#luckysheet-sheets-m").click(function (e) { + $("#luckysheet-sheet-list").html(""); + + let item = ""; + for (let i = 0; i < Store.luckysheetfile.length; i++) { + let f = Store.luckysheetfile[i], icon = '', style = ""; + if (f["status"] == 1) { + icon = ''; + } + + if (f["hide"] == 1) { + icon = ''; + style += "color:#BBBBBB;"; + } + + if (f["color"] != null && f["color"].length > 0) { + style += "border-right:4px solid " + f["color"] + ";"; + } + + item += replaceHtml(sheetselectlistitemHTML, { "index": f["index"], "name": f["name"], "icon": icon, "style": style }); + } + + if (initialOpenSheet) { + $("#" + Store.container).append(replaceHtml(sheetselectlistHTML, { "item": item })); + $("#luckysheet-sheet-list").on("click", ".luckysheet-cols-menuitem", function (e) { + if(isEditMode()){ + // tooltip.info("提示", "图表编辑模式下不允许该操作!"); + alert(locale_sheetconfig.chartEditNoOpt); + return; + } + + let $item = $(this), index = $item.data("index"); + + if ($item.data("index") != Store.currentSheetIndex) { + sheetmanage.setSheetShow(index); + sheetmanage.locationSheet(); + } + }); + + initialOpenSheet = false; + } + else { + $("#luckysheet-sheet-list").html(item); + } + + let $t = $("#luckysheet-sheet-list"); + + mouseclickposition($t, $(this).offset().left, $(this).offset().top - 12, "leftbottom"); + $("#luckysheet-input-box").removeAttr("style"); + }); + +} \ No newline at end of file diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 5e4cc6034..11b3ea1ee 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -10,7 +10,7 @@ import editor from '../global/editor'; import { luckysheetextendtable, luckysheetdeletetable } from '../global/extend'; import { isRealNum } from '../global/validate'; import { replaceHtml, getObjType, chatatABC } from '../utils/util'; -import { sheetHTML } from './constant'; +import { sheetHTML,luckysheetlodingHTML } from './constant'; import server from './server'; import luckysheetConfigsetting from './luckysheetConfigsetting'; import pivotTable from './pivotTable'; @@ -20,6 +20,7 @@ import luckysheetFreezen from './freezen'; import { createFilterOptions, labelFilterOptionState } from './filter'; import { selectHightlightShow, selectionCopyShow } from './select'; import Store from '../store'; +import locale from '../locale/locale'; const sheetmanage = { generateRandomSheetIndex: function(prefix) { @@ -62,9 +63,12 @@ const sheetmanage = { generateCopySheetName: function(file, name) { let copySheetName = ""; - if(name.toString().indexOf("(副本") > -1){ - let copy_i = name.toString().indexOf("(副本"); - let name2 = name.toString().substring(0, copy_i) + "(副本"; + let _locale = locale(); + let locale_info = _locale.info; + + if(name.toString().indexOf("("+locale_info.copy) > -1){ + let copy_i = name.toString().indexOf("("+locale_info.copy); + let name2 = name.toString().substring(0, copy_i) + "("+locale_info.copy; let index = null; for(let i = 0; i < file.length; i++){ @@ -94,7 +98,7 @@ const sheetmanage = { else{ let index = null; let hascopy = false; - let name2 = name + "(副本"; + let name2 = name + "("+locale_info.copy; for(let i = 0; i < file.length; i++){ let fileName = file[i].name.toString(); @@ -115,15 +119,15 @@ const sheetmanage = { if(hascopy){ if(index == null){ - copySheetName = name + "(副本2)"; + copySheetName = name + "("+ locale_info.copy +"2)"; } else{ index++; - copySheetName = name + "(副本" + index + ")"; + copySheetName = name + "("+ locale_info.copy +"" + index + ")"; } } else{ - copySheetName = name + "(副本)"; + copySheetName = name + "("+ locale_info.copy +")"; } } @@ -632,7 +636,7 @@ const sheetmanage = { width: Store.luckysheetTableContentHW[0], height: Store.luckysheetTableContentHW[1] }).get(0).getContext("2d"); - + let locale_info = locale().info; let key = server.gridKey; let cahce_key = key + "__qkcache"; @@ -663,7 +667,7 @@ const sheetmanage = { _this.restoreSheetAll(Store.currentSheetIndex); luckysheetrefreshgrid(0, 0); - $("#luckysheet_info_detail_save").html("已恢复本地缓存"); + $("#luckysheet_info_detail_save").html(locale_info.detailSave); if (!!file.isPivotTable) { Store.luckysheetcurrentisPivotTable = true; @@ -875,7 +879,7 @@ const sheetmanage = { server.saveParam("shs", null, Store.currentSheetIndex); } else{ - $("#luckysheet-grid-window-1").append('
    渲染中...
    '); + $("#luckysheet-grid-window-1").append(luckysheetlodingHTML()); let sheetindex = _this.checkLoadSheetIndex(file); diff --git a/src/core.js b/src/core.js index d80a7552e..eeaf26810 100644 --- a/src/core.js +++ b/src/core.js @@ -7,6 +7,13 @@ import luckysheetConfigsetting from './controllers/luckysheetConfigsetting'; import sheetmanage from './controllers/sheetmanage'; import luckysheetsizeauto from './controllers/resize'; import luckysheetHandler from './controllers/handler'; +import {initialFilterHandler} from './controllers/filter'; +import {initialMatrixOperation} from './controllers/matrixOperation'; +import {initialSheetBar} from './controllers/sheetBar'; +import {formulaBarInitial} from './controllers/formulaBar'; +import {rowColumnOperationInitial} from './controllers/rowColumnOperation'; +import {keyboardInitial} from './controllers/keyboard'; +import {orderByInitial} from './controllers/orderBy'; import {initPlugins} from './controllers/expendPlugins'; import { getluckysheetfile, @@ -14,11 +21,15 @@ import { getconfig, } from './methods/get'; import { - setluckysheetfile, - setluckysheet_select_save, - setconfig, + setluckysheet_select_save } from './methods/set'; -import { luckysheetrefreshgrid } from './global/refresh'; +import { luckysheetrefreshgrid, jfrefreshgrid } from './global/refresh'; +import functionlist from './function/functionlist'; +import { luckysheetlodingHTML } from './controllers/constant'; +import { getcellvalue, getdatabyselection } from './global/getdata'; +import { setcellvalue } from './global/setdata'; +import { selectHightlightShow } from './controllers/select'; +import method from './global/method'; let luckysheet = {}; @@ -81,6 +92,9 @@ luckysheet.create = function (setting) { // Register plugins initPlugins(extendsetting.plugins); + // Store formula information, including internationalization + functionlist(); + let devicePixelRatio = extendsetting.devicePixelRatio; if(devicePixelRatio == null){ devicePixelRatio = 1; @@ -88,13 +102,13 @@ luckysheet.create = function (setting) { Store.devicePixelRatio = Math.ceil(devicePixelRatio); //loading - $("#" + container).append('
    渲染中...
    '); + $("#" + container).append(luckysheetlodingHTML()); let data = []; if (loadurl == "") { sheetmanage.initialjfFile(menu, title); luckysheetsizeauto(); - luckysheetHandler(); + initialWorkBook(); } else { $.post(loadurl, {"gridKey" : server.gridKey}, function (d) { @@ -103,7 +117,7 @@ luckysheet.create = function (setting) { sheetmanage.initialjfFile(menu, title); luckysheetsizeauto(); - luckysheetHandler(); + initialWorkBook(); //需要更新数据给后台时,建立WebSocket连接 if(server.allowUpdate){ @@ -113,6 +127,17 @@ luckysheet.create = function (setting) { } } +function initialWorkBook(){ + luckysheetHandler();//Overall dom initialization + initialFilterHandler();//Filter initialization + initialMatrixOperation();//Right click matrix initialization + initialSheetBar();//bottom sheet bar initialization + formulaBarInitial();//top formula bar initialization + rowColumnOperationInitial();//row and coloumn operate initialization + keyboardInitial();//Keyboard operate initialization + orderByInitial();//menu bar orderby function initialization +} + //获取所有表格数据 luckysheet.getluckysheetfile = getluckysheetfile; @@ -125,17 +150,50 @@ luckysheet.setluckysheet_select_save = setluckysheet_select_save; //获取当前表格 config配置 luckysheet.getconfig = getconfig; -//设置当前表格 config配置 -luckysheet.setconfig = setconfig; - //二维数组数据 转化成 {r, c, v}格式 一维数组 (传入参数为二维数据data) luckysheet.getGridData = sheetmanage.getGridData; //生成表格所需二维数组 (传入参数为表格数据对象file) luckysheet.buildGridData = sheetmanage.buildGridData; +// Refresh the canvas display data according to scrollHeight and scrollWidth luckysheet.luckysheetrefreshgrid = luckysheetrefreshgrid; +// Refresh canvas +luckysheet.jfrefreshgrid = jfrefreshgrid; + +// Get the value of the cell +luckysheet.getcellvalue = getcellvalue; + +// Set cell value +luckysheet.setcellvalue = setcellvalue; + +// Get selection range value +luckysheet.getdatabyselection = getdatabyselection; + +// Data of the current table +luckysheet.flowdata = function () { + return Store.flowdata; +} + +// Set selection highlight +luckysheet.selectHightlightShow = selectHightlightShow; + +// Set the worksheet to hide +// Use the call method to change the `this` of the function to `this` of sheetmanage, +// Prevent _this error in setSheetHide +luckysheet.setSheetHide = function(index) { + return sheetmanage.setSheetHide.call(sheetmanage,index); +} + +// Set the worksheet to show +luckysheet.setSheetShow = function(index) { + return sheetmanage.setSheetShow.call(sheetmanage,index); +} + +// Reset parameters after destroying the table +luckysheet.destroy = method.destroy; + export { luckysheet } \ No newline at end of file diff --git a/src/demoData/sheetFormula.js b/src/demoData/sheetFormula.js index 68e554e62..4ac8e4439 100644 --- a/src/demoData/sheetFormula.js +++ b/src/demoData/sheetFormula.js @@ -6607,7 +6607,7 @@ const sheetFormula = { }], "luckysheet_selection_range": [], "scrollLeft": 0, - "scrollTop": 0, + "scrollTop": 0 } export default sheetFormula \ No newline at end of file diff --git a/src/function/functionImplementation.js b/src/function/functionImplementation.js index e62054cb3..1450b9c4f 100644 --- a/src/function/functionImplementation.js +++ b/src/function/functionImplementation.js @@ -12361,7 +12361,7 @@ const functionImplementation = { var endDate = moment(arguments[1]); var unit = arguments[2]; var result = formula.error.v; - if(luckysheet_function.DAYS.f(endDate,startDate) < 0){ + if(window.luckysheet_function.DAYS.f(endDate,startDate) < 0){ return formula.error.v; } diff --git a/src/function/functionlist.js b/src/function/functionlist.js index 69b050a42..00f2016b7 100644 --- a/src/function/functionlist.js +++ b/src/function/functionlist.js @@ -1,8 +1,8 @@ import functionImplementation from './functionImplementation'; +import Store from '../store/index' //{"0":"数学","1":"统计","2":"查找","3":"Luckysheet内置","4":"数据挖掘","5":"数据源","6":"日期","7":"过滤器","8":"财务","9":"工程计算","10":"逻辑","11":"运算符","12":"文本","13":"转换工具","14":"数组"} -const functionlist = [ - { +const functionlist_zh = [{ 'n': 'SUMIF', 't': 0, 'd': '对范围中符合指定条件的值求和。', @@ -1709,7 +1709,7 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': '数据_y', 'detail': '代表因变量数据数组或矩阵的范围。', 'example': 'A2:A100', @@ -1730,7 +1730,7 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': '数据_y', 'detail': '代表因变量数据数组或矩阵的范围。', 'example': 'B2:B100', @@ -8213,86 +8213,87 @@ const functionlist = [ "a": "生成单元格折线图", "m": [1, 8], "p": [ - //data - { - "name": "数据范围", - "example": 'A1:A20', - "detail": "数据范围,数值才能被有效计算,例如A1:A20, {1,2,3,4,5}等。", - "require": "m", - "repeat": "n", - "type": "rangeall" - }, - //lineColor - { - "name": "线条颜色", - "example": '#2ec7c9', - "detail": "线图的线条颜色,可以是否个范围A1、色表索引数值或者具体颜色值,设置为0或false则不显示,支持regx、rgb、rgba等。默认#2ec7c9", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - // { - // "name": "填充颜色", - // "example": '#CCF3F4', - // "detail": "形成面积图,同线条颜色配置,默认0不显示", - // "require": "o", - // "repeat": "n", - // "type": "rangeall" - // }, - //lineWidth - { - "name": "线条粗细", - "example": '1', - "detail": "折线图线段粗细,默认为1px", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //normalRangeMin和normalRangeMax设为相同的值,min、max、avg、median需要计算 - { - "name": "辅助线", - "example": 'avg', - "detail": "一条横线,可以是min、max、avg、median、范围或自定义数值,默认0无", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //normalRangeColor - { - "name": "辅助线颜色", - "example": '#000', - "detail": "辅助线的颜色设置,同线条颜色配置,默认#000", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //maxSpotColor - { - "name": "最大值标识", - "example": '#fc5c5c', - "detail": "标识线图最大值,同线条颜色配置,默认0不显示", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //minSpotColor - { - "name": "最小值标识", - "example": '#fc5c5c', - "detail": "标识线图最大值,同线条颜色配置,默认0不显示", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //spotRadius - { - "name": "标识大小", - "example": '1.5', - "detail": "最大值和最小值的标识大小设置,默认为1.5", - "require": "o", - "repeat": "n", - "type": "rangeall" - }] + //data + { + "name": "数据范围", + "example": 'A1:A20', + "detail": "数据范围,数值才能被有效计算,例如A1:A20, {1,2,3,4,5}等。", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, + //lineColor + { + "name": "线条颜色", + "example": '#2ec7c9', + "detail": "线图的线条颜色,可以是否个范围A1、色表索引数值或者具体颜色值,设置为0或false则不显示,支持regx、rgb、rgba等。默认#2ec7c9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + // { + // "name": "填充颜色", + // "example": '#CCF3F4', + // "detail": "形成面积图,同线条颜色配置,默认0不显示", + // "require": "o", + // "repeat": "n", + // "type": "rangeall" + // }, + //lineWidth + { + "name": "线条粗细", + "example": '1', + "detail": "折线图线段粗细,默认为1px", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //normalRangeMin和normalRangeMax设为相同的值,min、max、avg、median需要计算 + { + "name": "辅助线", + "example": 'avg', + "detail": "一条横线,可以是min、max、avg、median、范围或自定义数值,默认0无", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //normalRangeColor + { + "name": "辅助线颜色", + "example": '#000', + "detail": "辅助线的颜色设置,同线条颜色配置,默认#000", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //maxSpotColor + { + "name": "最大值标识", + "example": '#fc5c5c', + "detail": "标识线图最大值,同线条颜色配置,默认0不显示", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //minSpotColor + { + "name": "最小值标识", + "example": '#fc5c5c', + "detail": "标识线图最小值,同线条颜色配置,默认0不显示", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //spotRadius + { + "name": "标识大小", + "example": '1.5', + "detail": "最大值和最小值的标识大小设置,默认为1.5", + "require": "o", + "repeat": "n", + "type": "rangeall" + } + ] }, //sparklines面积图 { @@ -8302,87 +8303,87 @@ const functionlist = [ "a": "生成单元格面积图", "m": [1, 5], "p": [ - //data - { - "name": "数据范围", - "example": 'A1:A20', - "detail": "数据范围,数值才能被有效计算,例如A1:A20, {1,2,3,4,5}等。", - "require": "m", - "repeat": "n", - "type": "rangeall" - }, - //lineColor - { - "name": "线条颜色", - "example": '#2ec7c9', - "detail": "线图的线条颜色,可以是否个范围A1、色表索引数值或者具体颜色值,设置为0或false则不显示,支持regx、rgb、rgba等。默认#2ec7c9", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //fillColor - { - "name": "填充颜色", - "example": '#CCF3F4', - "detail": "形成面积图,同线条颜色配置,默认0不显示", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //lineWidth - { - "name": "线条粗细", - "example": '1', - "detail": "折线图线段粗细,默认为1px", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //normalRangeMin和normalRangeMax设为相同的值,min、max、avg、median需要计算 - { - "name": "辅助线", - "example": 'avg', - "detail": "一条横线,可以是min、max、avg、median、范围或自定义数值,默认0无", - "require": "o", - "repeat": "n", - "type": "rangeall" - }, - //normalRangeColor - { - "name": "辅助线颜色", - "example": '#000', - "detail": "辅助线的颜色设置,同线条颜色配置,默认#000", - "require": "o", - "repeat": "n", - "type": "rangeall" - } - // //maxSpotColor - // { - // "name": "最大值标识", - // "example": '#fc5c5c', - // "detail": "标识线图最大值,同线条颜色配置,默认0不显示", - // "require": "o", - // "repeat": "n", - // "type": "rangeall" - // }, - // //minSpotColor - // { - // "name": "最小值标识", - // "example": '#fc5c5c', - // "detail": "标识线图最大值,同线条颜色配置,默认0不显示", - // "require": "o", - // "repeat": "n", - // "type": "rangeall" - // }, - // //spotRadius - // { - // "name": "标识大小", - // "example": '1.5', - // "detail": "最大值和最小值的标识大小设置,默认为1.5", - // "require": "o", - // "repeat": "n", - // "type": "rangeall" - // } + //data + { + "name": "数据范围", + "example": 'A1:A20', + "detail": "数据范围,数值才能被有效计算,例如A1:A20, {1,2,3,4,5}等。", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, + //lineColor + { + "name": "线条颜色", + "example": '#2ec7c9', + "detail": "线图的线条颜色,可以是否个范围A1、色表索引数值或者具体颜色值,设置为0或false则不显示,支持regx、rgb、rgba等。默认#2ec7c9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //fillColor + { + "name": "填充颜色", + "example": '#CCF3F4', + "detail": "形成面积图,同线条颜色配置,默认0不显示", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //lineWidth + { + "name": "线条粗细", + "example": '1', + "detail": "折线图线段粗细,默认为1px", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //normalRangeMin和normalRangeMax设为相同的值,min、max、avg、median需要计算 + { + "name": "辅助线", + "example": 'avg', + "detail": "一条横线,可以是min、max、avg、median、范围或自定义数值,默认0无", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, + //normalRangeColor + { + "name": "辅助线颜色", + "example": '#000', + "detail": "辅助线的颜色设置,同线条颜色配置,默认#000", + "require": "o", + "repeat": "n", + "type": "rangeall" + } + // //maxSpotColor + // { + // "name": "最大值标识", + // "example": '#fc5c5c', + // "detail": "标识线图最大值,同线条颜色配置,默认0不显示", + // "require": "o", + // "repeat": "n", + // "type": "rangeall" + // }, + // //minSpotColor + // { + // "name": "最小值标识", + // "example": '#fc5c5c', + // "detail": "标识线图最大值,同线条颜色配置,默认0不显示", + // "require": "o", + // "repeat": "n", + // "type": "rangeall" + // }, + // //spotRadius + // { + // "name": "标识大小", + // "example": '1.5', + // "detail": "最大值和最小值的标识大小设置,默认为1.5", + // "require": "o", + // "repeat": "n", + // "type": "rangeall" + // } ] }, //sparklines柱状图 @@ -8674,7 +8675,7 @@ const functionlist = [ "n": "TRISTATESPLINES", "t": "3", "d": "生成嵌入在单元格内的三态图sparklines,一般用于描述三种态势的走势例如胜负平", - "a": "生成单元格离散图", + "a": "生成单元格三态图", "m": [1, 6], "p": [ //data @@ -8827,7 +8828,7 @@ const functionlist = [ { "name": "数据点大小", "example": '1.5', - "detail": "目标点和利群点的半径大小设置,默认为1.5", + "detail": "目标点和离群点的半径大小设置,默认为1.5", "require": "o", "repeat": "n", "type": "rangeall" @@ -8904,21 +8905,21 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'sort_index', 'detail': '[可选] - 表示要排序的行或列的数字。(默认row1/col1)', 'example': '1', 'require': 'o', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'sort_order', 'detail': '[可选] - 表示所需排序顺序的数字;1表示升序(默认),-1表示降序。', 'example': '-1', 'require': 'o', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'by_col', 'detail': '[可选] - 表示所需排序方向的逻辑值;按行排序为FALSE()(默认),按列排序为TRUE()。', 'example': 'TRUE()', @@ -8939,14 +8940,14 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'range' - },{ + }, { 'name': 'include', 'detail': '布尔数组,其高度或宽度与数组相同', 'example': '1', 'require': 'm', 'repeat': 'n', 'type': 'range' - },{ + }, { 'name': 'if_empty', 'detail': '[可选] - 如果包含数组中的所有值都为空(filter不返回任何值),则返回的值。', 'example': '""', @@ -8967,14 +8968,14 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'by_col', 'detail': '[可选] - 逻辑值,指示如何比较;按行 = FALSE() 或省略;按列 = TRUE()。', 'example': 'TRUE()', 'require': 'o', 'repeat': 'n', 'type': 'rangeall' - },{ + }, { 'name': 'occurs_once', 'detail': '[可选] - 逻辑值,仅返回唯一值中出现一次 = TRUE();包括所有唯一值 = FALSE() 或省略。', 'example': 'FALSE()', @@ -8995,7 +8996,7 @@ const functionlist = [ 'require': 'o', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'cols', 'detail': '[可选] - 要返回的列数。', 'example': '1', @@ -9016,21 +9017,21 @@ const functionlist = [ 'require': 'm', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'cols', 'detail': '[可选] - 要返回的列数。', 'example': '1', 'require': 'o', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'start', 'detail': '[可选] - 序列中的第一个数字。', 'example': '1', 'require': 'o', 'repeat': 'n', 'type': 'rangenumber' - },{ + }, { 'name': 'step', 'detail': '[可选] - 序列中每个序列值的增量。', 'example': '1', @@ -9038,12 +9039,8848 @@ const functionlist = [ 'repeat': 'n', 'type': 'rangenumber' }] - }, + }, ]; -for(let i = 0; i < functionlist.length; i++){ - let func = functionlist[i]; - func.f = functionImplementation[func.n]; + +const functionlist_en = [{ + "n": "SUMIF", + "t": 0, + "d": "Returns a conditional sum across a range.", + "a": "A conditional sum across a range.", + "m": [2, 3], + "p": [{ + "name": "range", + "detail": "The range which is tested against `criterion`.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "criterion", + "detail": "The pattern or test to apply to `range`.", + "example": "\">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "sum_range", + "detail": "The range to be summed, if different from `range`.", + "example": "B1:B10", + "require": "o", + "repeat": "n", + "type": "range" + }] +}, { + "n": "TAN", + "t": 0, + "d": "Returns the tangent of an angle provided in radians.", + "a": "Tangent of an angle provided in radians.", + "m": [1, 1], + "p": [{ + "name": "angle", + "detail": "The angle to find the tangent of, in radians.", + "example": "45*PI()/180", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TANH", + "t": 0, + "d": "Returns the hyperbolic tangent of any real number.", + "a": "Hyperbolic tangent of any real number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "Any real value to calculate the hyperbolic tangent of.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CEILING", + "t": 0, + "d": "Rounds a number up to the nearest integer multiple of specified significance `factor`.", + "a": "Rounds number up to nearest multiple of a factor.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to round up to the nearest integer multiple of `factor`.", + "example": "23.25", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor", + "detail": "The number to whose multiples `value` will be rounded.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ATAN", + "t": 0, + "d": "Returns the inverse tangent of a value, in radians.", + "a": "Inverse tangent of a value, in radians.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse tangent.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ASINH", + "t": 0, + "d": "Returns the inverse hyperbolic sine of a number.", + "a": "Inverse hyperbolic sine of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse hyperbolic sine.", + "example": "0.9", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ABS", + "t": 0, + "d": "Returns the absolute value of a number.", + "a": "Absolute value of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The number of which to return the absolute value.", + "example": "-2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ACOS", + "t": 0, + "d": "Returns the inverse cosine of a value, in radians.", + "a": "Inverse cosine of a value, in radians.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse cosine. Must be between `-1` and `1`, inclusive.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ACOSH", + "t": 0, + "d": "Returns the inverse hyperbolic cosine of a number.", + "a": "Inverse hyperbolic cosine of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to `1`.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MULTINOMIAL", + "t": 0, + "d": "Returns the factorial of the sum of values divided by the product of the values' factorials.", + "a": "Multinomial distribution function.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "ATANH", + "t": 0, + "d": "Returns the inverse hyperbolic tangent of a number.", + "a": "Inverse hyperbolic tangent of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.", + "example": "0.9", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ATAN2", + "t": 0, + "d": "Returns the angle between the x-axis and a line segment from the origin (0,0) to specified coordinate pair (`x`,`y`), in radians.", + "a": "Arctangent of a value.", + "m": [2, 2], + "p": [{ + "name": "x", + "detail": "The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "y", + "detail": "The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUNTBLANK", + "t": 1, + "d": "Returns the number of empty values in a list of values and ranges.", + "a": "Number of empty values.", + "m": [1, 1], + "p": [{ + "name": "value1", + "detail": "The first value or range in which to count the number of blanks.", + "example": "A2:C100", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "COSH", + "t": 0, + "d": "Returns the hyperbolic cosine of any real number.", + "a": "Hyperbolic cosine of any real number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "Any real value to calculate the hyperbolic cosine of.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "INT", + "t": 0, + "d": "Rounds a number down to the nearest integer that is less than or equal to it.", + "a": "Rounds number down to nearest integer.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to round down to the nearest integer.", + "example": "99.44", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ISEVEN", + "t": 0, + "d": "Checks whether the provided value is even.", + "a": "Whether the provided value is even.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as even.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ISODD", + "t": 0, + "d": "Checks whether the provided value is odd.", + "a": "Whether the provided value is odd.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as odd.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "LCM", + "t": 0, + "d": "Returns the least common multiple of one or more integers.", + "a": "Least common multiple of one or more integers.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range whose factors to consider in a calculation to find the least common multiple.", + "example": "A2:A5", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges whose factors to consider to find the least common multiple.", + "example": "3", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "LN", + "t": 0, + "d": "Returns the logarithm of a number, base e (Euler's number).", + "a": "The logarithm of a number, base e (euler's number).", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the logarithm, base e.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "LOG", + "t": 0, + "d": "Returns the logarithm of a number with respect to a base.", + "a": "The logarithm of a number with respect to a base.", + "m": [1, 2], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the logarithm.", + "example": "128", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "base", + "detail": "The base to use for calculation of the logarithm.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "LOG10", + "t": 0, + "d": "Returns the logarithm of a number, base 10.", + "a": "The logarithm of a number, base 10.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the logarithm, base 10.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MOD", + "t": 0, + "d": "Returns the result of the modulo operator, the remainder after a division operation.", + "a": "Modulo (remainder) operator.", + "m": [2, 2], + "p": [{ + "name": "dividend", + "detail": "The number to be divided to find the remainder.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "divisor", + "detail": "The number to divide by.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MROUND", + "t": 0, + "d": "Rounds one number to the nearest integer multiple of another.", + "a": "Rounds a number to the nearest integer multiple.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The number to round to the nearest integer multiple of another.", + "example": "21", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor", + "detail": "The number to whose multiples `value` will be rounded.", + "example": "14", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ODD", + "t": 0, + "d": "Rounds a number up to the nearest odd integer.", + "a": "Rounds a number up to the nearest odd integer.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to round to the next greatest odd number.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUMSQ", + "t": 0, + "d": "Returns the sum of the squares of a series of numbers and/or cells.", + "a": "Sum of squares.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first number or range whose squares to add together.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional numbers or ranges whose squares to add to the square(s) of `value1`.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "COMBIN", + "t": 0, + "d": "Returns the number of ways to choose some number of objects from a pool of a given size of objects.", + "a": "Number of combinations from a set of objects.", + "m": [2, 2], + "p": [{ + "name": "n", + "detail": "The size of the pool of objects to choose from.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "k", + "detail": "The number of objects to choose.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUM", + "t": 0, + "d": "Returns the sum of a series of numbers and/or cells.", + "a": "Sum of a series of numbers and/or cells.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first number or range to add together.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional numbers or ranges to add to `value1`.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "SUBTOTAL", + "t": 0, + "d": "Returns a subtotal for a vertical range of cells using a specified aggregation function.", + "a": "Subtotal for a range using a specific function.", + "m": [2, 256], + "p": [{ + "name": "function_code", + "detail": "The function to use in subtotal aggregation.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "range1", + "detail": "The first range over which to calculate a subtotal.", + "example": "A2:A5", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "range2", + "detail": "Additional ranges over which to calculate subtotals.", + "example": "B2:B8", + "require": "o", + "repeat": "y", + "type": "range" + }] +}, { + "n": "ASIN", + "t": 0, + "d": "Returns the inverse sine of a value, in radians.", + "a": "Inverse sine of a value, in radians.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse sine. Must be between `-1` and `1`, inclusive.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUNTIF", + "t": 1, + "d": "Returns a conditional count across a range.", + "a": "A conditional count across a range.", + "m": [2, 2], + "p": [{ + "name": "range", + "detail": "The range that is tested against `criterion`.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "criterion", + "detail": "The pattern or test to apply to `range`.", + "example": "\">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "RADIANS", + "t": 0, + "d": "Converts an angle value in degrees to radians.", + "a": "Converts an angle value in degrees to radians.", + "m": [1, 1], + "p": [{ + "name": "angle", + "detail": "The angle to convert from degrees to radians.", + "example": "180", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "RAND", + "t": 0, + "d": "Returns a random number between 0 inclusive and 1 exclusive.", + "a": "A random number between 0 inclusive and 1 exclusive.", + "m": [0, 0], + "p": [] +}, { + "n": "COUNTUNIQUE", + "t": 0, + "d": "Counts the number of unique values in a list of specified values and ranges.", + "a": "Counts number of unique values in a range.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider for uniqueness.", + "example": "A1:C100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider for uniqueness.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DEGREES", + "t": 0, + "d": "Converts an angle value in radians to degrees.", + "a": "Converts an angle value in radians to degrees.", + "m": [1, 1], + "p": [{ + "name": "angle", + "detail": "The angle to convert from radians to degrees.", + "example": "PI()", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ERFC", + "t": 9, + "d": "Returns the complementary Gauss error function of a value.", + "a": "Complementary gauss error function of a value.", + "m": [1, 1], + "p": [{ + "name": "z", + "detail": "The number for which to calculate the complementary Gauss error function.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "EVEN", + "t": 0, + "d": "Rounds a number up to the nearest even integer.", + "a": "Rounds a number up to the nearest even integer.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to round to the next greatest even number.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "EXP", + "t": 0, + "d": "Returns Euler's number, e (~2.718) raised to a power.", + "a": "Euler's number, e (~2.718) raised to a power.", + "m": [1, 1], + "p": [{ + "name": "exponent", + "detail": "The exponent to raise e to.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FACT", + "t": 0, + "d": "Returns the factorial of a number.", + "a": "Factorial of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The number or reference to a number whose factorial will be calculated and returned.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FACTDOUBLE", + "t": 0, + "d": "Returns the \"double factorial\" of a number.", + "a": "\"double factorial\" of a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The number or reference to a number whose double factorial will be calculated and returned.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PI", + "t": 0, + "d": "Returns the value of Pi to 14 decimal places.", + "a": "The number pi.", + "m": [0, 0], + "p": [] +}, { + "n": "FLOOR", + "t": 0, + "d": "Rounds a number down to the nearest integer multiple of specified significance `factor`.", + "a": "Rounds number down to nearest multiple of a factor.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to round down to the nearest integer multiple of `factor`.", + "example": "23.25", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor", + "detail": "The number to whose multiples `value` will be rounded.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "GCD", + "t": 0, + "d": "Returns the greatest common divisor of one or more integers.", + "a": "Greatest common divisor of one or more integers.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range whose factors to consider in a calculation to find the greatest common divisor.", + "example": "A2:A5", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges whose factors to consider to find the greatest common divisor.", + "example": "96", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "RANDBETWEEN", + "t": 0, + "d": "Returns a uniformly random integer between two values, inclusive.", + "a": "Random integer between two values, inclusive.", + "m": [2, 2], + "p": [{ + "name": "low", + "detail": "The low end of the random range.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "high", + "detail": "The high end of the random range.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ROUND", + "t": 0, + "d": "Rounds a number to a certain number of decimal places according to standard rules.", + "a": "Rounds a number according to standard rules.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to round to `places` number of places.", + "example": "99.44", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "places", + "detail": "The number of decimal places to which to round.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ROUNDDOWN", + "t": 0, + "d": "Rounds a number to a certain number of decimal places, always rounding down to the next valid increment.", + "a": "Rounds down a number.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to round to `places` number of places, always rounding down.", + "example": "99.44", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "places", + "detail": "The number of decimal places to which to round.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ROUNDUP", + "t": 0, + "d": "Rounds a number to a certain number of decimal places, always rounding up to the next valid increment.", + "a": "Rounds up a number.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to round to `places` number of places, always rounding up.", + "example": "99.44", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "places", + "detail": "The number of decimal places to which to round.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SERIESSUM", + "t": 0, + "d": "Given parameters `x`, `n`, `m`, and `a`, returns the power series sum a", + "a": "Sum of a power series.", + "m": [4, 4], + "p": [{ + "name": "x", + "detail": "The input to the power series. Varies depending on the type of approximation, may be angle, exponent, or some other value.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "n", + "detail": "The initial power to which to raise `x` in the power series.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "m", + "detail": "The additive increment by which to increase `x`.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "a", + "detail": "The array or range containing the coefficients of the power series.", + "example": "{FACT(0)", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SIGN", + "t": 0, + "d": "Given an input number, returns `-1` if it is negative, `1` if positive, and `0` if it is zero.", + "a": "Sign of a provided number (+/-/0).", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value whose sign will be evaluated.", + "example": "-42", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SIN", + "t": 0, + "d": "Returns the sine of an angle provided in radians.", + "a": "Sine of an angle provided in radians.", + "m": [1, 1], + "p": [{ + "name": "angle", + "detail": "The angle to find the sine of, in radians.", + "example": "PI()", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SINH", + "t": 0, + "d": "Returns the hyperbolic sine of any real number.", + "a": "Hyperbolic sine of any real number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "Any real value to calculate the hyperbolic sine of.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SQRT", + "t": 0, + "d": "Returns the positive square root of a positive number.", + "a": "Positive square root of a positive number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The number for which to calculate the positive square root.", + "example": "9", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SQRTPI", + "t": 0, + "d": "Returns the positive square root of the product of Pi and the given positive number.", + "a": "Square root of the product of pi and number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The number which will be multiplied by Pi and have the product's square root returned", + "example": "9", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "GAMMALN", + "t": 1, + "d": "Returns the logarithm of a specified Gamma function, base e (Euler's number).", + "a": "Logarithm of gamma function.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The input to the Gamma function. The natural logarithm of Gamma(`value`) will be returned.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COS", + "t": 0, + "d": "Returns the cosine of an angle provided in radians.", + "a": "Cosine of an angle provided in radians.", + "m": [1, 1], + "p": [{ + "name": "angle", + "detail": "The angle to find the cosine of, in radians.", + "example": "PI()", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TRUNC", + "t": 0, + "d": "Truncates a number to a certain number of significant digits by omitting less significant digits.", + "a": "Truncates a number.", + "m": [1, 2], + "p": [{ + "name": "value", + "detail": "The value to be truncated.", + "example": "3.141592654", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "places", + "detail": "The number of significant digits to the right of the decimal point to retain.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "QUOTIENT", + "t": 0, + "d": "Returns one number divided by another.", + "a": "One number divided by another.", + "m": [2, 2], + "p": [{ + "name": "dividend", + "detail": "The number to be divided.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "divisor", + "detail": "The number to divide by.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "POWER", + "t": 0, + "d": "Returns a number raised to a power.", + "a": "A number raised to a power.", + "m": [2, 2], + "p": [{ + "name": "base", + "detail": "The number to raise to the `exponent` power.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "exponent", + "detail": "The exponent to raise `base` to.", + "example": "0.5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUMIFS", + "t": 0, + "d": "Returns the sum of a range depending on multiple criteria.", + "a": "Sums a range depending on multiple criteria.", + "m": [3, 257], + "p": [{ + "name": "sum_range", + "detail": "The range to sum.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "criteria_range1", + "detail": "The range to check against criterion1.", + "example": " B1:B10", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "criterion1", + "detail": "The pattern or test to apply to criteria_range1.", + "example": " \">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria_range2", + "detail": "Additional ranges to check.", + "example": " C1:C10", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "COUNTIFS", + "t": 1, + "d": "Returns the count of a range depending on multiple criteria.", + "a": "Count values depending on multiple criteria.", + "m": [2, 256], + "p": [{ + "name": "criteria_range1", + "detail": "The range to check against `criterion1`.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "criterion1", + "detail": "The pattern or test to apply to `criteria_range1`.", + "example": " \">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria_range2", + "detail": "Additional ranges to check.", + "example": " B1:B10", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "PRODUCT", + "t": 0, + "d": "Returns the result of multiplying a series of numbers together.", + "a": "Result of multiplying a series of numbers together.", + "m": [1, 255], + "p": [{ + "name": "factor1", + "detail": "The first number or range to calculate for the product.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor2", + "detail": "More numbers or ranges to calculate for the product.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "HARMEAN", + "t": 1, + "d": "Calculates the harmonic mean of a dataset.", + "a": "The harmonic mean of a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the population.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the population.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "HYPGEOMDIST", + "t": 1, + "d": "Calculates the probability of drawing a certain number of successes in a certain number of tries given a population of a certain size containing a certain number of successes, without replacement of draws.", + "a": "Hypergeometric distribution probability.", + "m": [5, 5], + "p": [{ + "name": "num_successes", + "detail": "The desired number of successes.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "num_draws", + "detail": "The number of permitted draws.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "successes_in_pop", + "detail": "The total number of successes in the population.", + "example": "20", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "pop_size", + "detail": "The total size of the population", + "example": "40", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Determine the logical value of the function form. \n\nIf cumulative is TRUE(), HYPGEOM.DIST returns the cumulative distribution function;\n\nif FALSE(), it returns the probability density function.", + "example": "TRUE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "INTERCEPT", + "t": 1, + "d": "Calculates the y-value at which the line resulting from linear regression of a dataset will intersect the y-axis (x=0).", + "a": "Y-intercept of line derived via linear regression.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "KURT", + "t": 1, + "d": "Calculates the kurtosis of a dataset, which describes the shape, and in particular the \"peakedness\" of that dataset.", + "a": "Kurtosis of a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the dataset.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the dataset.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "LARGE", + "t": 1, + "d": "Returns the nth largest element from a data set, where n is user-defined.", + "a": "Nth largest element from a data set.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "Array or range containing the dataset to consider.", + "example": "A2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "n", + "detail": "The rank from largest to smallest of the element to return.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "STDEVA", + "t": 1, + "d": "Calculates the standard deviation based on a sample, setting text to the value `0`.", + "a": "Standard deviation of sample (text as 0).", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the sample.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the sample.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "STDEVP", + "t": 1, + "d": "Calculates the standard deviation based on an entire population.", + "a": "Standard deviation of an entire population.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the population.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the population.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "GEOMEAN", + "t": 1, + "d": "Calculates the geometric mean of a dataset.", + "a": "The geometric mean of a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the population.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the population.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "RANK_EQ", + "t": 1, + "d": "Returns the rank of a specified value in a dataset. If there is more than one entry of the same value in the dataset, the top rank of the entries will be returned.", + "a": "Top rank of a specified value in a dataset.", + "m": [2, 3], + "p": [{ + "name": "value", + "detail": "The value whose rank will be determined.", + "example": "A10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A1:A100", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "is_ascending", + "detail": "Whether to consider the values in `data` in descending or ascending order. If omitted, the default is descending (FALSE).", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "RANK_AVG", + "t": 1, + "d": "Returns the rank of a specified value in a dataset. If there is more than one entry of the same value in the dataset, the average rank of the entries will be returned.", + "a": "Average rank of a specified value in a dataset.", + "m": [2, 3], + "p": [{ + "name": "value", + "detail": "The value whose rank will be determined.", + "example": "A10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A1:A100", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "is_ascending", + "detail": "Whether to consider the values in `data` in descending or ascending order. If omitted, the default is descending (FALSE).", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "PERCENTRANK_EXC", + "t": 1, + "d": "Returns the percentage rank (percentile) from 0 to 1 exclusive of a specified value in a dataset.", + "a": "Percentage rank (percentile) from 0 to 1 exclusive.", + "m": [2, 3], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A1:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value", + "detail": "The value whose percentage rank will be determined.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "significant_digits", + "detail": "The number of significant figures to use in the calculation. Default is 3.", + "example": "4", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PERCENTRANK_INC", + "t": 1, + "d": "Returns the percentage rank (percentile) from 0 to 1 inclusive of a specified value in a dataset.", + "a": "Percentage rank (percentile) from 0 to 1 inclusive.", + "m": [2, 3], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A1:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value", + "detail": "The value whose percentage rank will be determined.", + "example": " A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "significant_digits", + "detail": "The number of significant figures to use in the calculation. Default is 3.", + "example": "4", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FORECAST", + "t": 1, + "d": "Calculates the expected y-value for a specified x based on a linear regression of a dataset.", + "a": "Expected y-value based of linear regression.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The value on the x-axis to forecast.", + "example": "A1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FISHERINV", + "t": 1, + "d": "Returns the inverse Fisher transformation of a specified value.", + "a": "Inverse fisher transformation of a specified value.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the inverse Fisher transformation.", + "example": "0.962", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FISHER", + "t": 1, + "d": "Returns the Fisher transformation of a specified value.", + "a": "Fisher transformation of a specified value.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value for which to calculate the Fisher transformation.", + "example": "0.962", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MODE_SNGL", + "t": 1, + "d": "Returns the most commonly occurring value in a dataset.", + "a": "Most commonly occurring value in a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating mode.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating mode.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "WEIBULL_DIST", + "t": 1, + "d": "Returns the value of the Weibull distribution function (or Weibull cumulative distribution function) for a specified shape and scale.", + "a": "Weibull distribution function.", + "m": [4, 4], + "p": [{ + "name": "x", + "detail": "The input to the Weibull distribution function.", + "example": "2.4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "shape", + "detail": "The shape parameter of the Weibull distribution function.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "scale", + "detail": "The scale parameter of the Weibull distribution function.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Whether to use the cumulative distribution function.", + "example": "TRUE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "COUNT", + "t": 1, + "d": "Returns the number of numeric values in a dataset.", + "a": "The number of numeric values in dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when counting.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when counting.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "COUNTA", + "t": 1, + "d": "Returns the number of values in a dataset.", + "a": "The number of values in a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when counting.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when counting.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "AVEDEV", + "t": 1, + "d": "Calculates the average of the magnitudes of deviations of data from a dataset's mean.", + "a": "Average magnitude of deviations from mean.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the sample.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the sample.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "AVERAGE", + "t": 1, + "d": "Returns the numerical average value in a dataset, ignoring text.", + "a": "Numerical average value in a dataset, ignoring text.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the average value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the average value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "AVERAGEA", + "t": 1, + "d": "Returns the numerical average value in a dataset.", + "a": "Numerical average value in a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the average value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the average value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "BINOM_DIST", + "t": 1, + "d": "Calculates the probability of drawing a certain number of successes (or a maximum number of successes) in a certain number of tries given a population of a certain size containing a certain number of successes, with replacement of draws.", + "a": "Binomial distribution probability.", + "m": [4, 4], + "p": [{ + "name": "num_successes", + "detail": "The number of successes for which to calculate the probability in `num_trials` trials.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "num_trials", + "detail": "The number of independent trials.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "prob_success", + "detail": "The probability of success in any given trial.", + "example": "0.005", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Whether to use the binomial cumulative distribution.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "BINOM_INV", + "t": 1, + "d": "Calculates the smallest value for which the cumulative binomial distribution is greater than or equal to a specified criteria.", + "a": "Inverse cumulative binomial distribution function.", + "m": [3, 3], + "p": [{ + "name": "num_trials", + "detail": "The number of independent trials.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "prob_success", + "detail": "The probability of success in any given trial.", + "example": "0.005", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "target_prob", + "detail": "The desired threshold probability.", + "example": "0.8", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CONFIDENCE_NORM", + "t": 1, + "d": "Calculates the width of half the confidence interval for a normal distribution.", + "a": "Confidence interval for a normal distribution.", + "m": [3, 3], + "p": [{ + "name": "alpha", + "detail": "One minus the desired confidence level. E.g. `0.1` for `0.9`, or 90%, confidence.", + "example": "0.05", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation of the population.", + "example": "1.6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "pop_size", + "detail": "The size of the population.", + "example": "250", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CORREL", + "t": 1, + "d": "Calculates r, the Pearson product-moment correlation coefficient of a dataset.", + "a": "Pearson Product-Moment Correlation Coefficient.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COVARIANCE_P", + "t": 1, + "d": "Calculates the covariance of a dataset.", + "a": "The covariance of a dataset.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COVARIANCE_S", + "t": 1, + "d": "Calculates the sample covariance of a dataset.", + "a": "The sample covariance of a dataset.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DEVSQ", + "t": 1, + "d": "Calculates the sum of squares of deviations based on a sample.", + "a": "The sum of squares of deviations based on a sample.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the sample.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the sample.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "EXPON_DIST", + "t": 1, + "d": "Returns the value of the exponential distribution function with a specified lambda at a specified value.", + "a": "Exponential distribution function.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the exponential distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "lambda", + "detail": "The lambda to specify the exponential distribution function.", + "example": "0.5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Whether to use the exponential cumulative distribution.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "AVERAGEIF", + "t": 1, + "d": "Returns the average of a range depending on criteria.", + "a": "Average of values depending on criteria.", + "m": [2, 3], + "p": [{ + "name": "criteria_range", + "detail": "The range to check against `criterion`.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criterion", + "detail": "The pattern or test to apply to `criteria_range`.", + "example": "\">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "average_range", + "detail": "The range to average. If not included, `criteria_range` is used for the average instead.", + "example": "B1:B10", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "AVERAGEIFS", + "t": 1, + "d": "Returns the average of a range depending on multiple criteria.", + "a": "Average of values depending on multiple criteria.", + "m": [2, 255], + "p": [{ + "name": "average_range", + "detail": "The range to average.", + "example": "A1:A10", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria_range1", + "detail": "The range to check against `criterion1`.", + "example": " B1:B10", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criterion1", + "detail": "The pattern or test to apply to `criteria_range1`.", + "example": " \">20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria_range2", + "detail": "Additional ranges to check.", + "example": " C1:C10", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "PERMUT", + "t": 1, + "d": "Returns the number of ways to choose some number of objects from a pool of a given size of objects, considering order.", + "a": "Number of permutations from a number of objects.", + "m": [2, 2], + "p": [{ + "name": "n", + "detail": "The size of the pool of objects to choose from.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "k", + "detail": "The number of objects to choose.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TRIMMEAN", + "t": 1, + "d": "Calculates the mean of a dataset excluding some proportion of data from the high and low ends of the dataset.", + "a": "Mean of a dataset excluding high/low ends.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "Array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "exclude_proportion", + "detail": "The proportion of the dataset to exclude, from the extremities of the set.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PERCENTILE_EXC", + "t": 1, + "d": "Returns the value at a given percentile of a dataset exclusive of 0 and 1.", + "a": "Value at a given percentile of a dataset exclusive of 0 and 1.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "percentile", + "detail": "The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.", + "example": "0.25", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PERCENTILE_INC", + "t": 1, + "d": "Returns the value at a given percentile of a dataset.", + "a": "Value at a given percentile of a dataset.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "percentile", + "detail": "The percentile whose value within `data` will be calculated and returned.`", + "example": "0.25", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PEARSON", + "t": 1, + "d": "Calculates r, the Pearson product-moment correlation coefficient of a dataset.", + "a": "Pearson Product-Moment Correlation Coefficient.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NORM_S_INV", + "t": 1, + "d": "Returns the value of the inverse standard normal distribution function for a specified value.", + "a": "Inverse standard normal distribution function.", + "m": [1, 1], + "p": [{ + "name": "x", + "detail": "The input to the inverse standard normal distribution function.", + "example": "0.75", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NORM_S_DIST", + "t": 1, + "d": "Returns the value of the standard normal cumulative distribution function for a specified value.", + "a": "Standard normal cumulative distribution function.", + "m": [2, 2], + "p": [{ + "name": "x", + "detail": "The input to the standard normal cumulative distribution function.", + "example": "2.4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Determine the logical value of the function form. \n\nIf TRUE(), it returns the cumulative distribution function;\n\nIf it is FALSE(), it returns the probability density function.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NORM_INV", + "t": 1, + "d": "Returns the value of the inverse normal distribution function for a specified value, mean, and standard deviation.", + "a": "Inverse normal distribution function.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the inverse normal distribution function.", + "example": "0.75", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean (mu) of the normal distribution function.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation (sigma) of the normal distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NORM_DIST", + "t": 1, + "d": "Returns the value of the normal distribution function (or normal cumulative distribution function) for a specified value, mean, and standard deviation.", + "a": "Normal distribution function.", + "m": [4, 4], + "p": [{ + "name": "x", + "detail": "The input to the normal distribution function.", + "example": "2.4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean (mu) of the normal distribution function.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation (sigma) of the normal distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Whether to use the normal cumulative distribution function rather than the distribution function.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NEGBINOM_DIST", + "t": 1, + "d": "Calculates the probability of drawing a certain number of failures before a certain number of successes given a probability of success in independent trials.", + "a": "Negative binomial distribution probability.", + "m": [4, 4], + "p": [{ + "name": "num_failures", + "detail": "The number of failures to model.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "num_successes", + "detail": "The number of successes to model.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "prob_success", + "detail": "The probability of success in any given trial.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Determine the logical value of the function form. \n\nIf TRUE(), it returns the cumulative distribution function;\n\nIf it is FALSE(), it returns the probability density function.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "MINA", + "t": 1, + "d": "Returns the minimum numeric value in a dataset.", + "a": "Minimum numeric value in a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the minimum value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the minimum value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "MIN", + "t": 1, + "d": "Returns the minimum value in a numeric dataset.", + "a": "Minimum value in a numeric dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the minimum value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the minimum value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "MEDIAN", + "t": 1, + "d": "Returns the median value in a numeric dataset.", + "a": "Median value in a numeric dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the median value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the median value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "MAXA", + "t": 1, + "d": "Returns the maximum numeric value in a dataset.", + "a": "Maximum numeric value in a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the maximum value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the maximum value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "MAX", + "t": 1, + "d": "Returns the maximum value in a numeric dataset.", + "a": "Maximum value in a numeric dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range to consider when calculating the maximum value.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to consider when calculating the maximum value.", + "example": "B2:B100", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "LOGNORM_INV", + "t": 1, + "d": "Returns the value of the inverse log-normal cumulative distribution with given mean and standard deviation at a specified value.", + "a": "Inverse log-normal cumulative distribution function.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the inverse log-normal cumulative distribution function.", + "example": "0.4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean (mu) of the inverse log-normal cumulative distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation (sigma) of the inverse log-normal cumulative distribution function.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "LOGNORM_DIST", + "t": 1, + "d": "Returns the value of the log-normal cumulative distribution with given mean and standard deviation at a specified value.", + "a": "Log-normal cumulative distribution probability.", + "m": [4, 4], + "p": [{ + "name": "x", + "detail": "The input to the log-normal cumulative distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean (mu) of the log-normal cumulative distribution function.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation (sigma) of the log-normal cumulative distribution function.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Determine the logical value of the function form. \n\nIf TRUE(), it returns the cumulative distribution function;\n\nIf it is FALSE(), it returns the probability density function.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "Z_TEST", + "t": 1, + "d": "Returns the one-tailed p-value of a Z-test with standard distribution.", + "a": "One-tailed p-value of a z-test.", + "m": [2, 3], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "value", + "detail": "The test statistic to use in the Z-test.", + "example": "B2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation to assume for the Z-test. If this is not provided, the standard deviation of the data will be used.", + "example": "3", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PROB", + "t": 1, + "d": "Given a set of values and corresponding probabilities, calculates the probability that a value chosen at random falls between two limits.", + "a": "Probability values lie in a range.", + "m": [3, 4], + "p": [{ + "name": "data", + "detail": "Array or range containing the dataset to consider.", + "example": "A3:A6", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "probabilities", + "detail": "Array or range containing probabilities corresponding to `data`.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "low_limit", + "detail": "The lower bound on the value range for which to calculate the probability.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "high_limit", + "detail": "The upper bound on the value range for which to calculate the probability.", + "example": "4", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "QUARTILE_EXC", + "t": 1, + "d": "Returns a value nearest to a specified quartile of a dataset exclusive of 0 and 4.", + "a": "Value nearest to a specific quartile of a dataset exclusive of 0 and 4.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "quartile_number", + "detail": "Which quartile to return.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "QUARTILE_INC", + "t": 1, + "d": "Returns a value nearest to a specified quartile of a dataset.", + "a": "Value nearest to a specific quartile of a dataset.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "quartile_number", + "detail": "Which quartile value to return.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "POISSON_DIST", + "t": 1, + "d": "Returns the value of the Poisson distribution function (or Poisson cumulative distribution function) for a specified value and mean.", + "a": "Poisson distribution function.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the Poisson distribution function.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean (mu) of the Poisson distribution function.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Whether to use the Poisson cumulative distribution function rather than the distribution function.", + "example": "FALSE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "RSQ", + "t": 1, + "d": "Calculates the square of r, the Pearson product-moment correlation coefficient of a dataset.", + "a": "Square of the correlation coefficient.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "T_DIST", + "t": 1, + "d": "Calculates the left tail probability for a Student's t-distribution with a given input (x).", + "a": "The left-tailed Student's t-distribution", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the t-distribution function.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom", + "detail": "The number of degrees of freedom.", + "example": "30", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "If cumulative is TRUE, T.DIST returns the cumulative distribution function; if FALSE, it returns the probability density function.", + "example": "TRUE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "T_DIST_2T", + "t": 1, + "d": "Calculates the probability for two tailed Student's t-distribution with a given input (x).", + "a": "The two tailed Student's t-distribution", + "m": [2, 2], + "p": [{ + "name": "x", + "detail": "The input to the t-distribution function.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom", + "detail": "The number of degrees of freedom.", + "example": "30", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "T_DIST_RT", + "t": 1, + "d": "Calculates the right tail probability for a Student's t-distribution with a given input (x).", + "a": "The right-tailed Student's t-distribution", + "m": [2, 2], + "p": [{ + "name": "x", + "detail": "The input to the t-distribution function.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom", + "detail": "The number of degrees of freedom.", + "example": "30", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "T_INV", + "t": 1, + "d": "Calculates the negative inverse of the one-tailed TDIST function.", + "a": "T.INV", + "m": [2, 2], + "p": [{ + "name": "probability", + "detail": "The probability associated with the two-tailed t-distribution.", + "example": "0.35", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom", + "detail": "The number of degrees of freedom.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "T_INV_2T", + "t": 1, + "d": "Calculates the inverse of the two-tailed TDIST function.", + "a": "T.INV.2T", + "m": [2, 2], + "p": [{ + "name": "probability", + "detail": "The probability associated with the two-tailed t-distribution.", + "example": "0.35", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom", + "detail": "The number of degrees of freedom.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "T_TEST", + "t": 1, + "d": "t-test. Returns the probability associated with Student's t-test. Determines whether two samples are likely to have come from the same two underlying populations that have the same mean.", + "a": "Returns the probability associated with t-test.", + "m": [4, 4], + "p": [{ + "name": "range1", + "detail": "The first sample of data or group of cells to consider for the t-test.", + "example": "A1:A4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "range2", + "detail": "The second sample of data or group of cells to consider for the t-test.", + "example": "B1:B4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "tails", + "detail": "Specifies the number of distribution tails.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "type", + "detail": "Specifies the type of t-test.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "F_DIST", + "t": 1, + "d": "Calculates the left-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.", + "a": "F probability distribution (left-tailed).", + "m": [4, 4], + "p": [{ + "name": "x", + "detail": "The input to the F probability distribution function. The value at which to evaluate the function.", + "example": "15.35", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom1", + "detail": "The numerator of the number of degrees of freedom.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom2", + "detail": "The denominator of the number of degrees of freedom.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cumulative", + "detail": "Logical value that determines the form of the function.", + "example": "TRUE()", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "F_DIST_RT", + "t": 1, + "d": "Calculates the right-tailed F probability distribution (degree of diversity) for two data sets with given input x. Alternately called Fisher-Snedecor distribution or Snedecor's F distribution.", + "a": "F probability distribution.", + "m": [3, 3], + "p": [{ + "name": "x", + "detail": "The input to the F probability distribution function. The value at which to evaluate the function.", + "example": "15.35", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom1", + "detail": "The numerator of the number of degrees of freedom.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "degrees_freedom2", + "detail": "The denominator of the number of degrees of freedom.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "VAR_P", + "t": 1, + "d": "Calculates the variance based on an entire population.", + "a": "Variance of entire population.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the population.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the population.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "VAR_S", + "t": 1, + "d": "Calculates the variance based on a sample.", + "a": "Variance.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the sample.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the sample.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "VARA", + "t": 1, + "d": "Calculates the variance based on a sample, setting text to the value `0`.", + "a": "Variance of sample (text as 0).", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the sample.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the sample.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "VARPA", + "t": 1, + "d": "Calculates the variance based on an entire population, setting text to the value `0`.", + "a": "Variance of entire population (text as 0).", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the population.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the population.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "STEYX", + "t": 1, + "d": "Calculates the standard error of the predicted y-value for each x in the regression of a dataset.", + "a": "Standard error of predicted y-values in regression.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "STANDARDIZE", + "t": 1, + "d": "Calculates the normalized equivalent of a random variable given mean and standard deviation of the distribution.", + "a": "Normalized equivalent of a random variable.", + "m": [3, 3], + "p": [{ + "name": "value", + "detail": "The value of the random variable to normalize.", + "example": "96", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "mean", + "detail": "The mean of the distribution.", + "example": "80", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "standard_deviation", + "detail": "The standard deviation of the distribution.", + "example": "6.7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SMALL", + "t": 1, + "d": "Returns the nth smallest element from a data set, where n is user-defined.", + "a": "Nth smallest element in a data set.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the dataset to consider.", + "example": "A2:B100", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "n", + "detail": "The rank from smallest to largest of the element to return.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SLOPE", + "t": 1, + "d": "Calculates the slope of the line resulting from linear regression of a dataset.", + "a": "Slope of line from linear regression of data.", + "m": [2, 2], + "p": [{ + "name": "data_y", + "detail": "The range representing the array or matrix of dependent data.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "data_x", + "detail": "The range representing the array or matrix of independent data.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SKEW", + "t": 1, + "d": "Calculates the skewness of a dataset, which describes the symmetry of that dataset about the mean.", + "a": "Skewness of a dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the dataset.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the dataset.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "SKEW_P", + "t": 1, + "d": "Calculates the skewness of a dataset, which describes the symmetry of that dataset about the mean. This assumes the dataset is for the population.", + "a": "Skewness of a population's dataset.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first value or range of the dataset.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional values or ranges to include in the dataset.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "VLOOKUP", + "t": 2, + "d": "Vertical lookup. Searches down the first column of a range for a key and returns the value of a specified cell in the row found.", + "a": "Vertical lookup.", + "m": [3, 4], + "p": [{ + "name": "search_key", + "detail": "The value to search for. For example, `42`, `\"Cats\"`, or `I24`.", + "example": "10003", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "range", + "detail": "The range to consider for the search. The first column in the range is searched for the key specified in `search_key`.", + "example": "A2:B26", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "index", + "detail": "The column index of the value to be returned, where the first column in `range` is numbered 1.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "is_sorted", + "detail": "Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for `search_key` will be returned.", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "HLOOKUP", + "t": 2, + "d": "Horizontal lookup. Searches across the first row of a range for a key and returns the value of a specified cell in the column found.", + "a": "Horizontal lookup", + "m": [3, 4], + "p": [{ + "name": "search_key", + "detail": "The value to search for. For example, `42`, `\"Cats\"`, or `I24`.", + "example": "10003", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "range", + "detail": "The range to consider for the search. The first row in the range is searched for the key specified in `search_key`.", + "example": "A2:Z6", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "index", + "detail": "The row index of the value to be returned, where the first row in `range` is numbered 1.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "is_sorted", + "detail": "Indicates whether the row to be searched (the first row of the specified range) is sorted.", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LOOKUP", + "t": 2, + "d": "Looks through a sorted row or column for a key and returns the value of the cell in a result range located in the same position as the search row or column.", + "a": "Look up a value.", + "m": [2, 3], + "p": [{ + "name": "search_key", + "detail": "The value to search for in the row or column. For example, `42`, `\"Cats\"`, or `I24`.", + "example": "10003", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "search_range|search_result_array", + "detail": "One method of using this function is to provide a single sorted row or column `search_range` to look through for the `search_key` with a second argument `result_range`. The other way is to combine these two arguments into one `search_result_array` where the first row or column is searched and a value is returned from the last row or column in the array. If `search_key` is not found, a non-exact match may be returned.", + "example": "A1:A100", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "result_range", + "detail": "The range from which to return a result. The value returned corresponds to the location where `search_key` is found in `search_range`. This range must be only a single row or column and should not be used if using the `search_result_array` method.", + "example": "B1:B100", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ADDRESS", + "t": 2, + "d": "Returns a cell reference as a string.", + "a": "Cell reference as a string.", + "m": [2, 5], + "p": [{ + "name": "row", + "detail": "The row number of the cell reference", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "column", + "detail": "The column number (not name) of the cell reference. `A` is column number `1`.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "absolute_relative_mode", + "detail": "An indicator of whether the reference is row/column absolute. `1` is row and column absolute (e.g. $A$1), `2` is row absolute and column relative (e.g. A$1), `3` is row relative and column absolute (e.g. $A1), and `4` is row and column relative (e.g. A1).", + "example": "4", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "use_a1_notation", + "detail": "A boolean indicating whether to use `A1` style notation (TRUE) or `R1C1` style notation (FALSE).", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "sheet", + "detail": "Text indicating the name of the sheet into which the address points.", + "example": "\"Sheet2\"", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "INDIRECT", + "t": 2, + "d": "Returns a cell reference specified by a string.", + "a": "A cell reference specified by a string.", + "m": [1, 2], + "p": [{ + "name": "cell_reference_as_string", + "detail": "A cell reference, written as a string with surrounding quotation marks.", + "example": "\"Sheet2!\"&B10", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "is_A1_notation", + "detail": "Indicates if the cell reference is in A1 notation (TRUE) or R1C1 notation (FALSE).", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ROW", + "t": 2, + "d": "Returns the row number of a specified cell.", + "a": "Row number of a specified cell.", + "m": [0, 1], + "p": [{ + "name": "cell_reference", + "detail": "The cell whose row number will be returned.", + "example": "A9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ROWS", + "t": 2, + "d": "Returns the number of rows in a specified array or range.", + "a": "Number of rows in a specified array or range.", + "m": [1, 1], + "p": [{ + "name": "range", + "detail": "The range whose row count will be returned.", + "example": "A9:A62", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COLUMN", + "t": 2, + "d": "Returns the column number of a specified cell, with `A=1`.", + "a": "Column number of a specified cell.", + "m": [0, 1], + "p": [{ + "name": "cell_reference", + "detail": "The cell whose column number will be returned. Column `A` corresponds to `1`.", + "example": "A9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "COLUMNS", + "t": 2, + "d": "Returns the number of columns in a specified array or range.", + "a": "Number of columns in a specified array or range.", + "m": [1, 1], + "p": [{ + "name": "range", + "detail": "The range whose column count will be returned.", + "example": "A9:W62", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "OFFSET", + "t": 2, + "d": "Returns a range reference shifted a specified number of rows and columns from a starting cell reference.", + "a": "A range reference offset relative to a cell.", + "m": [3, 5], + "p": [{ + "name": "cell_reference", + "detail": "The starting point from which to count the offset rows and columns.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "offset_rows", + "detail": "The number of rows to offset by.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "offset_columns", + "detail": "The number of columns to offset by.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "height", + "detail": "The height of the range to return starting at the offset target.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "width", + "detail": "The width of the range to return starting at the offset target.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MATCH", + "t": 2, + "d": "Returns the relative position of an item in a range that matches a specified value.", + "a": "Position of item in range that matches value.", + "m": [2, 3], + "p": [{ + "name": "search_key", + "detail": "The value to search for. For example, `42`, `\"Cats\"`, or `I24`.", + "example": "\"Sunday\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "range", + "detail": "The one-dimensional array to be searched.", + "example": "A2:A9", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "search_type", + "detail": "The search method. `1` (default) finds the largest value less than or equal to `search_key` when `range` is sorted in ascending order. `0` finds the exact value when `range` is unsorted. `-1` finds the smallest value greater than or equal to `search_key` when `range` is sorted in descending order.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "INDEX", + "t": 2, + "d": "Returns the content of a cell, specified by row and column offset.", + "a": "Content of cell specified by row and column offset.", + "m": [3, 3], + "p": [{ + "name": "reference", + "detail": "The array of cells to be offset into.", + "example": "A1:C20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "row", + "detail": "The number of offset rows.", + "example": "5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "column", + "detail": "The number of offset columns.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "GETPIVOTDATA", + "t": 2, + "d": "Extracts an aggregated value from a pivot table that corresponds to the specified row and column headings.", + "a": "Extracts an aggregated value from a pivot table that corresponds to the specified row and column headings.", + "m": [2, 254], + "p": [{ + "name": "value_name", + "detail": "The name of the value in the pivot table for which you want to get data.", + "example": "\"SUM of number of units\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "any_pivot_table_cell", + "detail": "Any reference to a cell in the desired pivot table (top corner recommended).", + "example": "'Pivot table'!A1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "original_column", + "detail": "The name of the column in the original data set (not the pivot table).", + "example": "\"division\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }, { + "name": "pivot_item", + "detail": "The name of the row or column shown in the pivot table corresponding to *original_column* that you want to retrieve.", + "example": "\"east\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "CHOOSE", + "t": 2, + "d": "Returns an element from a list of choices based on index.", + "a": "An element from a list of choices based on index.", + "m": [2, 255], + "p": [{ + "name": "index", + "detail": "Which choice (of the up to 30 provided) to return.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "choice1", + "detail": "A potential value to return. Required. May be a reference to a cell or an individual value.", + "example": "\"A\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "choice2", + "detail": "Additional values among which to choose.", + "example": "\"B\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "HYPERLINK", + "t": 2, + "d": "Creates a hyperlink inside a cell.", + "a": "Creates a hyperlink inside a cell.", + "p": [{ + "name": "url", + "detail": "The full URL of the link location enclosed in quotation marks, or a reference to a cell containing such a URL.", + "example": "\"http://www.luckysheet.com/\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "link_label", + "detail": "The text to display in the cell as the link, enclosed in quotation marks, or a reference to a cell containing such a label.", + "example": "\"luckysheet\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TIME", + "t": 6, + "d": "Converts a provided hour, minute, and second into a time.", + "a": "Converts hour/minute/second into a time.", + "m": [3, 3], + "p": [{ + "name": "hour", + "detail": "The hour component of the time.", + "example": "11", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "minute", + "detail": "The minute component of the time.", + "example": "40", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "second", + "detail": "The second component of the time.", + "example": "59", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TIMEVALUE", + "t": 6, + "d": "Returns the fraction of a 24-hour day the time represents.", + "a": "Converts a time string into its serial number representation.", + "m": [1, 1], + "p": [{ + "name": "time_string", + "detail": "The string that holds the time representation.", + "example": "\"2:15 PM\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "EOMONTH", + "t": 6, + "d": "Returns a date on the last day of a month that falls a specified number of months before or after another date.", + "a": "Last day of a month before or after a date.", + "m": [2, 2], + "p": [{ + "name": "start_date", + "detail": "The date from which to calculate the result.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "months", + "detail": "The number of months before (negative) or after (positive) 'start_date' to consider.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "EDATE", + "t": 6, + "d": "Returns a date a specified number of months before or after another date.", + "a": "Date a number of months before/after another date.", + "m": [2, 2], + "p": [{ + "name": "start_date", + "detail": "The date from which to calculate the result.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "months", + "detail": "The number of months before (negative) or after (positive) 'start_date' to calculate.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SECOND", + "t": 6, + "d": "Returns the second component of a specific time, in numeric format.", + "a": "Second component of a specific time.", + "m": [1, 1], + "p": [{ + "name": "time", + "detail": "The time from which to calculate the second component", + "example": "TIME(11", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "MINUTE", + "t": 6, + "d": "Returns the minute component of a specific time, in numeric format.", + "a": "Minute component of a specific time.", + "m": [1, 1], + "p": [{ + "name": "time", + "detail": "The time from which to calculate the minute component.", + "example": "TIME(11", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "HOUR", + "t": 6, + "d": "Returns the hour component of a specific time, in numeric format.", + "a": "Hour component of a specific time.", + "m": [1, 1], + "p": [{ + "name": "time", + "detail": "The time from which to calculate the hour component.", + "example": "TIME(11", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NOW", + "t": 6, + "d": "Returns the current date and time as a date value.", + "a": "Current date and time as a date value.", + "m": [0, 0], + "p": [] +}, { + "n": "NETWORKDAYS", + "t": 6, + "d": "Returns the number of net working days between two provided days.", + "a": "Net working days between two provided days.", + "m": [2, 3], + "p": [{ + "name": "start_date", + "detail": "The start date of the period from which to calculate the number of net working days.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_date", + "detail": "The end date of the period from which to calculate the number of net working days.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "holidays", + "detail": "A range or array constant containing the date serial numbers to consider holidays.", + "example": "16)", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NETWORKDAYS_INTL", + "t": 6, + "d": "Returns the number of net working days between two provided days excluding specified weekend days and holidays.", + "a": "Net working days between two dates (specifying weekends).", + "m": [2, 4], + "p": [{ + "name": "start_date", + "detail": "The start date of the period from which to calculate the number of net working days.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_date", + "detail": "The end date of the period from which to calculate the number of net working days.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "weekend", + "detail": "A number or string representing which days of the week are considered weekends.", + "example": "16)", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "holidays", + "detail": "A range or array constant containing the dates to consider as holidays.", + "example": "DATE(1969", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISOWEEKNUM", + "t": 6, + "d": "Returns a number representing the ISO week of the year where the provided date falls.", + "a": "ISO week number of the year.", + "m": [1, 1], + "p": [{ + "name": "date", + "detail": "The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "WEEKNUM", + "t": 6, + "d": "Returns a number representing the week of the year where the provided date falls.", + "a": "Week number of the year.", + "m": [1, 2], + "p": [{ + "name": "date", + "detail": "The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "type", + "detail": "A number representing the day that a week starts on. Sunday = 1.", + "example": "7", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "WEEKDAY", + "t": 6, + "d": "Returns a number representing the day of the week of the date provided.", + "a": "Day of the week of the date provided (as number).", + "m": [1, 2], + "p": [{ + "name": "date", + "detail": "The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "type", + "detail": "A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.", + "example": "7", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DAY", + "t": 6, + "d": "Returns the day of the month that a specific date falls on, in numeric format.", + "a": "Day of the month that a specific date falls on.", + "m": [1, 1], + "p": [{ + "name": "date", + "detail": "The date from which to extract the day.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DAYS", + "t": 6, + "d": "Returns the number of days between two dates.", + "a": "Number of days between two dates.", + "m": [2, 2], + "p": [{ + "name": "end_date", + "detail": "The end of the date range.", + "example": "2011-3-15", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "start_date", + "detail": "The start of the date range.", + "example": "2011-2-1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DAYS360", + "t": 6, + "d": "Returns the difference between two days based on the 360 day year used in some financial interest calculations.", + "a": "Days between two dates on a 360-day year.", + "m": [2, 3], + "p": [{ + "name": "start_date", + "detail": "The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_date", + "detail": "The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "method", + "detail": "An indicator of what day count method to use.", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DATE", + "t": 6, + "d": "Converts a provided year, month, and day into a date.", + "a": "Converts year/month/day into a date.", + "m": [3, 3], + "p": [{ + "name": "year", + "detail": "The year component of the date.", + "example": "1969", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "month", + "detail": "The month component of the date.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day", + "detail": "The day component of the date.", + "example": "20", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATEVALUE", + "t": 6, + "d": "Converts a provided date string in a known format to a date value.", + "a": "Converts a date string to a date value.", + "m": [1, 1], + "p": [{ + "name": "date_string", + "detail": "The string representing the date.", + "example": "\"1969-7-20\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DATEDIF", + "t": 6, + "d": "Calculates the number of days, months, or years between two dates.", + "a": "Date Difference.", + "m": [3, 3], + "p": [{ + "name": "start_date", + "detail": "The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_date", + "detail": "The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "unit", + "detail": "A string abbreviation for unit of time. For example, \"M\" for month. Accepted values are \"Y\",\"M\",\"D\",\"MD\",\"YM\",\"YD\".", + "example": "16)", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "WORKDAY", + "t": 6, + "d": "Calculates the date after a number of working days from a specified start date.", + "a": "Number of working days from start date.", + "m": [2, 3], + "p": [{ + "name": "start_date", + "detail": "The date from which to begin counting.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "num_days", + "detail": "The number of working days to advance from `start_date`. If negative, counts backwards.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "holidays", + "detail": "A range or array constant containing the dates to consider holidays.", + "example": "16)", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "WORKDAY_INTL", + "t": 6, + "d": "Calculates the date after a specified number of workdays excluding specified weekend days and holidays.", + "a": "Date after a number of workdays (specifying weekends).", + "m": [2, 4], + "p": [{ + "name": "start_date", + "detail": "The date from which to begin counting.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "num_days", + "detail": "The number of working days to advance from `start_date`. If negative, counts backwards.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "weekend", + "detail": "A number or string representing which days of the week are considered weekends.", + "example": "16)", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "holidays", + "detail": "A range or array constant containing the dates to consider holidays.", + "example": "DATE(1969", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "YEAR", + "t": 6, + "d": "Returns the year specified by a given date.", + "a": "Year specified by a given date.", + "m": [1, 1], + "p": [{ + "name": "date", + "detail": "The date from which to extract the year.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "YEARFRAC", + "t": 6, + "d": "Returns the number of years, including fractional years, between two dates using a specified day count convention.", + "a": "Exact number of years between two dates.", + "m": [2, 3], + "p": [{ + "name": "start_date", + "detail": "The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_date", + "detail": "The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.", + "example": "7", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "16)", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TODAY", + "t": 6, + "d": "Returns the current date as a date value.", + "a": "Current date as a date value.", + "m": [0, 0], + "p": [] +}, { + "n": "MONTH", + "t": 6, + "d": "Returns the month of the year a specific date falls in, in numeric format.", + "a": "Month of the year a specific date falls in.", + "m": [1, 1], + "p": [{ + "name": "date", + "detail": "The date from which to extract the month.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "EFFECT", + "t": 8, + "d": "Calculates the annual effective interest rate given the nominal rate and number of compounding periods per year.", + "a": "Annual effective interest rate.", + "m": [2, 2], + "p": [{ + "name": "nominal_rate", + "detail": "The nominal interest rate per year.", + "example": "0.99", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "periods_per_year", + "detail": "The number of compounding periods per year.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DOLLAR", + "t": 12, + "d": "Formats a number into the currency specific to your spreadsheet locale.", + "a": "Formats a number as currency specific to your spreadsheet locale.", + "m": [1, 2], + "p": [{ + "name": "number", + "detail": "The value to be formatted.", + "example": "1.2351", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_places", + "detail": "The number of decimal places to display.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DOLLARDE", + "t": 8, + "d": "Converts a price quotation given as a decimal fraction into a decimal value.", + "a": "Converts a decimal fraction to decimal value.", + "m": [2, 2], + "p": [{ + "name": "fractional_price", + "detail": "The price quotation given using fractional decimal conventions.", + "example": "100.10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "unit", + "detail": "The units of the fraction, e.g. `8` for 1/8ths or `32` for 1/32nds.", + "example": "32", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DOLLARFR", + "t": 8, + "d": "Converts a price quotation given as a decimal value into a decimal fraction.", + "a": "Converts a decimal value to decimal fraction.", + "m": [2, 2], + "p": [{ + "name": "decimal_price", + "detail": "The price quotation given as a decimal value.", + "example": "100.125", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "unit", + "detail": "The units of the desired fraction, e.g. `8` for 1/8ths or `32` for 1/32nds.", + "example": "32", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DB", + "t": 8, + "d": "Calculates the depreciation of an asset for a specified period using the arithmetic declining balance method.", + "a": "Depreciation via declining balance method.", + "m": [4, 5], + "p": [{ + "name": "cost", + "detail": "The initial cost of the asset.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "salvage", + "detail": "The value of the asset at the end of depreciation.", + "example": "50", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "life", + "detail": "The number of periods over which the asset is depreciated.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "period", + "detail": "The single period within `life` for which to calculate depreciation.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "month", + "detail": "The number of months in the first year of depreciation.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DDB", + "t": 8, + "d": "Calculates the depreciation of an asset for a specified period using the double-declining balance method.", + "a": "Depreciation via double-declining balance method.", + "m": [4, 5], + "p": [{ + "name": "cost", + "detail": "The initial cost of the asset.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "salvage", + "detail": "The value of the asset at the end of depreciation.", + "example": "50", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "life", + "detail": "The number of periods over which the asset is depreciated.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "period", + "detail": "The single period within `life` for which to calculate depreciation.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor", + "detail": "The factor by which depreciation decreases.", + "example": "2.25", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "RATE", + "t": 8, + "d": "Calculates the interest rate of an annuity investment based on constant-amount periodic payments and the assumption of a constant interest rate.", + "a": "Interest rate of an annuity investment.", + "m": [3, 6], + "p": [{ + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "payment_per_period", + "detail": "The amount per period to be paid.", + "example": "-100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "400", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "rate_guess", + "detail": "An estimate for what the interest rate will be.", + "example": "0.1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CUMPRINC", + "t": 8, + "d": "Calculates the cumulative principal paid over a range of payment periods for an investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Cumulative principal paid over a set of periods.", + "m": [6, 6], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "first_period", + "detail": "The number of the payment period to begin the cumulative calculation.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "last_period", + "detail": "The number of the payment period to end the cumulative calculation.", + "example": "5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPNUM", + "t": 8, + "d": "Calculates the number of coupons, or interest payments, between the settlement date and the maturity date of the investment.", + "a": "Number of coupons between settlement and maturity.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "02", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SYD", + "t": 8, + "d": "Calculates the depreciation of an asset for a specified period using the sum of years digits method.", + "a": "Depreciation via sum of years digits method.", + "m": [4, 4], + "p": [{ + "name": "cost", + "detail": "The initial cost of the asset.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "salvage", + "detail": "The value of the asset at the end of depreciation.", + "example": "50", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "life", + "detail": "The number of periods over which the asset is depreciated.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "period", + "detail": "The single period within `life` for which to calculate depreciation.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TBILLEQ", + "t": 8, + "d": "Calculates the equivalent annualized rate of return of a US Treasury Bill based on discount rate.", + "a": "Equivalent rate of return for a Treasury bill.", + "m": [3, 3], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "discount", + "detail": "The discount rate of the bill at time of purchase.", + "example": "2)", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TBILLYIELD", + "t": 8, + "d": "Calculates the yield of a US Treasury Bill based on price.", + "a": "The yield of a us treasury bill based on price.", + "m": [3, 3], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "price", + "detail": "The price at which the security is bought per 100 face value.", + "example": "95", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TBILLPRICE", + "t": 8, + "d": "Calculates the price of a US Treasury Bill based on discount rate.", + "a": "Price of US treasury bill.", + "m": [3, 3], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "discount", + "detail": "The discount rate of the bill at time of purchase.", + "example": "0.09", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PV", + "t": 8, + "d": "Calculates the present value of an annuity investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Present value of an annuity investment.", + "m": [3, 5], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "payment_amount", + "detail": "The amount per period to be paid.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "D2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ACCRINT", + "t": 8, + "d": "Calculates the accrued interest of a security that has periodic payments.", + "a": "Accrued interest of security with periodic payments.", + "m": [6, 8], + "p": [{ + "name": "issue", + "detail": "The date the security was initially issued.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "first_payment", + "detail": "The first date interest will be paid.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "10000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "calc_method", + "detail": "[Optional-defaults to TRUE()] - A logical value that specifies the method used to calculate the total accrued interest when the settlement date is later than the first interest accrual date. \n\nIf the value is TRUE, the total accrued interest from the issue date to the settlement date is returned. \n\nIf the value is FALSE, return the accrued interest from the first interest accrual date to the settlement date.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ACCRINTM", + "t": 8, + "d": "Calculates the accrued interest of a security that pays interest at maturity.", + "a": "Accrued interest of security paying at maturity.", + "m": [4, 5], + "p": [{ + "name": "issue", + "detail": "The date the security was initially issued.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity date of the security.", + "example": "DATE(1969", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "1000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPDAYBS", + "t": 8, + "d": "Calculates the number of days from the first coupon, or interest payment, until settlement.", + "a": "Number of days from first coupon to settlement.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPDAYS", + "t": 8, + "d": "Calculates the number of days in the coupon, or interest payment, period that contains the specified settlement date.", + "a": "Days in coupon period containing settlement date.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPDAYSNC", + "t": 8, + "d": "Calculates the number of days from the settlement date until the next coupon, or interest payment.", + "a": "Days from settlement until next coupon.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPNCD", + "t": 8, + "d": "Calculates next coupon, or interest payment, date after the settlement date.", + "a": "Next coupon date after the settlement date.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "01)", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "DATE(2019", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COUPPCD", + "t": 8, + "d": "Calculates last coupon, or interest payment, date before the settlement date.", + "a": "Last coupon date before settlement date.", + "m": [3, 4], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "01)", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "DATE(2019", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FV", + "t": 8, + "d": "Calculates the future value of an annuity investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Future value of an annuity investment.", + "m": [3, 5], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "payment_amount", + "detail": "The amount per period to be paid.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "400", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FVSCHEDULE", + "t": 8, + "d": "Calculates the future value of some principal based on a specified series of potentially varying interest rates.", + "a": "Future value of principal from series of rates.", + "m": [2, 2], + "p": [{ + "name": "principal", + "detail": "The amount of initial capital or value to compound against.", + "example": "10000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "rate_schedule", + "detail": "A series of interest rates to compound against the `principal`.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "YIELD", + "t": 8, + "d": "Calculates the annual yield of a security paying periodic interest, such as a US Treasury Bond, based on price.", + "a": "Annual yield of a security paying periodic interest.", + "m": [6, 7], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.057", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "price", + "detail": "The price at which the security is bought per 100 face value.", + "example": "95", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "YIELDDISC", + "t": 8, + "d": "Calculates the annual yield of a discount (non-interest-bearing) security, based on price.", + "a": "Annual yield of a discount security.", + "m": [4, 5], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "price", + "detail": "The price at which the security is bought per 100 face value.", + "example": "95", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NOMINAL", + "t": 8, + "d": "Calculates the annual nominal interest rate given the effective rate and number of compounding periods per year.", + "a": "Annual nominal interest rate.", + "m": [2, 2], + "p": [{ + "name": "effective_rate", + "detail": "The effective interest rate per year.", + "example": "0.85", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "periods_per_year", + "detail": "The number of compounding periods per year.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "XIRR", + "t": 8, + "d": "Calculates the internal rate of return of an investment based on a specified series of potentially irregularly spaced cash flows.", + "a": "Internal rate of return given non-periodic cashflows.", + "m": [2, 3], + "p": [{ + "name": "cashflow_amounts", + "detail": "An array or range containing the income or payments associated with the investment.", + "example": "B2:B25", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "cashflow_dates", + "detail": "An array or range with dates corresponding to the cash flows in `cashflow_amounts`.", + "example": "C2:C25", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "rate_guess", + "detail": "An estimate for what the internal rate of return will be.", + "example": "250", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MIRR", + "t": 8, + "d": "Calculates the modified internal rate of return on an investment based on a series of periodic cash flows and the difference between the interest rate paid on financing versus the return received on reinvested income.", + "a": "Modified internal rate of return.", + "m": [3, 3], + "p": [{ + "name": "cashflow_amounts", + "detail": "An array or range containing the income or payments associated with the investment.", + "example": "A2:A25", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "financing_rate", + "detail": "The interest rate paid on funds invested.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "reinvestment_return_rate", + "detail": "The return (as a percentage) earned on reinvestment of income received from the investment.", + "example": "0.12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "IRR", + "t": 8, + "d": "Calculates the internal rate of return on an investment based on a series of periodic cash flows.", + "a": "Internal rate of return given periodic cashflows.", + "m": [1, 2], + "p": [{ + "name": "cashflow_amounts", + "detail": "An array or range containing the income or payments associated with the investment.", + "example": "A2:A25", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "rate_guess", + "detail": "An estimate for what the internal rate of return will be.", + "example": "200", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NPV", + "t": 8, + "d": "Calculates the net present value of an investment based on a series of periodic cash flows and a discount rate.", + "a": "The net present value of an investment based on a series of periodic cash flows and a discount rate.", + "m": [2, 255], + "p": [{ + "name": "discount", + "detail": "The discount rate of the investment over one period.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cashflow1", + "detail": "The first future cash flow.", + "example": "200", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "cashflow2", + "detail": "Additional future cash flows.", + "example": "250", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "XNPV", + "t": 8, + "d": "Calculates the net present value of an investment based on a specified series of potentially irregularly spaced cash flows and a discount rate.", + "a": "Net present value given non-periodic cashflows.", + "m": [3, 3], + "p": [{ + "name": "discount", + "detail": "The discount rate of the investment over one period.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "cashflow_amounts", + "detail": "A range of cells containing the income or payments associated with the investment.", + "example": "B2:B25", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "cashflow_dates", + "detail": "A range of cells with dates corresponding to the cash flows in `cashflow_amounts`.", + "example": "C2:C25", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "CUMIPMT", + "t": 8, + "d": "Calculates the cumulative interest over a range of payment periods for an investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Cumulative interest paid over a set of periods.", + "m": [6, 6], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "first_period", + "detail": "The number of the payment period to begin the cumulative calculation.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "last_period", + "detail": "The number of the payment period to end the cumulative calculation.", + "example": "5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "0", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PMT", + "t": 8, + "d": "Calculates the periodic payment for an annuity investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Periodic payment for an annuity investment.", + "m": [3, 5], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.08", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": " 100000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "D2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "IPMT", + "t": 8, + "d": "Calculates the payment on interest for an investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Payment on interest for an investment.", + "m": [4, 6], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "period", + "detail": "The amortization period, in terms of number of periods.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "80000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "E2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PPMT", + "t": 8, + "d": "Calculates the payment on the principal of an investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Payment on the principal of an investment.", + "m": [4, 6], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "period", + "detail": "The amortization period, in terms of number of periods.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_periods", + "detail": "The number of payments to be made.", + "example": "3*12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "100000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "INTRATE", + "t": 8, + "d": "Calculates the effective interest rate generated when an investment is purchased at one price and sold at another with no interest or dividends generated by the investment itself.", + "a": "Calculates effective interest rate.", + "m": [4, 5], + "p": [{ + "name": "buy_date", + "detail": "The date of purchase of the investment.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "sell_date", + "detail": "The date of sale of the investment.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "buy_price", + "detail": "The price at which the investment was purchased.", + "example": "100000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "sell_price", + "detail": "The price at which the investment was sold.", + "example": "101200", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PRICE", + "t": 8, + "d": "Calculates the price of a security paying periodic interest, such as a US Treasury Bond, based on expected yield.", + "a": "Price of a security paying periodic interest.", + "m": [6, 7], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.057", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "yield", + "detail": "The expected annual yield of the security.", + "example": "0.065", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PRICEDISC", + "t": 8, + "d": "Calculates the price of a discount (non-interest-bearing) security, based on expected yield.", + "a": "Price of a discount security.", + "m": [4, 5], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "discount", + "detail": "The discount rate of the security at time of purchase.", + "example": "0.0525", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "PRICEMAT", + "t": 8, + "d": "Calculates the price of a security paying interest at maturity, based on expected yield.", + "a": "Price of security paying interest at maturity.", + "m": [5, 6], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "issue", + "detail": "The date the security was initially issued.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.061", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "yield", + "detail": "The expected annual yield of the security.", + "example": "0.061", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "RECEIVED", + "t": 8, + "d": "Calculates the amount received at maturity for an investment in fixed-income securities purchased on a given date.", + "a": "Amount received at maturity for a security.", + "m": [4, 5], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "investment", + "detail": "The amount invested (irrespective of face value of each security).", + "example": "10000000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "discount", + "detail": "The discount rate of the security invested in.", + "example": "0.0575", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "12", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DISC", + "t": 8, + "d": "Calculates the discount rate of a security based on price.", + "a": "The discount rate of a security based on price.", + "m": [4, 5], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "price", + "detail": "The price at which the security is bought per 100 face value.", + "example": "97.975", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "redemption", + "detail": "The redemption amount per 100 face value, or par.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "12", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "NPER", + "t": 8, + "d": "Calculates the number of payment periods for an investment based on constant-amount periodic payments and a constant interest rate.", + "a": "Number of payment periods for an investment.", + "m": [3, 5], + "p": [{ + "name": "rate", + "detail": "The interest rate.", + "example": "0.12", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "payment_amount", + "detail": "The amount of each payment made.", + "example": "500", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "present_value", + "detail": "The current value of the annuity.", + "example": "40000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "future_value", + "detail": "The future value remaining after the final payment has been made.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "end_or_beginning", + "detail": "Whether payments are due at the end (`0`) or beginning (`1`) of each period.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SLN", + "t": 8, + "d": "Calculates the depreciation of an asset for one period using the straight-line method.", + "a": "Depreciation of asset using the straight-line method.", + "m": [3, 3], + "p": [{ + "name": "cost", + "detail": "The initial cost of the asset.", + "example": "300000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "salvage", + "detail": "The value of the asset at the end of depreciation.", + "example": "75000", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "life", + "detail": "The number of periods over which the asset is depreciated.", + "example": "10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DURATION", + "t": 8, + "d": "Calculates the number of compounding periods required for an investment of a specified present value appreciating at a given rate to reach a target value.", + "a": "Number of periods for an investment to reach a value.", + "m": [5, 6], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.08", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "yield", + "detail": "The expected annual yield of the security.", + "example": "0.09", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MDURATION", + "t": 8, + "d": "Calculates the modified Macaulay duration of a security paying periodic interest, such as a US Treasury Bond, based on expected yield.", + "a": "Modified Macaulay duration.", + "m": [5, 6], + "p": [{ + "name": "settlement", + "detail": "The settlement date of the security, the date after issuance when the security is delivered to the buyer.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "maturity", + "detail": "The maturity or end date of the security, when it can be redeemed at face, or par value.", + "example": "DATE(2010", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "rate", + "detail": "The annualized rate of interest.", + "example": "0.08", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "yield", + "detail": "The expected annual yield of the security.", + "example": "0.09", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "frequency", + "detail": "The number of interest or coupon payments per year (1, 2, or 4).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "day_count_convention", + "detail": "An indicator of what day count method to use.", + "example": "0", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "BIN2DEC", + "t": 9, + "d": "Converts a signed binary number to decimal format.", + "a": "Converts a signed binary number to decimal format.", + "m": [1, 1], + "p": [{ + "name": "signed_binary_number", + "detail": "The signed 10-bit binary value to be converted to decimal, provided as a string.", + "example": "101", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "BIN2HEX", + "t": 9, + "d": "Converts a signed binary number to signed hexadecimal format.", + "a": "Converts a binary number to hexadecimal.", + "m": [1, 2], + "p": [{ + "name": "signed_binary_number", + "detail": "The signed 10-bit binary value to be converted to signed hexademical, provided as a string.", + "example": "101", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "BIN2OCT", + "t": 9, + "d": "Converts a signed binary number to signed octal format.", + "a": "Converts a binary number to octal.", + "m": [1, 2], + "p": [{ + "name": "signed_binary_number", + "detail": "The signed 10-bit binary value to be converted to signed octal, provided as a string.", + "example": "101", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DEC2BIN", + "t": 9, + "d": "Converts a decimal number to signed binary format.", + "a": "Converts a decimal number to signed binary format.", + "m": [1, 2], + "p": [{ + "name": "decimal_number", + "detail": "The decimal value to be converted to signed binary, provided as a string.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DEC2HEX", + "t": 9, + "d": "Converts a decimal number to signed hexadecimal format.", + "a": "Converts a decimal number to hexadecimal.", + "m": [1, 2], + "p": [{ + "name": "decimal_number", + "detail": "The decimal value to be converted to signed hexadecimal, provided as a string.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DEC2OCT", + "t": 9, + "d": "Converts a decimal number to signed octal format.", + "a": "Converts a decimal number to signed octal format.", + "m": [1, 2], + "p": [{ + "name": "decimal_number", + "detail": "The decimal value to be converted to signed octal, provided as a string.", + "example": "100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "HEX2BIN", + "t": 9, + "d": "Converts a signed hexadecimal number to signed binary format.", + "a": "Converts a hexadecimal number to binary.", + "m": [1, 2], + "p": [{ + "name": "signed_hexadecimal_number", + "detail": "The signed 40-bit hexadecimal value to be converted to signed binary, provided as a string.", + "example": "\"f3\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "HEX2DEC", + "t": 9, + "d": "Converts a signed hexadecimal number to decimal format.", + "a": "Converts a hexadecimal number to decimal.", + "m": [1, 1], + "p": [{ + "name": "signed_hexadecimal_number", + "detail": "The signed 40-bit hexadecimal value to be converted to decimal, provided as a string.", + "example": "\"f3\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "HEX2OCT", + "t": 9, + "d": "Converts a signed hexadecimal number to signed octal format.", + "a": "Converts a hexadecimal number to octal.", + "m": [1, 2], + "p": [{ + "name": "signed_hexadecimal_number", + "detail": "The signed 40-bit hexadecimal value to be converted to signed octal, provided as a string.", + "example": "\"f3\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "OCT2BIN", + "t": 9, + "d": "Converts a signed octal number to signed binary format.", + "a": "Converts an octal number to binary.", + "m": [1, 2], + "p": [{ + "name": "signed_octal_number", + "detail": "The signed 30-bit octal value to be converted to signed binary, provided as a string.", + "example": "37", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "OCT2DEC", + "t": 9, + "d": "Converts a signed octal number to decimal format.", + "a": "Converts a signed octal number to decimal format.", + "m": [1, 1], + "p": [{ + "name": "signed_octal_number", + "detail": "The signed 30-bit octal value to be converted to decimal, provided as a string.", + "example": "37", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "OCT2HEX", + "t": 9, + "d": "Converts a signed octal number to signed hexadecimal format.", + "a": "Converts an octal number to hexadecimal.", + "m": [1, 2], + "p": [{ + "name": "signed_octal_number", + "detail": "The signed 30-bit octal value to be converted to signed hexadecimal, provided as a string.", + "example": "37", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "significant_digits", + "detail": "The number of significant digits to ensure in the result.", + "example": "8", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "COMPLEX", + "t": 9, + "d": "Creates a complex number given real and imaginary coefficients.", + "a": "Creates a complex number.", + "m": [2, 3], + "p": [{ + "name": "real_part", + "detail": "The real coefficient.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "imaginary_part", + "detail": "The imaginary coefficient.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "suffix", + "detail": "The suffix for the imaginary coefficient, can only be 'i' or 'j'. If omitted, 'i' will be used.", + "example": "\"j\"", + "require": "o", + "repeat": "n", + "type": "rangestring" + }] +}, { + "n": "IMREAL", + "t": 9, + "d": "Returns the real coefficient of a complex number.", + "a": "The real coefficient of a complex number.", + "m": [1, 1], + "p": [{ + "name": "complex_number", + "detail": "The complex number, in the a+bi or a+bj format.", + "example": "\"4+5i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "IMAGINARY", + "t": 9, + "d": "Returns the imaginary coefficient of a complex number.", + "a": "The imaginary coefficient of a complex number.", + "m": [1, 1], + "p": [{ + "name": "complex_number", + "detail": "The complex number, in the a+bi or a+bj format.", + "example": "\"4+5i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "IMCONJUGATE", + "t": 9, + "d": "Returns the complex conjugate of a number.", + "a": "The complex conjugate of a number.", + "m": [1, 1], + "p": [{ + "name": "number", + "detail": "The complex number to calculate the conjugate for.", + "example": "\"3+4i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "IMABS", + "t": 9, + "d": "Returns absolute value (or modulus) of a complex number.", + "a": "The absolute value of a complex number.", + "m": [1, 1], + "p": [{ + "name": "number", + "detail": "The complex number to calculate the absolute value of.", + "example": "\"3+4i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DELTA", + "t": 9, + "d": "Compare two numeric values, returning 1 if they're equal.", + "a": "Compare two numeric values.", + "m": [1, 2], + "p": [{ + "name": "number1", + "detail": "The first number to compare.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number2", + "detail": "The second number to compare.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "IMSUM", + "t": 9, + "d": "Returns the sum of a series of complex numbers.", + "a": "Sum of a series of complex numbers.", + "m": [1, 255], + "p": [{ + "name": "value1", + "detail": "The first complex number or range to add together.", + "example": "\"3+4i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "Additional complex numbers or ranges to add to `value1`.", + "example": "\"5-3i\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "IMSUB", + "t": 9, + "d": "Returns the difference between two complex numbers.", + "a": "The difference between two complex numbers.", + "m": [2, 2], + "p": [{ + "name": "first_number", + "detail": "The complex number to subtract second_number from.", + "example": "\"6+5i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "second_number", + "detail": "The complex number to subtract from first_number.", + "example": "\"2+3i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "IMPRODUCT", + "t": 9, + "d": "Returns the result of multiplying a series of complex numbers together.", + "a": "Result of multiplying a series of complex numbers together.", + "m": [1, 255], + "p": [{ + "name": "factor1", + "detail": "The first number or range to calculate for the product.", + "example": "\"3+4i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "factor2", + "detail": "Additional complex numbers or ranges to calculate for the product.", + "example": "\"5-3i\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "IMDIV", + "t": 9, + "d": "Returns one complex number divided by another.", + "a": "One complex number divided by another.", + "m": [2, 2], + "p": [{ + "name": "dividend", + "detail": "The complex number to be divided.", + "example": "\"11+16i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "divisor", + "detail": "The complex number to divide by.", + "example": "\"3+2i\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NOT", + "t": 10, + "d": "Returns the opposite of a logical value - `NOT(TRUE)` returns `FALSE`; `NOT(FALSE)` returns `TRUE`.", + "a": "Returns opposite of provided logical value.", + "m": [1, 1], + "p": [{ + "name": "logical_expression", + "detail": "An expression or reference to a cell holding an expression that represents some logical value.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TRUE", + "t": 10, + "d": "Returns the logical value `TRUE`.", + "a": "Logical value `true`.", + "m": [0, 0], + "p": [] +}, { + "n": "FALSE", + "t": 10, + "d": "Returns the logical value `FALSE`.", + "a": "Logical value `false`.", + "m": [0, 0], + "p": [] +}, { + "n": "AND", + "t": 10, + "d": "Returns true if all of the provided arguments are logically true, and false if any of the provided arguments are logically false.", + "a": "Logical `and` operator.", + "m": [1, 255], + "p": [{ + "name": "logical_expression1", + "detail": "An expression or reference to a cell containing an expression that represents some logical value, i.e. `TRUE` or `FALSE`, or an expression that can be coerced to a logical value.", + "example": "A2 = \"foo\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "logical_expression2", + "detail": "More expressions that represent logical values.", + "example": "A3 = \"bar\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "IFERROR", + "t": 10, + "d": "Returns the first argument if it is not an error value, otherwise returns the second argument if present, or a blank if the second argument is absent.", + "a": "Value if it is not an error, otherwise 2nd argument.", + "m": [2, 2], + "p": [{ + "name": "value", + "detail": "The value to return if `value` itself is not an error.", + "example": "A1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value_if_error", + "detail": "The value the function returns if `value` is an error.", + "example": "\"Error in cell A1\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "IF", + "t": 10, + "d": "Returns one value if a logical expression is `TRUE` and another if it is `FALSE`.", + "a": "Returns value depending on logical expression.", + "m": [2, 3], + "p": [{ + "name": "logical_expression", + "detail": "An expression or reference to a cell containing an expression that represents some logical value, i.e. `TRUE` or `FALSE`.", + "example": "A2 = \"foo\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value_if_true", + "detail": "The value the function returns if `logical_expression` is `TRUE`.", + "example": "\"A2 is foo\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value_if_false", + "detail": "The value the function returns if `logical_expression` is `FALSE`.", + "example": "\"A2 was false\"", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "OR", + "t": 10, + "d": "Returns true if any of the provided arguments are logically true, and false if all of the provided arguments are logically false.", + "a": "Logical `or` operator.", + "m": [1, 255], + "p": [{ + "name": "logical_expression1", + "detail": "An expression or reference to a cell containing an expression that represents some logical value, i.e. `TRUE` or `FALSE`, or an expression that can be coerced to a logical value.", + "example": "A2 = \"foo\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "logical_expression2", + "detail": "More expressions that evaluate to logical values.", + "example": " A3 = \"bar\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "NE", + "t": 11, + "d": "Returns `TRUE` if two specified values are not equal and `FALSE` otherwise. Equivalent to the `!=` operator.", + "a": "Not equal.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The first value.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The value to test against `value1` for inequality.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "EQ", + "t": 11, + "d": "Returns `TRUE` if two specified values are equal and `FALSE` otherwise. Equivalent to the `==` operator.", + "a": "Equal.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The first value.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The value to test against `value1` for equality.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "GT", + "t": 11, + "d": "Returns `TRUE` if the first argument is strictly greater than the second, and `FALSE` otherwise. Equivalent to the `>` operator.", + "a": "Strictly greater than.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The value to test as being greater than `value2`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The second value.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "GTE", + "t": 11, + "d": "Returns `TRUE` if the first argument is greater than or equal to the second, and `FALSE` otherwise. Equivalent to the `>=` operator.", + "a": "Greater than or equal to.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The value to test as being greater than or equal to `value2`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The second value.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LT", + "t": 11, + "d": "Returns `TRUE` if the first argument is strictly less than the second, and `FALSE` otherwise. Equivalent to the `<` operator.", + "a": "Less than.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The value to test as being less than `value2`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The second value.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LTE", + "t": 11, + "d": "Returns `TRUE` if the first argument is less than or equal to the second, and `FALSE` otherwise. Equivalent to the `<=` operator.", + "a": "Less than or equal to.", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The value to test as being less than or equal to `value2`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The second value.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ADD", + "t": 11, + "d": "Returns the sum of two numbers. Equivalent to the `+` operator.", + "a": "Sum of two numbers", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The first addend.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "The second addend.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MINUS", + "t": 11, + "d": "Returns the difference of two numbers. Equivalent to the `-` operator.", + "a": "Difference of two numbers", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The minuend, or number to be subtracted from.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "value2", + "detail": "The subtrahend, or number to subtract from `value1`.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MULTIPLY", + "t": 11, + "d": "Returns the product of two numbers. Equivalent to the `*` operator.", + "a": "Product of two numbers", + "m": [2, 2], + "p": [{ + "name": "factor1", + "detail": "The first multiplicand.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "factor2", + "detail": "The second multiplicand.", + "example": "B2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DIVIDE", + "t": 11, + "d": "Returns one number divided by another. Equivalent to the `/` operator.", + "a": "One number divided by another", + "m": [2, 2], + "p": [{ + "name": "dividend", + "detail": "The number to be divided.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "divisor", + "detail": "The number to divide by.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CONCAT", + "t": 11, + "d": "Returns the concatenation of two values. Equivalent to the `&` operator.", + "a": "Concatenation of two values", + "m": [2, 2], + "p": [{ + "name": "value1", + "detail": "The value to which `value2` will be appended.", + "example": "\"de\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value2", + "detail": "The value to append to `value1`.", + "example": "\"mystify\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "UNARY_PERCENT", + "t": 11, + "d": "Returns a value interpreted as a percentage; that is, `UNARY_PERCENT(100)` equals `1`.", + "a": "Value interpreted as a percentage.", + "m": [1, 1], + "p": [{ + "name": "percentage", + "detail": "The value to interpret as a percentage.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CONCATENATE", + "t": 12, + "d": "Appends strings to one another.", + "a": "Appends strings to one another.", + "m": [1, 255], + "p": [{ + "name": "string1", + "detail": "The initial string.", + "example": "\"Super\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "string2", + "detail": "More strings to append in sequence.", + "example": "\"calla\"", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "CODE", + "t": 12, + "d": "Returns the numeric Unicode map value of the first character in the string provided.", + "a": "Numeric unicode map value of character.", + "m": [1, 1], + "p": [{ + "name": "string", + "detail": "The string whose first character's Unicode map value will be returned.", + "example": "\"a\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "CHAR", + "t": 12, + "d": "Convert a number into a character according to the current Unicode table.", + "a": "Gets character associated with number.", + "m": [1, 1], + "p": [{ + "name": "table_number", + "detail": "The number of the character to look up from the current Unicode table in decimal format.", + "example": "97", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ARABIC", + "t": 12, + "d": "Computes the value of a Roman numeral.", + "a": "Computes the value of a roman numeral.", + "m": [1, 1], + "p": [{ + "name": "roman_numeral", + "detail": "The Roman numeral to format, whose value must be between 1 and 3999, inclusive.", + "example": "\"XIV\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ROMAN", + "t": 12, + "d": "Formats a number in Roman numerals.", + "a": "Formats a number in Roman numerals.", + "m": [1, 1], + "p": [{ + "name": "number", + "detail": "The number to format, between 1 and 3999, inclusive.", + "example": "499", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "REGEXEXTRACT", + "t": 12, + "d": "Extracts matching substrings according to a regular expression.", + "a": "Extracts matching substrings with regular expression.", + "m": [2, 2], + "p": [{ + "name": "text", + "detail": "The input text.", + "example": "\"Needle in a haystack\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "regular_expression", + "detail": "The first part of `text` that matches this expression will be returned.", + "example": "\".e{2}dle\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "REGEXMATCH", + "t": 12, + "d": "Whether a piece of text matches a regular expression.", + "a": "Whether a piece of text matches regular expression.", + "m": [2, 2], + "p": [{ + "name": "text", + "detail": "The text to be tested against the regular expression.", + "example": "\"Spreadsheets\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "regular_expression", + "detail": "The regular expression to test the text against.", + "example": "\"S.r\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "REGEXREPLACE", + "t": 12, + "d": "Replaces part of a text string with a different text string using regular expressions.", + "a": "Replaces text with regular expressions.", + "m": [3, 3], + "p": [{ + "name": "text", + "detail": "The text, a part of which will be replaced.", + "example": "\"Spreadsheets\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "regular_expression", + "detail": "The regular expression. All matching instances in `text` will be replaced.", + "example": "\"S.*d\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "replacement", + "detail": "The text which will be inserted into the original text.", + "example": "\"Bed\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "T", + "t": 12, + "d": "Returns string arguments as text, or the empty string if the value is not text.", + "a": "String arguments as text.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument to be converted to text.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "FIXED", + "t": 12, + "d": "Formats a number with a fixed number of decimal places.", + "a": "Formats number with fixed number of decimal places.", + "m": [1, 3], + "p": [{ + "name": "number", + "detail": "The number to format.", + "example": "3.141592653", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "number_of_places", + "detail": "The number of decimal places to display in the result.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "suppress_separator", + "detail": "Whether or not to suppress the thousands separator used in some locales (e.g. `1,000` becomes `1000`). Separators will be present if this value is 0 or omitted, and absent otherwise.", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "FIND", + "t": 12, + "d": "Returns the position at which a string is first found within text where the capitalization of letters matters. Returns `#VALUE!` if the string is not found.", + "a": "First position of string found in text, case-sensitive.", + "m": [2, 3], + "p": [{ + "name": "search_for", + "detail": "The string to look for within `text_to_search`.", + "example": "\"n\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "text_to_search", + "detail": "The text to search for the first occurrence of `search_for`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "starting_at", + "detail": "The character within `text_to_search` at which to start the search.", + "example": "14", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "FINDB", + "t": 12, + "d": "Returns the position at which a string is first found within text counting each double-character as 2.", + "a": "Position at which a string is first found within text (binary).", + "m": [2, 3], + "p": [{ + "name": "search_for", + "detail": "The string to look for within `text_to_search`.", + "example": "\"new\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "text_to_search", + "detail": "The text to search for the first occurrence of `search_for`.", + "example": "\"new year\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "starting_at", + "detail": "The character within `text_to_search` at which to start the search.", + "example": "2", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "JOIN", + "t": 12, + "d": "Concatenates the elements of one or more one-dimensional arrays using a specified delimiter.", + "a": "Concatenates elements of arrays with delimiter.", + "m": [2, 255], + "p": [{ + "name": "delimiter", + "detail": "The character or string to place between each concatenated value.", + "example": "\" and-a \"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value_or_array1", + "detail": "The value or values to be appended using `delimiter`.", + "example": "{1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "value_or_array2", + "detail": "More values to be appended using `delimiter`.", + "example": "2", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "LEFT", + "t": 12, + "d": "Returns a substring from the beginning of a specified string.", + "a": "Substring from beginning of specified string.", + "m": [1, 2], + "p": [{ + "name": "string", + "detail": "The string from which the left portion will be returned.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "number_of_characters", + "detail": "The number of characters to return from the left side of `string`.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "RIGHT", + "t": 12, + "d": "Returns a substring from the end of a specified string.", + "a": "A substring from the end of a specified string.", + "m": [1, 2], + "p": [{ + "name": "string", + "detail": "The string from which the right portion will be returned.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "number_of_characters", + "detail": "The number of characters to return from the right side of `string`.", + "example": "2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MID", + "t": 12, + "d": "Returns a segment of a string.", + "a": "A segment of a string.", + "m": [3, 3], + "p": [{ + "name": "string", + "detail": "The string to extract a segment from.", + "example": "\"get this\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "starting_at", + "detail": "The index from the left of `string` from which to begin extracting. The first character in `string` has the index 1.", + "example": "5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "extract_length", + "detail": "The length of the segment to extract.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "LEN", + "t": 12, + "d": "Returns the length of a string.", + "a": "Length of a string.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The string whose length will be returned.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LENB", + "t": 12, + "d": "Returns the length of a string in bytes.", + "a": "Length of a string in bytes.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The string whose length will be returned.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LOWER", + "t": 12, + "d": "Converts a specified string to lowercase.", + "a": "Converts a specified string to lowercase.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The string to convert to lowercase.", + "example": "\"LOREM IPSUM\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "UPPER", + "t": 12, + "d": "Converts a specified string to uppercase.", + "a": "Converts a specified string to uppercase.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The string to convert to uppercase.", + "example": "\"lorem ipsum\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "EXACT", + "t": 12, + "d": "Tests whether two strings are identical.", + "a": "Tests whether two strings are identical.", + "m": [2, 2], + "p": [{ + "name": "string1", + "detail": "The first string to compare", + "example": "A1", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "string2", + "detail": "The second string to compare", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "REPLACE", + "t": 12, + "d": "Replaces part of a text string with a different text string.", + "a": "Replaces part of a text string with different text.", + "m": [4, 4], + "p": [{ + "name": "text", + "detail": "The text, a part of which will be replaced.", + "example": "\"Spreadsheets\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "position", + "detail": "The position where the replacement will begin (starting from 1).", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "length", + "detail": "The number of characters in the text to be replaced.", + "example": "6", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "new_text", + "detail": "The text which will be inserted into the original text.", + "example": "\"Bed\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "REPT", + "t": 12, + "d": "Returns specified text repeated a number of times.", + "a": "Specified text repeated a number of times.", + "m": [2, 2], + "p": [{ + "name": "text_to_repeat", + "detail": "The character or string to repeat.", + "example": "\"ha\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "number_of_repetitions", + "detail": "The number of times `text_to_repeat` should appear in the value returned.", + "example": "4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SEARCH", + "t": 12, + "d": "Returns the position at which a string is first found within text and ignores capitalization of letters. Returns `#VALUE!` if the string is not found.", + "a": "First position of string found in text, ignoring case.", + "m": [2, 3], + "p": [{ + "name": "search_for", + "detail": "The string to look for within `text_to_search`.", + "example": "\"n\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "text_to_search", + "detail": "The text to search for the first occurrence of `search_for`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "starting_at", + "detail": "The character within `text_to_search` at which to start the search.", + "example": "14", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUBSTITUTE", + "t": 12, + "d": "Replaces existing text with new text in a string.", + "a": "Replaces existing text with new text in a string.", + "m": [3, 4], + "p": [{ + "name": "text_to_search", + "detail": "The text within which to search and replace.", + "example": "\"search for it\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "search_for", + "detail": "The string to search for within `text_to_search`.", + "example": "\"search for\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "replace_with", + "detail": "The string that will replace `search_for`.", + "example": "\"Google\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "occurrence_number", + "detail": "The instance of `search_for` within `text_to_search` to replace with `replace_with`. By default, all occurrences of `search_for` are replaced; however, if `occurrence_number` is specified, only the indicated instance of `search_for` is replaced.", + "example": "3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "CLEAN", + "t": 12, + "d": "Returns the text with the non-printable ASCII characters removed.", + "a": "Removes non-printable characters from a piece of text.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The text whose non-printable characters are to be removed.", + "example": "\"AF\"&CHAR(31)", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TEXT", + "t": 12, + "d": "Converts a number into text according to a specified format.", + "a": "Formats a number into text.", + "m": [2, 2], + "p": [{ + "name": "number", + "detail": "The number, date, or time to format.", + "example": "1.23", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "format", + "detail": "The pattern by which to format the number, enclosed in quotation marks.", + "example": "\"$0.00\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TRIM", + "t": 12, + "d": "Removes leading, trailing, and repeated spaces in text.", + "a": "Removes space characters.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The text or reference to a cell containing text to be trimmed.", + "example": "\" lorem ipsum\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "VALUE", + "t": 12, + "d": "Converts a string in any of the date, time or number formats that Google Sheets understands into a number.", + "a": "Converts a date/time/number string into a number.", + "m": [1, 1], + "p": [{ + "name": "text", + "detail": "The string containing the value to be converted.", + "example": "\"123\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "PROPER", + "t": 12, + "d": "Capitalizes each word in a specified string.", + "a": "Capitalizes each word in a specified string.", + "m": [1, 1], + "p": [{ + "name": "text_to_capitalize", + "detail": "The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.", + "example": "\"united states\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "CONVERT", + "t": 13, + "d": "Converts a numeric value to a different unit of measure.", + "a": "Unit conversion for numbers.", + "m": [3, 3], + "p": [{ + "name": "value", + "detail": "The numeric value in `start_unit` to convert to `end_unit`.", + "example": "5.1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "start_unit", + "detail": "The starting unit, the unit currently assigned to `value`.", + "example": "\"g\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "end_unit", + "detail": "The unit of measure into which to convert the argument, `value`.", + "example": "\"kg\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "SUMX2MY2", + "t": 14, + "d": "Calculates the sum of the differences of the squares of values in two arrays.", + "a": "Sum of the differences of squares.", + "m": [2, 2], + "p": [{ + "name": "array_x", + "detail": "The array or range of values whose squares will be reduced by the squares of corresponding entries in `array_y` and added together.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "array_y", + "detail": "The array or range of values whose squares will be subtracted from the squares of corresponding entries in `array_x` and added together.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUMX2PY2", + "t": 14, + "d": "Calculates the sum of the sums of the squares of values in two arrays.", + "a": "Sum of the sums of squares.", + "m": [2, 2], + "p": [{ + "name": "array_x", + "detail": "The array or range of values whose squares will be added to the squares of corresponding entries in `array_y` and added together.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "array_y", + "detail": "The array or range of values whose squares will be added to the squares of corresponding entries in `array_x` and added together.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUMXMY2", + "t": 14, + "d": "Calculates the sum of the squares of differences of values in two arrays.", + "a": "Sum of the squares of differences.", + "m": [2, 2], + "p": [{ + "name": "array_x", + "detail": "The array or range of values that will be reduced by corresponding entries in `array_y`, squared, and added together.", + "example": "A2:A100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "array_y", + "detail": "The array or range of values that will be subtracted from corresponding entries in `array_x`, the result squared, and all such results added together.", + "example": "B2:B100", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TRANSPOSE", + "t": 14, + "d": "Transposes the rows and columns of an array or range of cells.", + "a": "Transposes the rows and columns of an array.", + "m": [1, 1], + "p": [{ + "name": "array_or_range", + "detail": "The array or range whose rows and columns will be swapped.", + "example": "{1,2}", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "TREND", + "t": 14, + "d": "Given partial data about a linear trend, fits an ideal linear trend using the least squares method and/or predicts further values.", + "a": "Fits points to linear trend derived via least-squares.", + "m": [1, 4], + "p": [{ + "name": "known_data_y", + "detail": "The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.", + "example": "B2:B10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "known_data_x", + "detail": "The values of the independent variable(s) corresponding with `known_data_y`.", + "example": "A2:A10", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "new_data_x", + "detail": "The data points to return the `y` values for on the ideal curve fit.", + "example": "A11:A13", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "b", + "detail": "Given a general linear form of `y = m*x+b` for a curve fit, calculates `b` if `TRUE` or forces `b` to be `0` and only calculates the `m` values if `FALSE`, i.e. forces the curve fit to pass through the origin.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "FREQUENCY", + "t": 14, + "d": "Calculates the frequency distribution of a one-column array into specified classes.", + "a": "The frequency distribution of array.", + "m": [2, 2], + "p": [{ + "name": "data", + "detail": "The array or range containing the values to be counted.", + "example": "A2:A40", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "classes", + "detail": "The array or range containing the set of classes.", + "example": "B2:B5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "GROWTH", + "t": 14, + "d": "Given partial data about an exponential growth trend, fits an ideal exponential growth trend and/or predicts further values.", + "a": "Fits points to exponential growth trend.", + "m": [1, 4], + "p": [{ + "name": "known_data_y", + "detail": "The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.", + "example": "B2:B10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "known_data_x", + "detail": "The values of the independent variable(s) corresponding with `known_data_y`.", + "example": "A2:A10", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "new_data_x", + "detail": "The data points to return the `y` values for on the ideal curve fit.", + "example": "A11:A13", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "b", + "detail": "Given a general exponential form of `y = b*m^x` for a curve fit, calculates `b` if `TRUE` or forces `b` to be `1` and only calculates the `m` values if `FALSE`.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LINEST", + "t": 14, + "d": "Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.", + "a": "Best-fit linear trend via least-squares.", + "m": [1, 4], + "p": [{ + "name": "known_data_y", + "detail": "The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.", + "example": "B2:B10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "known_data_x", + "detail": "The values of the independent variable(s) corresponding with `known_data_y`.", + "example": "A2:A10", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "calculate_b", + "detail": "Given a linear form of `y = m*x+b`, calculates the y-intercept (`b`) if `TRUE`. Otherwise, forces `b` to be `0` and only calculates the `m` values if `FALSE`, i.e. forces the curve fit to pass through the origin.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "verbose", + "detail": "A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept (default).", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LOGEST", + "t": 14, + "d": "Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.", + "a": "Best-fit exponential growth curve.", + "m": [1, 4], + "p": [{ + "name": "known_data_y", + "detail": "The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.", + "example": "B2:B10", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "known_data_x", + "detail": "The values of the independent variable(s) corresponding with `known_data_y`.", + "example": "A2:A10", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "b", + "detail": "Given a general exponential form of `y = b*m^x` for a curve fit, calculates `b` if `TRUE` or forces `b` to be `1` and only calculates the `m` values if `FALSE`.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "verbose", + "detail": "A flag specifying whether to return additional regression statistics or only the calculated coefficient and exponents.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "MDETERM", + "t": 14, + "d": "Returns the matrix determinant of a square matrix specified as an array or range.", + "a": "Matrix determinant of a square matrix.", + "m": [1, 1], + "p": [{ + "name": "square_matrix", + "detail": "An array or range with an equal number of rows and columns representing a matrix whose determinant will be calculated.", + "example": "A1:D4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MINVERSE", + "t": 14, + "d": "Returns the multiplicative inverse of a square matrix specified as an array or range.", + "a": "Multiplicative inverse of square matrix.", + "m": [1, 1], + "p": [{ + "name": "square_matrix", + "detail": "An array or range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.", + "example": "A1:D4", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "MMULT", + "t": 14, + "d": "Calculates the matrix product of two matrices specified as arrays or ranges.", + "a": "The matrix product of two matrices.", + "m": [2, 2], + "p": [{ + "name": "matrix1", + "detail": "The first matrix in the matrix multiplication operation, represented as an array or range.", + "example": "A1:B3", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "matrix2", + "detail": "The second matrix in the matrix multiplication operation, represented as an array or range.", + "example": "C1:F2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SUMPRODUCT", + "t": 14, + "d": "Calculates the sum of the products of corresponding entries in two equal-sized arrays or ranges.", + "a": "Sum of products of elements in two arrays.", + "m": [1, 255], + "p": [{ + "name": "array1", + "detail": "The first array or range whose entries will be multiplied with corresponding entries in the second such array or range.", + "example": "A2:C5", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "array2", + "detail": "The second array or range whose entries will be multiplied with corresponding entries in the first such array or range.", + "example": "D2:F5", + "require": "o", + "repeat": "y", + "type": "rangenumber" + }] +}, { + "n": "ISFORMULA", + "t": 15, + "d": "Checks whether a value is a formula.", + "a": "Whether a value is a formula.", + "m": [1, 1], + "p": [{ + "name": "cell", + "detail": "The cell to be verified as containing a formula.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "CELL", + "t": 15, + "d": "Returns the requested information about the specified cell.", + "a": "Gets information about a cell.", + "m": [2, 2], + "p": [{ + "name": "info_type", + "detail": "The type of information requested (see article for available types)", + "example": "\"type\"", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "reference", + "detail": "The reference to the cell.", + "example": "C2", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "NA", + "t": 15, + "d": "Returns the \"value not available\" error, `#N/A`.", + "a": "The `#N/A` error.", + "m": [0, 0], + "p": [] +}, { + "n": "ERROR_TYPE", + "t": 15, + "d": "Returns a number corresponding to the error value in a different cell.", + "a": "Error value of cell (as number).", + "m": [1, 1], + "p": [{ + "name": "reference", + "detail": "The cell to find the error number for although you can also provide the error value directly.", + "example": "A3", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISBLANK", + "t": 15, + "d": "Checks whether the referenced cell is empty.", + "a": "Whether the referenced cell is empty.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "Reference to the cell that will be checked for emptiness.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "ISERR", + "t": 15, + "d": "Checks whether a value is an error other than `#N/A`.", + "a": "Whether a value is an error other than `#n/a`.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as an error type other than `#N/A`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISERROR", + "t": 15, + "d": "Checks whether a value is an error.", + "a": "Whether a value is an error.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as an error type.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISLOGICAL", + "t": 15, + "d": "Checks whether a value is `TRUE` or `FALSE`.", + "a": "Whether a value is `true` or `false`.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as a logical `TRUE` or `FALSE`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISNA", + "t": 15, + "d": "Checks whether a value is the error `#N/A`.", + "a": "Whether a value is the error `#n/a`.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be compared with the error value `#N/A`.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISNONTEXT", + "t": 15, + "d": "Checks whether a value is non-textual.", + "a": "Whether a value is non-textual.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be checked.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISNUMBER", + "t": 15, + "d": "Checks whether a value is a number.", + "a": "Whether a value is a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as a number.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISREF", + "t": 15, + "d": "Checks whether a value is a valid cell reference.", + "a": "Whether a value is a valid cell reference.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as a cell reference.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "ISTEXT", + "t": 15, + "d": "Checks whether a value is text.", + "a": "Whether a value is text.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value to be verified as text.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TYPE", + "t": 15, + "d": "Returns a number associated with the type of data passed into the function.", + "a": "Get the type of a value.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The value whose type is to be determined.", + "example": "C4", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "N", + "t": 15, + "d": "Returns the argument provided as a number. Text is converted to 0 and errors are returned as-is.", + "a": "Argument provided as a number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument to be converted to a number.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TO_DATE", + "t": 16, + "d": "Converts a provided number to a date.", + "a": "Converts a provided number to a date.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument or reference to a cell to be converted to a date.", + "example": "25405", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TO_PURE_NUMBER", + "t": 16, + "d": "Converts a provided date/time, percentage, currency or other formatted numeric value to a pure number without formatting.", + "a": "Converts any numeric value to a pure number.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument or reference to a cell to be converted to a pure number.", + "example": "50%", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TO_TEXT", + "t": 16, + "d": "Converts a provided numeric value to a text value.", + "a": "Converts a provided numeric value to a text value.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument or reference to a cell to be converted to text.", + "example": "24", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TO_DOLLARS", + "t": 16, + "d": "Converts a provided number to a dollar value.", + "a": "Converts a provided number to a dollar value.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument or reference to a cell to be converted to a dollar value.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "TO_PERCENT", + "t": 16, + "d": "Converts a provided number to a percentage.", + "a": "Converts a provided number to a percentage.", + "m": [1, 1], + "p": [{ + "name": "value", + "detail": "The argument or reference to a cell to be converted to a percentage.", + "example": "A2", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DGET", + "t": 17, + "d": "Returns a single value from a database table-like array or range using a SQL-like query.", + "a": "Single value from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DMAX", + "t": 17, + "d": "Returns the maximum value selected from a database table-like array or range using a SQL-like query.", + "a": "Maximum of values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DMIN", + "t": 17, + "d": "Returns the minimum value selected from a database table-like array or range using a SQL-like query.", + "a": "Minimum of values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DAVERAGE", + "t": 17, + "d": "Returns the average of a set of values selected from a database table-like array or range using a SQL-like query.", + "a": "Average of a set of values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DCOUNT", + "t": 17, + "d": "Counts numeric values selected from a database table-like array or range using a SQL-like query.", + "a": "Counts values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DCOUNTA", + "t": 17, + "d": "Counts values, including text, selected from a database table-like array or range using a SQL-like query.", + "a": "Counts values and text from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DPRODUCT", + "t": 17, + "d": "Returns the product of values selected from a database table-like array or range using a SQL-like query.", + "a": "Product of values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DSTDEV", + "t": 17, + "d": "Returns the standard deviation of a population sample selected from a database table-like array or range using a SQL-like query.", + "a": "Standard deviation of population sample from table.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DSTDEVP", + "t": 17, + "d": "Returns the standard deviation of an entire population selected from a database table-like array or range using a SQL-like query.", + "a": "Standard deviation of entire population from table.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DSUM", + "t": 17, + "d": "Returns the sum of values selected from a database table-like array or range using a SQL-like query.", + "a": "Sum of values from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DVAR", + "t": 17, + "d": "Returns the variance of a population sample selected from a database table-like array or range using a SQL-like query.", + "a": "Variance of population sample from table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "DVARP", + "t": 17, + "d": "Returns the variance of an entire population selected from a database table-like array or range using a SQL-like query.", + "a": "Variance of a population from a table-like range.", + "m": [3, 3], + "p": [{ + "name": "database", + "detail": "The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.", + "example": "A2:F20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "field", + "detail": "Indicates which column in `database` contains the values to be extracted and operated on.", + "example": "G2", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "criteria", + "detail": "An array or range containing zero or more criteria to filter the `database` values by before operating.", + "example": "A22:D23", + "require": "m", + "repeat": "n", + "type": "range" + }] +}, { + "n": "AGE_BY_IDCARD", + "t": "3", + "d": "Calculate the age based on the Chinese ID number. Support 15 or 18", + "a": "Get age based on ID number.", + "m": [1, 2], + "p": [{ + "name": "ID number", + "example": "A1", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Deadline", + "example": "\"2017-10-01\"", + "detail": "The deadline or range of age calculation. The default is the current day.", + "require": "o", + "repeat": "n", + "type": "rangedatetime" + }] +}, { + "n": "SEX_BY_IDCARD", + "t": "3", + "d": "Calculate gender based on Chinese ID number. Support 15 or 18", + "a": "Get gender based on ID number.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "BIRTHDAY_BY_IDCARD", + "t": "3", + "d": "Calculate the birthday based on the Chinese ID number. Support 15 or 18", + "a": "Get the birthday based on the ID number.", + "m": [1, 2], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Birthday format", + "example": "0", + "detail": "Date type, default:0:[1900/01/01], 1:[1900-01-01], 2:[1900年1月1日]", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "PROVINCE_BY_IDCARD", + "t": "3", + "d": "Calculate the province of birthplace based on the Chinese ID number. Support 15 or 18", + "a": "Get the province of birthplace based on the ID number.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "CITY_BY_IDCARD", + "t": "3", + "d": "Calculate the city of birthplace based on the Chinese ID number. Support 15 or 18", + "a": "Get the city of birthplace based on the ID number.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "STAR_BY_IDCARD", + "t": "3", + "d": "Calculate the constellation based on the Chinese ID number. Support 15 or 18", + "a": "Get the constellation based on the ID number.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ANIMAL_BY_IDCARD", + "t": "3", + "d": "Calculate the zodiac (rat, ox, tiger, rabbit...) based on the Chinese ID number. Support 15 or 18", + "a": "Get the zodiac according to the ID number.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "ISIDCARD", + "t": "3", + "d": "Verify that the format of the ID card is correct. Support 15 or 18", + "a": "Verify the correctness of the ID card format.", + "m": [1, 1], + "p": [{ + "name": "ID number", + "example": "\"31033519900101XXXX\"", + "detail": "15-digit or 18-digit ID number or range.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "DM_TEXT_CUTWORD", + "t": "4", + "d": "Text segmentation. Split a series of words into a series of individual words", + "a": "Chinese text segmentation.", + "m": [1, 2], + "p": [{ + "name": "Text", + "example": "\"I came to Beijing Tsinghua University\"", + "detail": "Any text that needs word segmentation.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Word segmentation mode", + "example": "0", + "detail": "The default is 0[precision mode], 1[full mode], 2[search engine mode].", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DM_TEXT_TFIDF", + "t": "4", + "d": "Use tf-idf algorithm for keyword extraction. Identify keywords from a series of text", + "a": "tf-idf keyword recognition.", + "m": [1, 3], + "p": [{ + "name": "Text", + "example": "\"I came to Beijing Tsinghua University\"", + "detail": "Any text that needs word segmentation.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Number of keywords", + "example": "20", + "detail": "The number of keywords returned by the algorithm, the default is 20", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "Corpus", + "example": "1", + "detail": "Select a corpus in a specific field, the default is 0[General], 1[Finance], 2[Medical]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DM_TEXT_TEXTRANK", + "t": "4", + "d": "Use TextRank algorithm to extract keywords. Identify keywords from a series of text", + "a": "TextRank keyword recognition.", + "m": [1, 3], + "p": [{ + "name": "Text", + "example": "\"I came to Beijing Tsinghua University\"", + "detail": "Any text that needs word segmentation.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Number of keywords", + "example": "20", + "detail": "The number of keywords returned by the algorithm, the default is 20", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "Corpus", + "example": "1", + "detail": "Select a corpus in a specific field, the default is 0[General], 1[Finance], 2[Medical]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_CLOSE", + "t": "5", + "d": "According to the stock code and date, return the corresponding stock closing price of A shares.", + "a": "Returns the closing price of stock.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_OPEN", + "t": "5", + "d": "According to the stock code and date, return the opening price of stock.", + "a": "Return the opening price of a shares.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_MAX", + "t": "5", + "d": "According to the stock code and date, return the highest price of stock.", + "a": "Return the highest price of stock.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_MIN", + "t": "5", + "d": "According to the stock code and date, return the lowest price of stock.", + "a": "Returns the lowest price of stock.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_VOLUMN", + "t": "5", + "d": "According to the stock code and date, return the corresponding stock trading volume of A shares.", + "a": "Returns the corresponding stock trading volume of A shares.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "DATA_CN_STOCK_AMOUNT", + "t": "5", + "d": "According to the stock code and date, return the corresponding stock turnover of A shares.", + "a": "Returns the corresponding stock turnover of A shares.", + "m": [1, 3], + "p": [{ + "name": "Stock code", + "example": "\"000001\"", + "detail": "6-digit stock code, required.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Date", + "example": "2015-01-08", + "detail": "The trading day of the stock, the default is the latest trading day", + "require": "o", + "repeat": "n", + "type": "rangedate" + }, { + "name": "Reversion and exclusion", + "example": "0", + "detail": "Select the ex right restoration type of the stock, default to 0 [former reversion], 1 [original price], 2 [post reversion]", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "ISDATE", + "t": "6", + "d": "Returns whether a value is a date.", + "a": "Whether a value is a date.", + "m": [1, 1], + "p": [{ + "name": "value", + "example": "\"1990-01-01\"", + "detail": "The value to be verified as a date.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "LINESPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell to describe the continuous trend of data", + "a": "Generate sparklines line chart", + "m": [1, 8], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Line color", + "example": "#2ec7c9", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #2ec7c9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Line thickness", + "example": "1", + "detail": "Line thickness of the line graph, the default is 1px", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Auxiliary line", + "example": "avg", + "detail": "A horizontal line, which can be min, max, avg, median, range or custom value, default 0 none", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Auxiliary line color", + "example": "#000", + "detail": "Color setting of auxiliary line, same as line color configuration, default #000", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Maximum mark", + "example": "#fc5c5c", + "detail": "Identifies the maximum value of the line graph, the same line color configuration, default 0 does not display", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Minimum mark", + "example": "#fc5c5c", + "detail": "Identify the minimum value of the line graph, the same line color configuration, default 0 does not display", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Mark size", + "example": "1.5", + "detail": "The maximum and minimum mark size settings, the default is 1.5", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "AREASPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell area chart, generally used to describe the continuous cumulative value trend of the data", + "a": "Generate sparklines area chart", + "m": [1, 5], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Line color", + "example": "#2ec7c9", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #2ec7c9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Fill color", + "example": "#CCF3F4", + "detail": "Form an area chart, the same line color configuration, default 0 does not display", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Line thickness", + "example": "1", + "detail": "Line thickness of the line graph, the default is 1px", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Auxiliary line", + "example": "avg", + "detail": "A horizontal line, which can be min, max, avg, median, range or custom value, default 0 none", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Auxiliary line color", + "example": "#000", + "detail": "Color setting of auxiliary line, same as line color configuration, default #000", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "COLUMNSPLINES", + "t": "3", + "d": "Generate sparklines embedded in the vertical histogram of cells, generally used to describe the size of discrete data", + "a": "Generate sparklines vertical histogram", + "m": [1, 6], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar interval", + "example": "1", + "detail": "The distance between bars, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar color", + "example": "#fc5c5c", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #fc5c5c", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Negative bar color", + "example": "#97b552", + "detail": "Negative bar color setting, representing the color of negative value, same as the bar color configuration, default #97b552", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Max", + "example": "100", + "detail": "The maximum value of the bar chart, used to standardize the length of the bar chart, the default is to automatically calculate false, auto, null", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color palette can set the color of each bar individually, multiple settings can be set, and two formats are supported: 1 color such as #000, which means that the color of the first bar is black; 2 value range: color, such as -2:# 000 indicates that the bar with a value of -2 is black, 0:5:#000 indicates that the bar with a value of 0-5 is black, and the default is empty", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "STACKCOLUMNSPLINES", + "t": "3", + "d": "Generate sparklines, a cumulative vertical histogram embedded in a cell, generally used to describe the numerical size of multiple dimensions of discrete data", + "a": "Generate sparklines cumulative vertical histogram", + "m": [1, 5], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Stack by column", + "example": "1", + "detail": "If you need to stack by row, set this item to false or 0, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar interval", + "example": "1", + "detail": "The distance between bars, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Max", + "example": "100", + "detail": "The maximum value of the cumulative bar, used to regulate the length of the bar, the default is to automatically calculate false, auto, null", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color palette can individually set the bar color of each dimension, which can be set to the range of A1:A10, etc. The default is #2ec7c9, #fc5c5c, #5ab1ef, #ffb980...", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "BARSPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell, generally used to describe the size of discrete data", + "a": "Generate sparklines horizontal bar graph", + "m": [1, 6], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar interval", + "example": "1", + "detail": "The distance between bars, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar color", + "example": "#fc5c5c", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #fc5c5c", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Negative bar color", + "example": "#97b552", + "detail": "Negative bar color setting, representing the color of negative value, same as the bar color configuration, default #97b552", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Max", + "example": "100", + "detail": "The maximum value of the bar chart, used to standardize the length of the bar chart, the default is to automatically calculate false, auto, null", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color palette can set the color of each bar individually, multiple settings can be set, and two formats are supported: 1 color such as #000, which means that the color of the first bar is black; 2 value range: color, such as -2:# 000 indicates that the bar with a value of -2 is black, 0:5:#000 indicates that the bar with a value of 0-5 is black, and the default is empty", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "STACKBARSPLINES", + "t": "3", + "d": "Generate sparklines, a cumulative horizontal bar graph embedded in a cell, which is generally used to describe the numerical size of multiple dimensions of discrete data", + "a": "Generate sparklines cumulative horizontal bar graph", + "m": [1, 5], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Stack by column", + "example": "1", + "detail": "If you need to stack by row, set this item to false or 0, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar interval", + "example": "1", + "detail": "The distance between bars, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Max", + "example": "100", + "detail": "The maximum value of the cumulative bar, used to regulate the length of the bar, the default is to automatically calculate false, auto, null", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color palette can individually set the bar color of each dimension, which can be set to the range of A1:A10, etc. The default is #2ec7c9, #fc5c5c, #5ab1ef, #ffb980...", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "DISCRETESPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell, generally used to describe the trend of discrete data", + "a": "Generate sparklines discrete graph", + "m": [1, 4], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Segmentation threshold", + "example": "1", + "detail": "Discrete graph column color distinction, for example: if the value is 0, blue is greater than 0, red is less than 0, and the default is 0", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Above threshold color", + "example": "#2ec7c9", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #2ec7c9", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Below threshold color", + "example": "#fc5c5c", + "detail": "The color setting of the bar below the threshold, the same as the color above the threshold, default #fc5c5c", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "TRISTATESPLINES", + "t": "3", + "d": "Generate sparklines, a three-state graph embedded in the cell, which is generally used to describe the trend of three situations, such as winning, losing, or drawing.", + "a": "Generate sparklines three-state graph", + "m": [1, 6], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar interval", + "example": "1", + "detail": "The distance between bars, the default is 1", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Bar color", + "example": "#fc5c5c", + "detail": "The line color of the line graph can be range A1, color table index value or specific color value. Set it to 0 or false to not display it. It supports regx, rgb, rgba, etc. Default #fc5c5c", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Negative bar color", + "example": "#97b552", + "detail": "Negative bar color setting, representing the color of negative value, same as the bar color configuration, default #97b552", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Zero value bar color", + "example": "#999", + "detail": "Zero value bar color setting, representing 0 value color, the same color configuration of the bar, default #999", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color palette can set the color of each bar individually, multiple settings can be set, and two formats are supported: 1 color such as #000, which means that the color of the first bar is black; 2 value range: color, such as -2:# 000 indicates that the bar with a value of -2 is black, 0:5:#000 indicates that the bar with a value of 0-5 is black, and the default is empty", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "PIESPLINES", + "t": "3", + "d": "Generate sparklines pie chart embedded in the cell, generally used to describe the proportion of data", + "a": "Generate sparklines pie chart", + "m": [1, 5], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Rotation angle", + "example": "0", + "detail": "The rotation angle of the pie chart, the default is 0", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "border", + "example": "0", + "detail": "Pie chart border size, default is none 0", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Border color", + "example": "#000", + "detail": "The border color of the pie chart, the default is #000", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Color palette", + "example": "#97b552", + "detail": "The color of the slice can be set in the palette, which can be set to the range of A1:A10, etc. The default is #2ec7c9, #fc5c5c, #5ab1ef, #ffb980...", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "BOXSPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell box plot, generally used to describe the statistical distribution of the data set", + "a": "Generate sparklines box plot", + "m": [1, 4], + "p": [{ + "name": "Range", + "example": "A1:A20", + "detail": "Range,Values can be calculated effectively, such as A1:A20, {1,2,3,4,5}, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Outlier ratio", + "example": "1.5", + "detail": "The threshold range of outliers, if it is 0 or false, it will not be displayed, the default is 1.5 times", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Target value", + "example": "10", + "detail": "The target value setting on the box plot, the default is false and does not display", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Point size", + "example": "1.5", + "detail": "The radius of the target point and outlier is set, the default is 1.5", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "BULLETSPLINES", + "t": "3", + "d": "Generate sparklines embedded in the cell, generally used to describe the task achievement rate", + "a": "Generating sparklines bullets", + "m": [2, 3], + "p": [{ + "name": "Target", + "example": "10", + "detail": "The numerical value can be calculated effectively for the achieved target value, such as A1, 100, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "achieved", + "example": "8", + "detail": "Only when the value is completed can the value be calculated effectively, such as A1, 100, etc.", + "require": "m", + "repeat": "n", + "type": "rangeall" + }, { + "name": "Contrast", + "example": "12", + "detail": "Comparative values, such as excess, minimum, and bottom line for awards, can be effectively calculated, such as A1, 100, etc. You can set up to 9 comparison values", + "require": "o", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "COMPOSESPLINES", + "t": "3", + "d": "Support multiple types of pictures in the same cell, each parameter represents a sparklines diagram", + "a": "Combine sparklines graphs into one cell", + "m": [1, 1], + "p": [{ + "name": "config", + "example": "PIESPLINES(A1:A20)", + "detail": "Sparklines chart settings, such as A1:A20, a completed pie chart, line chart settings, etc.", + "require": "m", + "repeat": "y", + "type": "rangeall" + }] +}, { + "n": "SORT", + "t": "14", + "d": "Sorts the rows of a given array or range by the values in one or more columns.", + "a": "Sorts rows of range by specified column.", + "m": [1, 4], + "p": [{ + "name": "range", + "detail": "The data to be sorted.", + "example": "A2:A17", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "sort_column", + "detail": "The index of the column in `range` or a range outside of `range` containing the values by which to sort.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "is_ascending", + "detail": "`TRUE` or `FALSE` indicating whether to sort `sort_column` in ascending order. `FALSE` sorts in descending order.", + "example": "-1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "sort_column2", + "detail": "Additional columns.", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "FILTER", + "t": "14", + "d": "Returns a filtered version of the source range, returning only rows or columns which meet the specified conditions.", + "a": "Filters a range based off provided conditions.", + "m": [2, 3], + "p": [{ + "name": "range", + "detail": "The data to be filtered.", + "example": "A5:D20", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "condition1", + "detail": "A column or row containing true or false values corresponding to the first column or row of `range`, or an array formula evaluating to true or false.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "range" + }, { + "name": "condition2", + "detail": "Additional rows or columns containing boolean values `TRUE` or `FALSE` indicating whether the corresponding row or column in `range` should pass through `FILTER`. Can also contain array formula expressions which evaluate to such rows or columns. All conditions must be of the same type (row or column). Mixing row conditions and column conditions is not permitted.", + "example": "\"\"", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "UNIQUE", + "t": "14", + "d": "Returns unique rows in the provided source range, discarding duplicates. Rows are returned in the order in which they first appear in the source range.", + "a": "Unique rows in the provided source range.", + "m": [1, 3], + "p": [{ + "name": "range", + "detail": "The data to filter by unique entries.", + "example": "A2:B26", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "by_col", + "detail": "[Option] - Logical value, indicating how to compare; by row = FALSE() or omitted; by column = TRUE().", + "example": "TRUE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }, { + "name": "occurs_once", + "detail": "[Option] - Logical value, only one occurrence in the unique value is returned = TRUE(); including all unique values = FALSE() or omitted.", + "example": "FALSE()", + "require": "o", + "repeat": "n", + "type": "rangeall" + }] +}, { + "n": "RANDARRAY", + "t": "14", + "d": "Returns a grid of random numbers between 0 inclusive and 1 exclusive. The grid size will match the provided rows and columns arguments. If neither rows nor columns are provided, then the grid will be size 1 x 1.", + "a": "Returns a grid of random numbers.", + "m": [0, 2], + "p": [{ + "name": "rows", + "detail": "The number of rows to populate with a random number.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "columns", + "detail": "The number of columns to populate with a random number.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}, { + "n": "SEQUENCE", + "t": "14", + "d": "Returns a grid of sequential numbers starting at a specified start value and increasing by a specified step size. By default, the sequence starts at and increases by 1.", + "a": "Returns a grid of sequential numbers.", + "m": [1, 4], + "p": [{ + "name": "rows", + "detail": "The number of rows in the function's resulting grid.", + "example": "1", + "require": "m", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "columns", + "detail": "The number of columns in the function's resulting grid. If omitted, the result grid will have 1 column.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "start", + "detail": "The number, at which to start the sequence. If omitted, the sequence will start at 1.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }, { + "name": "step", + "detail": "The amount each value in the sequence will differ by. If omitted, each value will differ by 1.", + "example": "1", + "require": "o", + "repeat": "n", + "type": "rangenumber" + }] +}] + +const functionlist = function(){ + + // internationalization,get function list + let functionListOrigin = Store.lang === 'zh' ? functionlist_zh : functionlist_en; + + // add new property f + for (let i = 0; i < functionListOrigin.length; i++) { + let func = functionListOrigin[i]; + func.f = functionImplementation[func.n]; + } + + Store.functionlist = functionListOrigin; + + // get n property + const luckysheet_function = {}; + + for (let i = 0; i < functionListOrigin.length; i++) { + let func = functionListOrigin[i]; + luckysheet_function[func.n] = func; + } + + window.luckysheet_function = luckysheet_function; //Mount window for eval() calculation formula + + Store.luckysheet_function = luckysheet_function; } export default functionlist; \ No newline at end of file diff --git a/src/global/count.js b/src/global/count.js index adc75c249..e6447018a 100644 --- a/src/global/count.js +++ b/src/global/count.js @@ -2,6 +2,7 @@ import Store from '../store'; import { getdatabyselectionNoCopy } from './getdata'; import { isRealNull, isRealNum } from './validate'; import { update } from './format'; +import locale from '../locale/locale'; //表格计数栏 export function countfunc() { @@ -51,21 +52,23 @@ export function countfunc() { } } + let locale_formula = locale().formula; + let ret = ""; - ret += "计数:" + count + ""; + ret += ""+locale_formula.count+":" + count + ""; //处理成亿万格式 if (isFinite(max) || isFinite(min)) { - ret += "求和:" + update("w", sum) + ""; - ret += "平均值:" + update("w", Math.round(sum / count * 10000) / 10000) + ""; + ret += ""+locale_formula.sum+":" + update("w", sum) + ""; + ret += ""+locale_formula.average+":" + update("w", Math.round(sum / count * 10000) / 10000) + ""; } if (isFinite(max)) { - ret += "最大值:" + update("w", max) + ""; + ret += ""+locale_formula.max+":" + update("w", max) + ""; } if (isFinite(min)) { - ret += "最小值:" + update("w", min) + ""; + ret += ""+locale_formula.min+":" + update("w", min) + ""; } $("#luckysheet-sta-content").html(ret); diff --git a/src/global/createdom.js b/src/global/createdom.js index 646352f61..a6039653b 100644 --- a/src/global/createdom.js +++ b/src/global/createdom.js @@ -18,6 +18,7 @@ import editor from './editor'; import rhchInit from './rhchInit'; import { replaceHtml } from '../utils/util'; import Store from '../store'; +import locale from '../locale/locale'; export default function luckysheetcreatedom(colwidth, rowheight, data, menu, title) { //最少30行 @@ -30,7 +31,7 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit colwidth = 22; } - let gh = gridHTML; + let gh = gridHTML(); gh = replaceHtml(gh, { "logotitle": title });//设置title gh = replaceHtml(gh, { "menu": menuToolBar() });//设置需要显示的菜单 @@ -59,11 +60,19 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit rhchInit(rowheight, colwidth); - let addControll = '(在底部添加)'; - let backControll = ' '; + const _locale = locale(); + const locale_info = _locale.info; + + let addControll = ''+ locale_info.row +'('+locale_info.addLast+')'; + let backControll = ' '; // let pageControll = ' 共'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页,每页'+ luckysheetConfigsetting.pageInfo.pageSize +'条 '; - let pageControll = ' 共'+ luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页 '; - let pageControll2 = ' 共'+ luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页'; + let pageInfo = replaceHtml(locale_info.pageInfo,{ + total:luckysheetConfigsetting.total?luckysheetConfigsetting.total:"", + totalPage:luckysheetConfigsetting.pageInfo.totalPage?luckysheetConfigsetting.pageInfo.totalPage:"", + currentPage:luckysheetConfigsetting.pageInfo.currentPage?luckysheetConfigsetting.pageInfo.currentPage:"", + }); + let pageControll = ' '+ pageInfo +' '; + let pageControll2 = ' '+pageInfo+''; let bottomControll = ""; if(luckysheetConfigsetting.enableAddRow){ diff --git a/src/global/draw.js b/src/global/draw.js index 704366a04..6ebbc9b67 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -400,40 +400,6 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of let end_c = Store.visibledatacolumn[c] - scrollWidth; - //横线 - if(c == dataset_col_ed && !Store.luckysheetcurrentisPivotTable){ - luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo( - Store.devicePixelRatio * (offsetLeft - 1), - Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) - ); - luckysheetTableContent.lineTo( - Store.devicePixelRatio * (fill_col_ed - scrollWidth + offsetLeft - 2), - Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) - ); - luckysheetTableContent.lineWidth = Store.devicePixelRatio; - luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; - luckysheetTableContent.closePath(); - luckysheetTableContent.stroke(); - } - - //竖线 - if(r == dataset_row_st && !Store.luckysheetcurrentisPivotTable){ - luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo( - Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), - Store.devicePixelRatio * (offsetTop - 1) - ); - luckysheetTableContent.lineTo( - Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), - Store.devicePixelRatio * (fill_row_ed - scrollHeight + offsetTop - 2) - ); - luckysheetTableContent.lineWidth = Store.devicePixelRatio; - luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; - luckysheetTableContent.closePath(); - luckysheetTableContent.stroke(); - } - //数据透视表 if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) { if ((c == 0 || c == 5) && r <= 11) { @@ -708,8 +674,14 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of //右边框 luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (start_r + offsetTop)); - luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + offsetTop)); + luckysheetTableContent.moveTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), + Store.devicePixelRatio * (start_r + offsetTop - 2) + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), + Store.devicePixelRatio * (end_r + offsetTop - 2) + ); luckysheetTableContent.lineWidth = Store.devicePixelRatio; if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { @@ -724,8 +696,14 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of //下边框 luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo(Store.devicePixelRatio * (start_c - 2 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); - luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 2), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); + luckysheetTableContent.moveTo( + Store.devicePixelRatio * (start_c + offsetLeft - 2), + Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2), + Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) + ); luckysheetTableContent.lineWidth = Store.devicePixelRatio; if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { @@ -742,647 +720,1227 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of //非空白单元格渲染 let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, canvasType){ let cell = Store.flowdata[r][c]; - let cellWidth = end_c - start_c; - let cellHeight = end_r - start_r; - - //取渲染单元格大小离屏canvas - let offlinecanvasElement = offlinecanvasElement_cache[cellWidth + '_' + cellHeight]; - if(offlinecanvasElement == null){ - offlinecanvasElement = document.createElement('canvas'); - offlinecanvasElement.width = cellWidth * Store.devicePixelRatio; - offlinecanvasElement.height = cellHeight * Store.devicePixelRatio; - offlinecanvasElement_cache[cellWidth + '_' + cellHeight] = offlinecanvasElement; - } - let offlinecanvas = offlinecanvasElement.getContext("2d"); - - offlinecanvas.clearRect( - 0, - 0, - cellWidth * Store.devicePixelRatio, - cellHeight * Store.devicePixelRatio - ) + let cellWidth = end_c - start_c - 2; + let cellHeight = end_r - start_r - 2; + let space_width = 2, space_height = 2; //宽高方向 间隙 let fontset = luckysheetfontformat(cell); - offlinecanvas.font = fontset; - - //文本宽度和高度 + luckysheetTableContent.font = fontset; + + //文本计算 宽度和高度 + let cellValueSize = getCellValueSize(cell, value, luckysheetTableContent, cellWidth, cellHeight, space_width, space_height); + + //水平对齐 + let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c, "ht"); + //垂直对齐 + let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c, "vt"); + + //文本单行 宽度和高度 let measureText = luckysheetTableContent.measureText(value); let textMetrics = measureText.width; let oneLineTextHeight = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent; - + //交替颜色 let checksAF = alternateformat.checksAF(r, c, af_compute); //条件格式 let checksCF = conditionformat.checksCF(r, c, cf_compute); //单元格 背景颜色 - offlinecanvas.fillStyle = menuButton.checkstatus(Store.flowdata, r, c, "bg"); - - //若单元格有交替颜色 背景颜色 - if(checksAF != null && checksAF[1] != null){ - offlinecanvas.fillStyle = checksAF[1]; + luckysheetTableContent.fillStyle = menuButton.checkstatus(Store.flowdata, r, c, "bg"); + if(checksAF != null && checksAF[1] != null){ //若单元格有交替颜色 背景颜色 + luckysheetTableContent.fillStyle = checksAF[1]; } - //若单元格有条件格式 背景颜色 - if(checksCF != null && checksCF["cellColor"] != null){ - offlinecanvas.fillStyle = checksCF["cellColor"]; + if(checksCF != null && checksCF["cellColor"] != null){ //若单元格有条件格式 背景颜色 + luckysheetTableContent.fillStyle = checksCF["cellColor"]; } - - offlinecanvas.fillRect( - 0, - 0, - cellWidth * Store.devicePixelRatio, - cellHeight * Store.devicePixelRatio + luckysheetTableContent.fillRect( + (start_c + offsetLeft - 1) * Store.devicePixelRatio, + (start_r + offsetTop) * Store.devicePixelRatio, + (end_c - start_c + 2) * Store.devicePixelRatio, + (end_r - start_r + 1) * Store.devicePixelRatio ) - //若单元格有批注(单元格右上角红色小三角标示) - if(cell.ps != null){ - let ps_w = 5, ps_h = 5; //红色小三角宽高 + // 非Safari浏览器 + //(canvasType为offline) + //(水平对齐方式为居中或右对齐 且 文本宽度大于单元格宽度) + //(文本高度大于单元格高度) + // 走离屏canvas方法 + if(browser.BrowserType() != "Safari" && ( canvasType == "offline" || ( (horizonAlign == "0" || horizonAlign == "2") && cellWidth < cellValueSize.width ) || cellHeight < cellValueSize.height )){ + //取渲染单元格大小离屏canvas + let offlinecanvasElement = offlinecanvasElement_cache[cellWidth + '_' + cellHeight]; + if(offlinecanvasElement == null){ + offlinecanvasElement = document.createElement('canvas'); + offlinecanvasElement.width = cellWidth * Store.devicePixelRatio; + offlinecanvasElement.height = cellHeight * Store.devicePixelRatio; + offlinecanvasElement_cache[cellWidth + '_' + cellHeight] = offlinecanvasElement; + } + let offlinecanvas = offlinecanvasElement.getContext("2d"); - offlinecanvas.beginPath(); - offlinecanvas.moveTo( - Store.devicePixelRatio * (cellWidth - ps_w), - 0 - ); - offlinecanvas.lineTo( - Store.devicePixelRatio * cellWidth, - 0 - ); - offlinecanvas.lineTo( - Store.devicePixelRatio * cellWidth, - Store.devicePixelRatio * ps_h + offlinecanvas.clearRect( + 0, + 0, + cellWidth * Store.devicePixelRatio, + cellHeight * Store.devicePixelRatio ); - offlinecanvas.fillStyle = "#FC6666"; - offlinecanvas.fill(); - offlinecanvas.closePath(); - } - - let space_width = 2, space_height = 2; //宽高方向 间隙 - - //若单元格有条件格式数据条 - if(checksCF != null && checksCF["dataBar"] != null){ - let x = Store.devicePixelRatio * space_width; - let y = Store.devicePixelRatio * space_height; - let w = Store.devicePixelRatio * (cellWidth - space_width * 2); - let h = Store.devicePixelRatio * (cellHeight - space_height * 2); + offlinecanvas.font = fontset; - let valueType = checksCF["dataBar"]["valueType"]; - let valueLen = checksCF["dataBar"]["valueLen"]; - let format = checksCF["dataBar"]["format"]; - - if(valueType == 'minus'){ - //负数 - let minusLen = checksCF["dataBar"]["minusLen"]; - - if(format.length > 1){ - //渐变 - let my_gradient = offlinecanvas.createLinearGradient( - x + w * minusLen * (1 - valueLen), - y, - x + w * minusLen, - y - ); - my_gradient.addColorStop(0, "#ffffff"); - my_gradient.addColorStop(1, "#ff0000"); - - offlinecanvas.fillStyle = my_gradient; - } - else{ - //单色 - offlinecanvas.fillStyle = "#ff0000"; - } - - offlinecanvas.fillRect( - x + w * minusLen * (1 - valueLen), - y, - w * minusLen * valueLen, - h - ); + //若单元格有批注(单元格右上角红色小三角标示) + if(cell.ps != null){ + let ps_w = 5, ps_h = 5; //红色小三角宽高 offlinecanvas.beginPath(); offlinecanvas.moveTo( - x + w * minusLen * (1 - valueLen), - y - ); - offlinecanvas.lineTo( - x + w * minusLen * (1 - valueLen), - y + h - ); - offlinecanvas.lineTo( - x + w * minusLen, - y + h + Store.devicePixelRatio * (cellWidth - ps_w), + 0 ); offlinecanvas.lineTo( - x + w * minusLen, - y + Store.devicePixelRatio * cellWidth, + 0 ); offlinecanvas.lineTo( - x + w * minusLen * (1 - valueLen), - y + Store.devicePixelRatio * cellWidth, + Store.devicePixelRatio * ps_h ); - offlinecanvas.lineWidth = Store.devicePixelRatio; - offlinecanvas.strokeStyle = "#ff0000"; - offlinecanvas.stroke(); + offlinecanvas.fillStyle = "#FC6666"; + offlinecanvas.fill(); offlinecanvas.closePath(); } - else if(valueType == 'plus'){ - //正数 - let plusLen = checksCF["dataBar"]["plusLen"]; - if(plusLen == 1){ + //若单元格有条件格式数据条 + if(checksCF != null && checksCF["dataBar"] != null){ + let x = Store.devicePixelRatio * space_width; + let y = Store.devicePixelRatio * space_height; + let w = Store.devicePixelRatio * (cellWidth - space_width * 2); + let h = Store.devicePixelRatio * (cellHeight - space_height * 2); + + let valueType = checksCF["dataBar"]["valueType"]; + let valueLen = checksCF["dataBar"]["valueLen"]; + let format = checksCF["dataBar"]["format"]; + + if(valueType == 'minus'){ + //负数 + let minusLen = checksCF["dataBar"]["minusLen"]; + if(format.length > 1){ //渐变 let my_gradient = offlinecanvas.createLinearGradient( - x, + x + w * minusLen * (1 - valueLen), y, - x + w * valueLen, + x + w * minusLen, y ); - my_gradient.addColorStop(0, format[0]); - my_gradient.addColorStop(1, format[1]); - + my_gradient.addColorStop(0, "#ffffff"); + my_gradient.addColorStop(1, "#ff0000"); + offlinecanvas.fillStyle = my_gradient; } else{ //单色 - offlinecanvas.fillStyle = format[0]; + offlinecanvas.fillStyle = "#ff0000"; } offlinecanvas.fillRect( - x, + x + w * minusLen * (1 - valueLen), y, - w * valueLen, + w * minusLen * valueLen, h ); offlinecanvas.beginPath(); offlinecanvas.moveTo( - x, + x + w * minusLen * (1 - valueLen), y ); offlinecanvas.lineTo( - x, + x + w * minusLen * (1 - valueLen), y + h ); offlinecanvas.lineTo( - x + w * valueLen, + x + w * minusLen, y + h ); offlinecanvas.lineTo( - x + w * valueLen, + x + w * minusLen, y ); offlinecanvas.lineTo( - x, + x + w * minusLen * (1 - valueLen), y ); offlinecanvas.lineWidth = Store.devicePixelRatio; - offlinecanvas.strokeStyle = format[0]; + offlinecanvas.strokeStyle = "#ff0000"; offlinecanvas.stroke(); offlinecanvas.closePath(); } - else{ - let minusLen = checksCF["dataBar"]["minusLen"]; + else if(valueType == 'plus'){ + //正数 + let plusLen = checksCF["dataBar"]["plusLen"]; + + if(plusLen == 1){ + if(format.length > 1){ + //渐变 + let my_gradient = offlinecanvas.createLinearGradient( + x, + y, + x + w * valueLen, + y + ); + my_gradient.addColorStop(0, format[0]); + my_gradient.addColorStop(1, format[1]); + + offlinecanvas.fillStyle = my_gradient; + } + else{ + //单色 + offlinecanvas.fillStyle = format[0]; + } + + offlinecanvas.fillRect( + x, + y, + w * valueLen, + h + ); - if(format.length > 1){ - //渐变 - let my_gradient = offlinecanvas.createLinearGradient( + offlinecanvas.beginPath(); + offlinecanvas.moveTo( + x, + y + ); + offlinecanvas.lineTo( + x, + y + h + ); + offlinecanvas.lineTo( + x + w * valueLen, + y + h + ); + offlinecanvas.lineTo( + x + w * valueLen, + y + ); + offlinecanvas.lineTo( + x, + y + ); + offlinecanvas.lineWidth = Store.devicePixelRatio; + offlinecanvas.strokeStyle = format[0]; + offlinecanvas.stroke(); + offlinecanvas.closePath(); + } + else{ + let minusLen = checksCF["dataBar"]["minusLen"]; + + if(format.length > 1){ + //渐变 + let my_gradient = offlinecanvas.createLinearGradient( + x + w * minusLen, + y, + x + w * minusLen + w * plusLen * valueLen, + y + ); + my_gradient.addColorStop(0, format[0]); + my_gradient.addColorStop(1, format[1]); + + offlinecanvas.fillStyle = my_gradient; + } + else{ + //单色 + offlinecanvas.fillStyle = format[0]; + } + + offlinecanvas.fillRect( x + w * minusLen, y, + w * plusLen * valueLen, + h + ); + + offlinecanvas.beginPath(); + offlinecanvas.moveTo( + x + w * minusLen, + y + ); + offlinecanvas.lineTo( + x + w * minusLen, + y + h + ); + offlinecanvas.lineTo( + x + w * minusLen + w * plusLen * valueLen, + y + h + ); + offlinecanvas.lineTo( x + w * minusLen + w * plusLen * valueLen, y ); - my_gradient.addColorStop(0, format[0]); - my_gradient.addColorStop(1, format[1]); - - offlinecanvas.fillStyle = my_gradient; - } - else{ - //单色 - offlinecanvas.fillStyle = format[0]; + offlinecanvas.lineTo( + x + w * minusLen, + y + ); + offlinecanvas.lineWidth = Store.devicePixelRatio; + offlinecanvas.strokeStyle = format[0]; + offlinecanvas.stroke(); + offlinecanvas.closePath(); } - - offlinecanvas.fillRect( - x + w * minusLen, - y, - w * plusLen * valueLen, - h - ); - - offlinecanvas.beginPath(); - offlinecanvas.moveTo( - x + w * minusLen, - y - ); - offlinecanvas.lineTo( - x + w * minusLen, - y + h - ); - offlinecanvas.lineTo( - x + w * minusLen + w * plusLen * valueLen, - y + h - ); - offlinecanvas.lineTo( - x + w * minusLen + w * plusLen * valueLen, - y - ); - offlinecanvas.lineTo( - x + w * minusLen, - y - ); - offlinecanvas.lineWidth = Store.devicePixelRatio; - offlinecanvas.strokeStyle = format[0]; - offlinecanvas.stroke(); - offlinecanvas.closePath(); } } - } - - //水平对齐 - let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c, "ht"); - let horizonAlignPos = space_width * Store.devicePixelRatio; //默认为1,左对齐 - if(horizonAlign == "0"){ //居中对齐 - horizonAlignPos = (cellWidth / 2) * Store.devicePixelRatio - (textMetrics / 2); - } - else if(horizonAlign == "2"){ //右对齐 - horizonAlignPos = (cellWidth - space_width) * Store.devicePixelRatio - textMetrics; - } - //垂直对齐 - let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c, "vt"); - let verticalAlignPos = (cellHeight - space_height) * Store.devicePixelRatio - oneLineTextHeight; //默认为2,下对齐 - - let verticalAlignPos_text = (cellHeight - space_height) * Store.devicePixelRatio; //文本垂直方向基准线 - offlinecanvas.textBaseline = "bottom"; - - if(verticalAlign == "0"){ //居中对齐 - verticalAlignPos = (cellHeight / 2) * Store.devicePixelRatio - (oneLineTextHeight / 2); - - verticalAlignPos_text = (cellHeight / 2) * Store.devicePixelRatio; - offlinecanvas.textBaseline = "middle"; - } - else if(verticalAlign == "1"){ //上对齐 - verticalAlignPos = space_height * Store.devicePixelRatio; + let horizonAlignPos = space_width * Store.devicePixelRatio; //默认为1,左对齐 + if(horizonAlign == "0"){ //居中对齐 + horizonAlignPos = (cellWidth / 2) * Store.devicePixelRatio - (textMetrics / 2); + } + else if(horizonAlign == "2"){ //右对齐 + horizonAlignPos = (cellWidth - space_width) * Store.devicePixelRatio - textMetrics; + } - verticalAlignPos_text = space_height * Store.devicePixelRatio; - offlinecanvas.textBaseline = "top"; - } - - //若单元格有条件格式图标集 - if(checksCF != null && checksCF["icons"] != null){ - let l = checksCF["icons"]["left"]; - let t = checksCF["icons"]["top"]; + let verticalAlignPos = (cellHeight - space_height) * Store.devicePixelRatio - oneLineTextHeight; //默认为2,下对齐 + let verticalAlignPos_text = (cellHeight - space_height) * Store.devicePixelRatio; //文本垂直方向基准线 + offlinecanvas.textBaseline = "bottom"; + if(verticalAlign == "0"){ //居中对齐 + verticalAlignPos = (cellHeight / 2) * Store.devicePixelRatio - (oneLineTextHeight / 2); + + verticalAlignPos_text = (cellHeight / 2) * Store.devicePixelRatio; + offlinecanvas.textBaseline = "middle"; + } + else if(verticalAlign == "1"){ //上对齐 + verticalAlignPos = space_height * Store.devicePixelRatio; + + verticalAlignPos_text = space_height * Store.devicePixelRatio; + offlinecanvas.textBaseline = "top"; + } + + //若单元格有条件格式图标集 + if(checksCF != null && checksCF["icons"] != null){ + let l = checksCF["icons"]["left"]; + let t = checksCF["icons"]["top"]; + + offlinecanvas.drawImage( + luckysheet_CFiconsImg, + l * 42, + t * 32, + 32, + 32, + 0, + verticalAlignPos, + oneLineTextHeight, + oneLineTextHeight + ); + + if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离 + horizonAlignPos = horizonAlignPos + oneLineTextHeight; + } + } - offlinecanvas.drawImage( - luckysheet_CFiconsImg, - l * 42, - t * 32, - 32, - 32, - 0, - verticalAlignPos, - oneLineTextHeight, - oneLineTextHeight - ); + //单元格 文本颜色 + offlinecanvas.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "fc"); - if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离 - horizonAlignPos = horizonAlignPos + oneLineTextHeight; + //若单元格有交替颜色 文本颜色 + if(checksAF != null && checksAF[0] != null){ + offlinecanvas.fillStyle = checksAF[0]; + } + //若单元格有条件格式 文本颜色 + if(checksCF != null && checksCF["textColor"] != null){ + offlinecanvas.fillStyle = checksCF["textColor"]; } - } - - //单元格 文本颜色 - offlinecanvas.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "fc"); - - //若单元格有交替颜色 文本颜色 - if(checksAF != null && checksAF[0] != null){ - offlinecanvas.fillStyle = checksAF[0]; - } - //若单元格有条件格式 文本颜色 - if(checksCF != null && checksCF["textColor"] != null){ - offlinecanvas.fillStyle = checksCF["textColor"]; - } - //单元格是否有删除线 - let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); + //单元格是否有删除线 + let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); - if(cell.tb == '2'){ - //自动换行 - offlinecanvas.textBaseline = 'top'; //textBaseline以top计算 - - let strArr = [];//文本截断数组 - strArr = getCellTextSplitArr(value.toString(), strArr, cellWidth - space_width * 2, offlinecanvas); + if(cell.tb == '2'){ + //自动换行 + offlinecanvas.textBaseline = 'top'; //textBaseline以top计算 + + let strArr = [];//文本截断数组 + strArr = getCellTextSplitArr(value.toString(), strArr, cellWidth - space_width * 2, offlinecanvas); - for(let i = 0; i < strArr.length; i++){ - let strV = strArr[i]; + for(let i = 0; i < strArr.length; i++){ + let strV = strArr[i]; - let strWidth = offlinecanvas.measureText(strV).width; - let strHeight = oneLineTextHeight; + let strWidth = offlinecanvas.measureText(strV).width; + let strHeight = oneLineTextHeight; - //水平对齐计算 - if(horizonAlign == "0"){ - horizonAlignPos = (cellWidth / 2) * Store.devicePixelRatio - (strWidth / 2); - } - else if(horizonAlign == "2"){ - horizonAlignPos = (cellWidth - space_width) * Store.devicePixelRatio - strWidth; - } - else{ - horizonAlignPos = space_width * Store.devicePixelRatio; - } - - //垂直对齐计算 - if(verticalAlign == "0"){ - verticalAlignPos = (cellHeight / 2) * Store.devicePixelRatio - (strHeight / 2) * strArr.length; - } - else if(verticalAlign == "1"){ - verticalAlignPos = space_height * Store.devicePixelRatio; - } - else{ - verticalAlignPos = (cellHeight - space_height) * Store.devicePixelRatio - strHeight * strArr.length; - } + //水平对齐计算 + if(horizonAlign == "0"){ + horizonAlignPos = (cellWidth / 2) * Store.devicePixelRatio - (strWidth / 2); + } + else if(horizonAlign == "2"){ + horizonAlignPos = (cellWidth - space_width) * Store.devicePixelRatio - strWidth; + } + else{ + horizonAlignPos = space_width * Store.devicePixelRatio; + } + + //垂直对齐计算 + if(verticalAlign == "0"){ + verticalAlignPos = (cellHeight / 2) * Store.devicePixelRatio - (strHeight / 2) * strArr.length; + } + else if(verticalAlign == "1"){ + verticalAlignPos = space_height * Store.devicePixelRatio; + } + else{ + verticalAlignPos = (cellHeight - space_height) * Store.devicePixelRatio - strHeight * strArr.length; + } - offlinecanvas.fillText(strV, horizonAlignPos, (verticalAlignPos + i * strHeight)); + offlinecanvas.fillText(strV, horizonAlignPos, (verticalAlignPos + i * strHeight)); - if(cl == "1" && !isRealNull(strV)){ - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo( - horizonAlignPos, - (verticalAlignPos + i * strHeight) + strHeight / 2 - ); - offlinecanvas.lineTo( - horizonAlignPos + strWidth, - (verticalAlignPos + i * strHeight) + strHeight / 2 - ); - offlinecanvas.stroke(); - offlinecanvas.closePath(); + if(cl == "1" && !isRealNull(strV)){ + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#000"; + offlinecanvas.moveTo( + horizonAlignPos, + (verticalAlignPos + i * strHeight) + strHeight / 2 + ); + offlinecanvas.lineTo( + horizonAlignPos + strWidth, + (verticalAlignPos + i * strHeight) + strHeight / 2 + ); + offlinecanvas.stroke(); + offlinecanvas.closePath(); + } } } - } - else if(cell.tr != null && cell.tr != '0'){ - //旋转 - offlinecanvas.textBaseline = 'top'; //textBaseline以top计算 + else if(cell.tr != null && cell.tr != '0'){ + //旋转 + offlinecanvas.textBaseline = 'top'; //textBaseline以top计算 - //单元格旋转属性 - let tr = cell.tr; + //单元格旋转属性 + let tr = cell.tr; - //旋转重新计算水平、垂直方向坐标 - if(cell.tr == "1" || cell.tr == "2"){ - let textW = 0.707 * (textMetrics + oneLineTextHeight); - let textH = 0.707 * (textMetrics + oneLineTextHeight); + //旋转重新计算水平、垂直方向坐标 + if(cell.tr == "1" || cell.tr == "2"){ + let textW = 0.707 * (textMetrics + oneLineTextHeight); + let textH = 0.707 * (textMetrics + oneLineTextHeight); - let hAP = space_width * Store.devicePixelRatio; - if(horizonAlign == "0"){ - hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); - } - else if(horizonAlign == "2"){ - hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; - } + let hAP = space_width * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; + } - let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; - if(verticalAlign == "0"){ - vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); - } - else if(verticalAlign == "1"){ - vAP = space_height * Store.devicePixelRatio; - } - - //向下倾斜(45 旋转) - if(cell.tr == "1"){ - offlinecanvas.save(); - offlinecanvas.translate(hAP, vAP); - offlinecanvas.rotate(45 * Math.PI / 180); - offlinecanvas.translate(-hAP, -vAP); - offlinecanvas.fillText( - value == null ? "" : value, - hAP + (0.707 * 0.707 * oneLineTextHeight), - vAP - (0.707 * 0.707 * oneLineTextHeight) - ); - offlinecanvas.restore(); + let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = space_height * Store.devicePixelRatio; + } - if(cl == "1" && !isRealNull(value)){ - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo( - hAP + oneLineTextHeight / 2, - vAP + oneLineTextHeight / 2 + //向下倾斜(45 旋转) + if(cell.tr == "1"){ + offlinecanvas.save(); + offlinecanvas.translate(hAP, vAP); + offlinecanvas.rotate(45 * Math.PI / 180); + offlinecanvas.translate(-hAP, -vAP); + offlinecanvas.fillText( + value == null ? "" : value, + hAP + (0.707 * 0.707 * oneLineTextHeight), + vAP - (0.707 * 0.707 * oneLineTextHeight) ); - offlinecanvas.lineTo( - hAP + textW - oneLineTextHeight / 2, - vAP + textH - oneLineTextHeight / 2 + offlinecanvas.restore(); + + if(cl == "1" && !isRealNull(value)){ + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#000"; + offlinecanvas.moveTo( + hAP + oneLineTextHeight / 2, + vAP + oneLineTextHeight / 2 + ); + offlinecanvas.lineTo( + hAP + textW - oneLineTextHeight / 2, + vAP + textH - oneLineTextHeight / 2 + ); + offlinecanvas.closePath(); + offlinecanvas.stroke(); + } + } + + //向上倾斜(-45 旋转) + if(cell.tr == "2"){ + offlinecanvas.save(); + offlinecanvas.translate(hAP, vAP + textH); + offlinecanvas.rotate(-45 * Math.PI / 180); + offlinecanvas.translate(-hAP, -(vAP + textH)); + offlinecanvas.fillText( + value == null ? "" : value, + hAP + (0.707 * 0.707 * oneLineTextHeight), + vAP + textH - (0.707 * 0.707 * oneLineTextHeight) ); - offlinecanvas.closePath(); - offlinecanvas.stroke(); + offlinecanvas.restore(); + + if(cl == "1" && !isRealNull(value)){ + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#000"; + offlinecanvas.moveTo( + hAP + oneLineTextHeight / 2, + vAP + textH - oneLineTextHeight / 2 + ); + offlinecanvas.lineTo( + hAP + textW - oneLineTextHeight / 2, + vAP + oneLineTextHeight / 2 + ); + offlinecanvas.closePath(); + offlinecanvas.stroke(); + } } } - - //向上倾斜(-45 旋转) - if(cell.tr == "2"){ - offlinecanvas.save(); - offlinecanvas.translate(hAP, vAP + textH); - offlinecanvas.rotate(-45 * Math.PI / 180); - offlinecanvas.translate(-hAP, -(vAP + textH)); - offlinecanvas.fillText( - value == null ? "" : value, - hAP + (0.707 * 0.707 * oneLineTextHeight), - vAP + textH - (0.707 * 0.707 * oneLineTextHeight) - ); - offlinecanvas.restore(); + else if(cell.tr == "3"){ + if(!isRealNull(value)){ + value = value.toString(); + + let vArr = []; + if(value.length > 1){ + vArr = value.split(""); + } + else{ + vArr.push(value); + } + + let textW_all = 0; //拆分后宽高度合计 + let textH_all = 0; + + for(let i = 0; i < vArr.length; i++){ + let textW = offlinecanvas.measureText(vArr[i]).width; + let textH = oneLineTextHeight; + + textW_all += textW; + textH_all += textH; + + let hAP = space_width * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH * vArr.length; + if(verticalAlign == "0"){ + vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2) * vArr.length; + } + else if(verticalAlign == "1"){ + vAP = space_height * Store.devicePixelRatio; + } + + offlinecanvas.fillText(vArr[i], hAP, (vAP + i * textH)); + } + + if(cl == "1" && !isRealNull(value)){ + let textW = textW_all / vArr.length; + let textH = textH_all; + + let hAP = space_width * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = space_height * Store.devicePixelRatio; + } + + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#000"; + offlinecanvas.moveTo( + hAP + textW / 2, + vAP + ); + offlinecanvas.lineTo( + hAP + textW / 2, + vAP + textH + ); + offlinecanvas.closePath(); + offlinecanvas.stroke(); + } + } + } + else if(cell.tr == "4" || cell.tr == "5"){ + let textW = oneLineTextHeight; + let textH = textMetrics; + + let hAP = space_width * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = space_height * Store.devicePixelRatio; + } + + //向下90(90 旋转) + if(tr == "4"){ + offlinecanvas.save(); + offlinecanvas.translate(hAP, vAP); + offlinecanvas.rotate(90 * Math.PI / 180); + offlinecanvas.translate(-hAP, -vAP); + offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textW); + offlinecanvas.restore(); + } + //向上90(-90 旋转) + if(tr == "5"){ + offlinecanvas.save(); + offlinecanvas.translate(hAP + textH, vAP); + offlinecanvas.rotate(-90 * Math.PI / 180); + offlinecanvas.translate(-(hAP + textH), -vAP); + offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textH); + offlinecanvas.restore(); + } + if(cl == "1" && !isRealNull(value)){ offlinecanvas.beginPath(); offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo( - hAP + oneLineTextHeight / 2, - vAP + textH - oneLineTextHeight / 2 - ); - offlinecanvas.lineTo( - hAP + textW - oneLineTextHeight / 2, - vAP + oneLineTextHeight / 2 - ); + offlinecanvas.moveTo(hAP + textW / 2, vAP); + offlinecanvas.lineTo(hAP + textW / 2, vAP + textH); offlinecanvas.closePath(); offlinecanvas.stroke(); } } } - else if(cell.tr == "3"){ - if(!isRealNull(value)){ - value = value.toString(); + else{ + //单元格有下钻属性,文本颜色变成超链接的颜色 + if(cell.dd != null){ + offlinecanvas.fillStyle = "#0000ff"; + + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#0000ff"; + offlinecanvas.moveTo( + horizonAlignPos, + verticalAlignPos + oneLineTextHeight + ); + offlinecanvas.lineTo( + horizonAlignPos + textMetrics, + verticalAlignPos + oneLineTextHeight + ); + offlinecanvas.stroke(); + offlinecanvas.closePath(); + } + + offlinecanvas.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text); - let vArr = []; - if(value.length > 1){ - vArr = value.split(""); + if(cl == "1" && !isRealNull(value)){ + offlinecanvas.beginPath(); + offlinecanvas.strokeStyle = "#000"; + offlinecanvas.moveTo( + horizonAlignPos, + verticalAlignPos + oneLineTextHeight / 2 + ); + offlinecanvas.lineTo( + horizonAlignPos + textMetrics, + verticalAlignPos + oneLineTextHeight / 2 + ); + offlinecanvas.stroke(); + offlinecanvas.closePath(); + } + } + + //将离屏canvas 画到主表格canvas上 + luckysheetTableContent.drawImage( + offlinecanvasElement, + 0, + 0, + cellWidth * Store.devicePixelRatio, + cellHeight * Store.devicePixelRatio, + (start_c + offsetLeft) * Store.devicePixelRatio, + (start_r + offsetTop) * Store.devicePixelRatio, + cellWidth * Store.devicePixelRatio, + cellHeight * Store.devicePixelRatio, + ); + } + //走主表格canvas方法 + else{ + let pos_x = start_c + offsetLeft; + let pos_y = start_r + offsetTop + 1; + + //若单元格有批注(单元格右上角红色小三角标示) + if(cell.ps != null){ + let ps_w = 5, ps_h = 5; //红色小三角宽高 + + luckysheetTableContent.beginPath(); + luckysheetTableContent.moveTo( + Store.devicePixelRatio * (end_c + offsetLeft - ps_w), + start_r + offsetTop + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * end_c + offsetLeft, + start_r + offsetTop + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * end_c + offsetLeft, + Store.devicePixelRatio * (start_r + offsetTop + ps_h) + ); + luckysheetTableContent.fillStyle = "#FC6666"; + luckysheetTableContent.fill(); + luckysheetTableContent.closePath(); + } + + //若单元格有条件格式数据条 + if(checksCF != null && checksCF["dataBar"] != null){ + let x = Store.devicePixelRatio * (start_c + offsetLeft + space_width); + let y = Store.devicePixelRatio * (start_r + offsetTop + space_height); + let w = Store.devicePixelRatio * (cellWidth - space_width * 2); + let h = Store.devicePixelRatio * (cellHeight - space_height * 2); + + let valueType = checksCF["dataBar"]["valueType"]; + let valueLen = checksCF["dataBar"]["valueLen"]; + let format = checksCF["dataBar"]["format"]; + + if(valueType == 'minus'){ + //负数 + let minusLen = checksCF["dataBar"]["minusLen"]; + + if(format.length > 1){ + //渐变 + let my_gradient = luckysheetTableContent.createLinearGradient( + x + w * minusLen * (1 - valueLen), + y, + x + w * minusLen, + y + ); + my_gradient.addColorStop(0, "#ffffff"); + my_gradient.addColorStop(1, "#ff0000"); + + luckysheetTableContent.fillStyle = my_gradient; } else{ - vArr.push(value); + //单色 + luckysheetTableContent.fillStyle = "#ff0000"; } + + luckysheetTableContent.fillRect( + x + w * minusLen * (1 - valueLen), + y, + w * minusLen * valueLen, + h + ); - let textW_all = 0; //拆分后宽高度合计 - let textH_all = 0; - - for(let i = 0; i < vArr.length; i++){ - let textW = offlinecanvas.measureText(vArr[i]).width; - let textH = oneLineTextHeight; - - textW_all += textW; - textH_all += textH; - - let hAP = space_width * Store.devicePixelRatio; - if(horizonAlign == "0"){ - hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + luckysheetTableContent.beginPath(); + luckysheetTableContent.moveTo( + x + w * minusLen * (1 - valueLen), + y + ); + luckysheetTableContent.lineTo( + x + w * minusLen * (1 - valueLen), + y + h + ); + luckysheetTableContent.lineTo( + x + w * minusLen, + y + h + ); + luckysheetTableContent.lineTo( + x + w * minusLen, + y + ); + luckysheetTableContent.lineTo( + x + w * minusLen * (1 - valueLen), + y + ); + luckysheetTableContent.lineWidth = Store.devicePixelRatio; + luckysheetTableContent.strokeStyle = "#ff0000"; + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); + } + else if(valueType == 'plus'){ + //正数 + let plusLen = checksCF["dataBar"]["plusLen"]; + + if(plusLen == 1){ + if(format.length > 1){ + //渐变 + let my_gradient = luckysheetTableContent.createLinearGradient( + x, + y, + x + w * valueLen, + y + ); + my_gradient.addColorStop(0, format[0]); + my_gradient.addColorStop(1, format[1]); + + luckysheetTableContent.fillStyle = my_gradient; } - else if(horizonAlign == "2"){ - hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; + else{ + //单色 + luckysheetTableContent.fillStyle = format[0]; } + + luckysheetTableContent.fillRect( + x, + y, + w * valueLen, + h + ); - let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH * vArr.length; - if(verticalAlign == "0"){ - vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2) * vArr.length; + luckysheetTableContent.beginPath(); + luckysheetTableContent.moveTo( + x, + y + ); + luckysheetTableContent.lineTo( + x, + y + h + ); + luckysheetTableContent.lineTo( + x + w * valueLen, + y + h + ); + luckysheetTableContent.lineTo( + x + w * valueLen, + y + ); + luckysheetTableContent.lineTo( + x, + y + ); + luckysheetTableContent.lineWidth = Store.devicePixelRatio; + luckysheetTableContent.strokeStyle = format[0]; + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); + } + else{ + let minusLen = checksCF["dataBar"]["minusLen"]; + + if(format.length > 1){ + //渐变 + let my_gradient = luckysheetTableContent.createLinearGradient( + x + w * minusLen, + y, + x + w * minusLen + w * plusLen * valueLen, + y + ); + my_gradient.addColorStop(0, format[0]); + my_gradient.addColorStop(1, format[1]); + + luckysheetTableContent.fillStyle = my_gradient; } - else if(verticalAlign == "1"){ - vAP = space_height * Store.devicePixelRatio; + else{ + //单色 + luckysheetTableContent.fillStyle = format[0]; } - offlinecanvas.fillText(vArr[i], hAP, (vAP + i * textH)); + luckysheetTableContent.fillRect( + x + w * minusLen, + y, + w * plusLen * valueLen, + h + ); + + luckysheetTableContent.beginPath(); + luckysheetTableContent.moveTo( + x + w * minusLen, + y + ); + luckysheetTableContent.lineTo( + x + w * minusLen, + y + h + ); + luckysheetTableContent.lineTo( + x + w * minusLen + w * plusLen * valueLen, + y + h + ); + luckysheetTableContent.lineTo( + x + w * minusLen + w * plusLen * valueLen, + y + ); + luckysheetTableContent.lineTo( + x + w * minusLen, + y + ); + luckysheetTableContent.lineWidth = Store.devicePixelRatio; + luckysheetTableContent.strokeStyle = format[0]; + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); } + } + } - if(cl == "1" && !isRealNull(value)){ - let textW = textW_all / vArr.length; - let textH = textH_all; + let horizonAlignPos = (pos_x + space_width) * Store.devicePixelRatio; //默认为1,左对齐 + if(horizonAlign == "0"){ //居中对齐 + horizonAlignPos = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (textMetrics / 2); + } + else if(horizonAlign == "2"){ //右对齐 + horizonAlignPos = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - textMetrics; + } + + let verticalAlignPos = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - oneLineTextHeight; //默认为2,下对齐 + let verticalAlignPos_text = (pos_y + cellHeight - space_height) * Store.devicePixelRatio; //文本垂直方向基准线 + luckysheetTableContent.textBaseline = "bottom"; + if(verticalAlign == "0"){ //居中对齐 + verticalAlignPos = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (oneLineTextHeight / 2); + + verticalAlignPos_text = (pos_y + cellHeight / 2) * Store.devicePixelRatio; + luckysheetTableContent.textBaseline = "middle"; + } + else if(verticalAlign == "1"){ //上对齐 + verticalAlignPos = (pos_y + space_height) * Store.devicePixelRatio; + + verticalAlignPos_text = (pos_y + space_height) * Store.devicePixelRatio; + luckysheetTableContent.textBaseline = "top"; + } + + //若单元格有条件格式图标集 + if(checksCF != null && checksCF["icons"] != null){ + let l = checksCF["icons"]["left"]; + let t = checksCF["icons"]["top"]; + + luckysheetTableContent.drawImage( + luckysheet_CFiconsImg, + l * 42, + t * 32, + 32, + 32, + pos_x * Store.devicePixelRatio, + verticalAlignPos, + oneLineTextHeight, + oneLineTextHeight + ); + + if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离 + horizonAlignPos = horizonAlignPos + oneLineTextHeight; + } + } - let hAP = space_width * Store.devicePixelRatio; - if(horizonAlign == "0"){ - hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); - } - else if(horizonAlign == "2"){ - hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; - } + //单元格 文本颜色 + luckysheetTableContent.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "fc"); + + //若单元格有交替颜色 文本颜色 + if(checksAF != null && checksAF[0] != null){ + luckysheetTableContent.fillStyle = checksAF[0]; + } + //若单元格有条件格式 文本颜色 + if(checksCF != null && checksCF["textColor"] != null){ + luckysheetTableContent.fillStyle = checksCF["textColor"]; + } - let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; - if(verticalAlign == "0"){ - vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); - } - else if(verticalAlign == "1"){ - vAP = space_height * Store.devicePixelRatio; - } + //单元格是否有删除线 + let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo( - hAP + textW / 2, - vAP + if(cell.tb == '2'){ + //自动换行 + luckysheetTableContent.textBaseline = 'top'; //textBaseline以top计算 + + let strArr = [];//文本截断数组 + strArr = getCellTextSplitArr(value.toString(), strArr, cellWidth - space_width * 2, luckysheetTableContent); + + for(let i = 0; i < strArr.length; i++){ + let strV = strArr[i]; + + let strWidth = luckysheetTableContent.measureText(strV).width; + let strHeight = oneLineTextHeight; + + //水平对齐计算 + if(horizonAlign == "0"){ + horizonAlignPos = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (strWidth / 2); + } + else if(horizonAlign == "2"){ + horizonAlignPos = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - strWidth; + } + else{ + horizonAlignPos = (pos_x + space_width) * Store.devicePixelRatio; + } + + //垂直对齐计算 + if(verticalAlign == "0"){ + verticalAlignPos = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (strHeight / 2) * strArr.length; + } + else if(verticalAlign == "1"){ + verticalAlignPos = (pos_y + space_height) * Store.devicePixelRatio; + } + else{ + verticalAlignPos = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - strHeight * strArr.length; + } + + luckysheetTableContent.fillText(strV, horizonAlignPos, (verticalAlignPos + i * strHeight)); + + if(cl == "1" && !isRealNull(strV)){ + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo( + horizonAlignPos, + (verticalAlignPos + i * strHeight) + strHeight / 2 ); - offlinecanvas.lineTo( - hAP + textW / 2, - vAP + textH + luckysheetTableContent.lineTo( + horizonAlignPos + strWidth, + (verticalAlignPos + i * strHeight) + strHeight / 2 ); - offlinecanvas.closePath(); - offlinecanvas.stroke(); + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); } } } - else if(cell.tr == "4" || cell.tr == "5"){ - let textW = oneLineTextHeight; - let textH = textMetrics; + else if(cell.tr != null && cell.tr != '0'){ + //旋转 + luckysheetTableContent.textBaseline = 'top'; //textBaseline以top计算 - let hAP = space_width * Store.devicePixelRatio; - if(horizonAlign == "0"){ - hAP = (cellWidth / 2) * Store.devicePixelRatio - (textW / 2); - } - else if(horizonAlign == "2"){ - hAP = (cellWidth - space_width) * Store.devicePixelRatio - textW; - } + //单元格旋转属性 + let tr = cell.tr; - let vAP = (cellHeight - space_height) * Store.devicePixelRatio - textH; - if(verticalAlign == "0"){ - vAP = (cellHeight / 2) * Store.devicePixelRatio - (textH / 2); - } - else if(verticalAlign == "1"){ - vAP = space_height * Store.devicePixelRatio; - } + //旋转重新计算水平、垂直方向坐标 + if(cell.tr == "1" || cell.tr == "2"){ + let textW = 0.707 * (textMetrics + oneLineTextHeight); + let textH = 0.707 * (textMetrics + oneLineTextHeight); - //向下90(90 旋转) - if(tr == "4"){ - offlinecanvas.save(); - offlinecanvas.translate(hAP, vAP); - offlinecanvas.rotate(90 * Math.PI / 180); - offlinecanvas.translate(-hAP, -vAP); - offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textW); - offlinecanvas.restore(); + let hAP = (pos_x + space_width) * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = (pos_y + space_height) * Store.devicePixelRatio; + } + + //向下倾斜(45 旋转) + if(cell.tr == "1"){ + luckysheetTableContent.save(); + luckysheetTableContent.translate(hAP, vAP); + luckysheetTableContent.rotate(45 * Math.PI / 180); + luckysheetTableContent.translate(-hAP, -vAP); + luckysheetTableContent.fillText( + value == null ? "" : value, + hAP + (0.707 * 0.707 * oneLineTextHeight), + vAP - (0.707 * 0.707 * oneLineTextHeight) + ); + luckysheetTableContent.restore(); + + if(cl == "1" && !isRealNull(value)){ + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo( + hAP + oneLineTextHeight / 2, + vAP + oneLineTextHeight / 2 + ); + luckysheetTableContent.lineTo( + hAP + textW - oneLineTextHeight / 2, + vAP + textH - oneLineTextHeight / 2 + ); + luckysheetTableContent.closePath(); + luckysheetTableContent.stroke(); + } + } + + //向上倾斜(-45 旋转) + if(cell.tr == "2"){ + luckysheetTableContent.save(); + luckysheetTableContent.translate(hAP, vAP + textH); + luckysheetTableContent.rotate(-45 * Math.PI / 180); + luckysheetTableContent.translate(-hAP, -(vAP + textH)); + luckysheetTableContent.fillText( + value == null ? "" : value, + hAP + (0.707 * 0.707 * oneLineTextHeight), + vAP + textH - (0.707 * 0.707 * oneLineTextHeight) + ); + luckysheetTableContent.restore(); + + if(cl == "1" && !isRealNull(value)){ + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo( + hAP + oneLineTextHeight / 2, + vAP + textH - oneLineTextHeight / 2 + ); + luckysheetTableContent.lineTo( + hAP + textW - oneLineTextHeight / 2, + vAP + oneLineTextHeight / 2 + ); + luckysheetTableContent.closePath(); + luckysheetTableContent.stroke(); + } + } } - - //向上90(-90 旋转) - if(tr == "5"){ - offlinecanvas.save(); - offlinecanvas.translate(hAP + textH, vAP); - offlinecanvas.rotate(-90 * Math.PI / 180); - offlinecanvas.translate(-(hAP + textH), -vAP); - offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textH); - offlinecanvas.restore(); + else if(cell.tr == "3"){ + if(!isRealNull(value)){ + value = value.toString(); + + let vArr = []; + if(value.length > 1){ + vArr = value.split(""); + } + else{ + vArr.push(value); + } + + let textW_all = 0; //拆分后宽高度合计 + let textH_all = 0; + + for(let i = 0; i < vArr.length; i++){ + let textW = luckysheetTableContent.measureText(vArr[i]).width; + let textH = oneLineTextHeight; + + textW_all += textW; + textH_all += textH; + + let hAP = (pos_x + space_width) * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - textH * vArr.length; + if(verticalAlign == "0"){ + vAP = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (textH / 2) * vArr.length; + } + else if(verticalAlign == "1"){ + vAP = (pos_y + space_height) * Store.devicePixelRatio; + } + + luckysheetTableContent.fillText(vArr[i], hAP, (vAP + i * textH)); + } + + if(cl == "1" && !isRealNull(value)){ + let textW = textW_all / vArr.length; + let textH = textH_all; + + let hAP = (pos_x + space_width) * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = (pos_y + space_height) * Store.devicePixelRatio; + } + + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo( + hAP + textW / 2, + vAP + ); + luckysheetTableContent.lineTo( + hAP + textW / 2, + vAP + textH + ); + luckysheetTableContent.closePath(); + luckysheetTableContent.stroke(); + } + } } + else if(cell.tr == "4" || cell.tr == "5"){ + let textW = oneLineTextHeight; + let textH = textMetrics; - if(cl == "1" && !isRealNull(value)){ - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo(hAP + textW / 2, vAP); - offlinecanvas.lineTo(hAP + textW / 2, vAP + textH); - offlinecanvas.closePath(); - offlinecanvas.stroke(); + let hAP = (pos_x + space_width) * Store.devicePixelRatio; + if(horizonAlign == "0"){ + hAP = (pos_x + cellWidth / 2) * Store.devicePixelRatio - (textW / 2); + } + else if(horizonAlign == "2"){ + hAP = (pos_x + cellWidth - space_width) * Store.devicePixelRatio - textW; + } + + let vAP = (pos_y + cellHeight - space_height) * Store.devicePixelRatio - textH; + if(verticalAlign == "0"){ + vAP = (pos_y + cellHeight / 2) * Store.devicePixelRatio - (textH / 2); + } + else if(verticalAlign == "1"){ + vAP = (pos_y + space_height) * Store.devicePixelRatio; + } + + //向下90(90 旋转) + if(tr == "4"){ + luckysheetTableContent.save(); + luckysheetTableContent.translate(hAP, vAP); + luckysheetTableContent.rotate(90 * Math.PI / 180); + luckysheetTableContent.translate(-hAP, -vAP); + luckysheetTableContent.fillText(value == null ? "" : value, hAP, vAP - textW); + luckysheetTableContent.restore(); + } + + //向上90(-90 旋转) + if(tr == "5"){ + luckysheetTableContent.save(); + luckysheetTableContent.translate(hAP + textH, vAP); + luckysheetTableContent.rotate(-90 * Math.PI / 180); + luckysheetTableContent.translate(-(hAP + textH), -vAP); + luckysheetTableContent.fillText(value == null ? "" : value, hAP, vAP - textH); + luckysheetTableContent.restore(); + } + + if(cl == "1" && !isRealNull(value)){ + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo(hAP + textW / 2, vAP); + luckysheetTableContent.lineTo(hAP + textW / 2, vAP + textH); + luckysheetTableContent.closePath(); + luckysheetTableContent.stroke(); + } } } - } - else{ - //单元格有下钻属性,文本颜色变成超链接的颜色 - if(cell.dd != null){ - offlinecanvas.fillStyle = "#0000ff"; + else{ + //单元格有下钻属性,文本颜色变成超链接的颜色 + if(cell.dd != null){ + luckysheetTableContent.fillStyle = "#0000ff"; - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#0000ff"; - offlinecanvas.moveTo( - horizonAlignPos, - verticalAlignPos + oneLineTextHeight - ); - offlinecanvas.lineTo( - horizonAlignPos + textMetrics, - verticalAlignPos + oneLineTextHeight - ); - offlinecanvas.stroke(); - offlinecanvas.closePath(); - } + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#0000ff"; + luckysheetTableContent.moveTo( + horizonAlignPos, + verticalAlignPos + oneLineTextHeight + ); + luckysheetTableContent.lineTo( + horizonAlignPos + textMetrics, + verticalAlignPos + oneLineTextHeight + ); + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); + } - offlinecanvas.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text); - - if(cl == "1" && !isRealNull(value)){ - offlinecanvas.beginPath(); - offlinecanvas.strokeStyle = "#000"; - offlinecanvas.moveTo( - horizonAlignPos, - verticalAlignPos + oneLineTextHeight / 2 - ); - offlinecanvas.lineTo( - horizonAlignPos + textMetrics, - verticalAlignPos + oneLineTextHeight / 2 - ); - offlinecanvas.stroke(); - offlinecanvas.closePath(); + luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text); + + if(cl == "1" && !isRealNull(value)){ + luckysheetTableContent.beginPath(); + luckysheetTableContent.strokeStyle = "#000"; + luckysheetTableContent.moveTo( + horizonAlignPos, + verticalAlignPos + oneLineTextHeight / 2 + ); + luckysheetTableContent.lineTo( + horizonAlignPos + textMetrics, + verticalAlignPos + oneLineTextHeight / 2 + ); + luckysheetTableContent.stroke(); + luckysheetTableContent.closePath(); + } } - } + } - //将离屏canvas 画到主表格canvas上 - luckysheetTableContent.drawImage( - offlinecanvasElement, - 0, - 0, - cellWidth * Store.devicePixelRatio, - cellHeight * Store.devicePixelRatio, - (start_c + offsetLeft) * Store.devicePixelRatio, - (start_r + offsetTop + 1) * Store.devicePixelRatio, - cellWidth * Store.devicePixelRatio, - cellHeight * Store.devicePixelRatio, - ); - - //右边框 + //右边框重绘 luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (start_r + offsetTop)); - luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + offsetTop)); + luckysheetTableContent.moveTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), + Store.devicePixelRatio * (start_r + offsetTop - 2) + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), + Store.devicePixelRatio * (end_r + offsetTop - 2) + ); luckysheetTableContent.lineWidth = Store.devicePixelRatio; if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { @@ -1395,10 +1953,16 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of luckysheetTableContent.stroke(); luckysheetTableContent.closePath(); - //下边框 + //下边框重绘 luckysheetTableContent.beginPath(); - luckysheetTableContent.moveTo(Store.devicePixelRatio * (start_c - 2 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); - luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 2), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); + luckysheetTableContent.moveTo( + Store.devicePixelRatio * (start_c + offsetLeft - 2), + Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) + ); + luckysheetTableContent.lineTo( + Store.devicePixelRatio * (end_c + offsetLeft - 2), + Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) + ); luckysheetTableContent.lineWidth = Store.devicePixelRatio; if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { @@ -1678,1444 +2242,65 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of } } -// function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas, ctx, ctxdata) { -// if(ctxdata != null){ -// Store.flowdata = ctxdata; -// } - -// if(Store.flowdata == null){ -// return; -// } - -// if (scrollWidth == null) { -// scrollWidth = $("#luckysheet-cell-main").scrollLeft(); -// } -// if (scrollHeight == null) { -// scrollHeight = $("#luckysheet-cell-main").scrollTop(); -// } - -// if (drawWidth == null) { -// drawWidth = Store.luckysheetTableContentHW[0]; -// } -// if (drawHeight == null) { -// drawHeight = Store.luckysheetTableContentHW[1]; -// } - -// if (offsetLeft == null) { -// offsetLeft = Store.rowHeaderWidth; -// } -// if (offsetTop == null) { -// offsetTop = Store.columeHeaderHeight; -// } - -// if (columnOffsetCell == null) { -// columnOffsetCell = 0; -// } -// if (rowOffsetCell == null) { -// rowOffsetCell = 0; -// } - -// let luckysheetTableContent = null; -// if(ctx != null){ -// let luckysheetTableElement = document.createElement('canvas'); -// luckysheetTableElement.width = drawWidth; -// luckysheetTableElement.height = drawHeight; -// luckysheetTableContent = luckysheetTableElement.getContext("2d"); -// } -// else{ -// if(mycanvas == null){ -// luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d"); -// } -// else { -// if(getObjType(mycanvas) == "object"){ -// try{ -// luckysheetTableContent = mycanvas.get(0).getContext("2d"); -// } -// catch(err){ -// luckysheetTableContent = mycanvas; -// } -// } -// else{ -// luckysheetTableContent = $("#" + mycanvas).get(0).getContext("2d"); -// } -// } -// } - -// luckysheetTableContent.clearRect( -// 0, -// 0, -// Store.luckysheetTableContentHW[0] * Store.devicePixelRatio, -// Store.luckysheetTableContentHW[1] * Store.devicePixelRatio -// ); - -// //离屏canvas -// let offlinecanvas = null; -// if(ctx != null){ -// let offlineElement = document.createElement('canvas'); -// offlineElement.width = drawWidth; -// offlineElement.height = drawHeight; -// offlinecanvas = offlineElement.getContext("2d"); -// } -// else{ -// offlinecanvas = $("#luckysheetTableContentF").get(0).getContext("2d"); -// } -// offlinecanvas.fillStyle = "#ffffff"; -// offlinecanvas.fillRect( -// 0, -// 0, -// Store.luckysheetTableContentHW[0] * Store.devicePixelRatio, -// Store.luckysheetTableContentHW[1] * Store.devicePixelRatio -// ); -// offlinecanvas.font = luckysheetdefaultstyle.font; -// offlinecanvas.textBaseline = "top"; -// offlinecanvas.fillStyle = luckysheetdefaultstyle.fillStyle; - -// // -// let dataset_row_st, dataset_row_ed, dataset_col_st, dataset_col_ed; - -// dataset_row_st = luckysheet_searcharray(Store.visibledatarow, scrollHeight); -// dataset_row_ed = luckysheet_searcharray(Store.visibledatarow, scrollHeight + drawHeight); - -// if (dataset_row_st == -1) { -// dataset_row_st = 0; -// } - -// dataset_row_st += rowOffsetCell; - -// if (dataset_row_ed == -1) { -// dataset_row_ed = Store.visibledatarow.length - 1; -// } - -// dataset_row_ed += rowOffsetCell; - -// if (dataset_row_ed >= Store.visibledatarow.length) { -// dataset_row_ed = Store.visibledatarow.length - 1; -// } - -// dataset_col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollWidth); -// dataset_col_ed = luckysheet_searcharray(Store.visibledatacolumn, scrollWidth + drawWidth); - -// if (dataset_col_st == -1) { -// dataset_col_st = 0; -// } - -// dataset_col_st += columnOffsetCell; - -// if (dataset_col_ed == -1) { -// dataset_col_ed = Store.visibledatacolumn.length - 1; -// } - -// dataset_col_ed += columnOffsetCell; - -// if (dataset_col_ed >= Store.visibledatacolumn.length) { -// dataset_col_ed = Store.visibledatacolumn.length - 1; -// } - - -// let fill_row_st, fill_row_ed, fill_col_st, fill_col_ed; -// if(dataset_row_st == 0){ -// fill_row_st = 0; -// } -// else{ -// fill_row_st = Store.visibledatarow[dataset_row_st - 1]; -// } - -// fill_row_ed = Store.visibledatarow[dataset_row_ed]; - -// if(dataset_col_st == 0){ -// fill_col_st = 0; -// } -// else{ -// fill_col_st = Store.visibledatacolumn[dataset_col_st - 1]; -// } - -// fill_col_ed = Store.visibledatacolumn[dataset_col_ed]; - -// luckysheetTableContent.fillStyle = "#ffffff"; -// luckysheetTableContent.fillRect( -// (offsetLeft - 1) * Store.devicePixelRatio, -// (offsetTop - 1) * Store.devicePixelRatio, -// (fill_col_ed - scrollWidth) * Store.devicePixelRatio, -// (fill_row_ed - scrollHeight) * Store.devicePixelRatio -// ); -// luckysheetTableContent.font = luckysheetdefaultstyle.font; -// luckysheetTableContent.textBaseline = "top"; -// luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle; - -// let end_r, start_r, end_c, start_c; - -// let cellupdate = []; -// let mergeCache = {}; - -// let borderOffset = {}; - -// for (let r = dataset_row_st; r <= dataset_row_ed; r++) { -// if (r == 0) { -// start_r = -scrollHeight - 1; -// } -// else { -// start_r = Store.visibledatarow[r - 1] - scrollHeight - 1; -// } - -// end_r = Store.visibledatarow[r] - scrollHeight; - -// for (let c = dataset_col_st; c <= dataset_col_ed; c++) { -// if (c == 0) { -// start_c = -scrollWidth; -// } -// else { -// start_c = Store.visibledatacolumn[c - 1] - scrollWidth; -// } - -// end_c = Store.visibledatacolumn[c] - scrollWidth; - -// //横线 -// if(c == dataset_col_ed && !Store.luckysheetcurrentisPivotTable){ -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio * (offsetLeft - 1), -// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio * (fill_col_ed - scrollWidth + offsetLeft - 2), -// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); -// } - -// //竖线 -// if(r == dataset_row_st && !Store.luckysheetcurrentisPivotTable){ -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), -// Store.devicePixelRatio * (offsetTop - 1) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5), -// Store.devicePixelRatio * (fill_row_ed - scrollHeight + offsetTop - 2) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); -// } - -// //数据透视表 -// if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) { -// if ((c == 0 || c == 5) && r <= 11) { -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), -// Store.devicePixelRatio * (start_r + offsetTop) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), -// Store.devicePixelRatio * (end_r - 2 + offsetTop) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = "#000000"; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); -// } - -// if ((r == 2 || r == 11) && c <= 5) { -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio * (start_c - 1 + offsetLeft), -// Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio * (end_c - 2 + offsetLeft), -// Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = "#000000"; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); -// } - -// if (r == 6 && c == 3) { -// luckysheetTableContent.fillText( -// "数据透视表", -// Store.devicePixelRatio * (start_c + 4 + offsetLeft), -// Store.devicePixelRatio *(start_r + (end_r - start_r) / 2 - 1 + offsetTop) -// ); -// } -// } -// else if (!!Store.luckysheetcurrentisPivotTable) { -// if (c < pivotTable.pivotTableBoundary[1] && r < pivotTable.pivotTableBoundary[0]) { -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft), -// Store.devicePixelRatio*(start_r + offsetTop) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio*(end_c - 2 + 0.5 + offsetLeft), -// Store.devicePixelRatio*(end_r - 2 + offsetTop) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = "#000000"; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); - -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo( -// Store.devicePixelRatio*(start_c - 1 + offsetLeft), -// Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop) -// ); -// luckysheetTableContent.lineTo( -// Store.devicePixelRatio*(end_c - 2 + offsetLeft), -// Store.devicePixelRatio*(end_r - 2 + 0.5 + offsetTop) -// ); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; -// luckysheetTableContent.strokeStyle = "#000000"; -// luckysheetTableContent.closePath(); -// luckysheetTableContent.stroke(); -// } -// } - -// if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) { - -// } -// else { -// let firstcolumlen = Store.defaultcollen; -// if (Store.config["columlen"] != null && Store.config["columlen"][c] != null) { -// firstcolumlen = Store.config["columlen"][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("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(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, -// "firstcolumlen": firstcolumlen, -// startlist: [] -// }); -// } -// else{ -// if(margeMain.c == c){ -// margeMain.end_r += (end_r - start_r - 1); -// margeMain.startlist.push(start_r); -// } - -// if(margeMain.r == r){ -// margeMain.end_c += (end_c - start_c); -// margeMain.firstcolumlen += firstcolumlen; -// } -// } - -// continue; -// } -// } -// } - -// cellupdate.push({ -// "r": r, -// "c": c, -// "start_r": start_r, -// "start_c": start_c, -// "end_r": end_r, -// "end_c": end_c, -// "firstcolumlen": firstcolumlen, -// startlist: [] -// }); -// borderOffset[r + "_" + c] = { -// "start_r": start_r, -// "start_c": start_c, -// "end_r": end_r, -// "end_c": end_c -// }; -// } -// } -// } - -// //动态数组公式计算 -// let dynamicArray_compute = dynamicArrayCompute(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["dynamicArray"]); - -// //交替颜色计算 -// let af_compute = alternateformat.getComputeMap(); - -// //条件格式计算 -// let cf_compute = conditionformat.getComputeMap(); - -// //sparklines渲染 -// let sparklinesRender = function(r, c, offsetX, offsetY, canvasid, ctx){ -// if(Store.flowdata[r] == null || Store.flowdata[r][c] == null){ -// return; -// } - -// let sparklines = Store.flowdata[r][c].spl; -// if(sparklines != null){ -// if(typeof sparklines == "string"){ -// sparklines = eval('('+ sparklines +')'); -// } - -// if(getObjType(sparklines) == "object"){ -// let temp1 = sparklines; -// let x = temp1.offsetX; -// let y = temp1.offsetY; -// x = x == null ? 0 : x; -// y = y == null ? 0 : y; -// luckysheetSparkline.render( -// temp1.shapeseq, -// temp1.shapes, -// offsetX + x, -// offsetY + y, -// temp1.pixelWidth, -// temp1.pixelHeight, -// canvasid, -// ctx -// ); -// } -// else if(getObjType(sparklines) == "array" && getObjType(sparklines[0]) == "object"){ -// for(let i = 0; i < sparklines.length; i++){ -// let temp1 = sparklines[i]; -// let x = temp1.offsetX; -// let y = temp1.offsetY; -// x = x == null ? 0 : x; -// y = y == null ? 0 : y; -// luckysheetSparkline.render( -// temp1.shapeseq, -// temp1.shapes, -// offsetX + x, -// offsetY + y, -// temp1.pixelWidth, -// temp1.pixelHeight, -// canvasid, -// ctx -// ); -// } -// } -// } -// } - -// //空白单元格渲染 -// let nullCellRender = function(r, c, start_r, start_c, end_r, end_c){ -// let checksAF = alternateformat.checksAF(r, c, af_compute); //交替颜色 -// let checksCF = conditionformat.checksCF(r, c, cf_compute); //条件格式 - -// let borderfix = menuButton.borderfix(Store.flowdata, r, c); - -// //背景色 -// luckysheetTableContent.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "bg"); - -// if(checksAF != null && checksAF[1] != null){//交替颜色 -// luckysheetTableContent.fillStyle = checksAF[1]; -// } - -// if(checksCF != null && checksCF["cellColor"] != null){//条件格式 -// luckysheetTableContent.fillStyle = checksCF["cellColor"]; -// } - -// if(Store.flowdata[r][c] != null && Store.flowdata[r][c].tc != null){//标题色 -// luckysheetTableContent.fillStyle = Store.flowdata[r][c].tc; -// } - -// let cellsize = [ -// Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), -// Store.devicePixelRatio * (start_r + offsetTop + 1 + borderfix[1]), -// Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), -// Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3]) -// ]; -// luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]); - -// if((r + "_" + c) in dynamicArray_compute){ -// let value = dynamicArray_compute[r + "_" + c].v; - -// luckysheetTableContent.fillStyle = "#000000"; -// //文本宽度和高度 -// let fontset = luckysheetdefaultstyle.font; -// luckysheetTableContent.font = fontset; - -// let textMetrics = luckysheetTableContent.measureText(value).width; -// let oneLineTextHeight = menuButton.getTextSize("田", fontset)[1]; - -// //水平对齐 (默认为1,左对齐) -// let horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; - -// //垂直对齐 (默认为2,下对齐) -// let verticalFixed = browser.luckysheetrefreshfixed(); -// let verticalAlignPos = (end_r + offsetTop - 2) * Store.devicePixelRatio; -// luckysheetTableContent.textBaseline = 'bottom'; - -// luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos); -// } - -// //若单元格有批注 -// if(Store.flowdata[r][c] != null && Store.flowdata[r][c].ps != null){ -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo(Store.devicePixelRatio * (end_c + offsetLeft - 6), Store.devicePixelRatio * (start_r + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 1), Store.devicePixelRatio * (start_r + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 1), Store.devicePixelRatio * (start_r + offsetTop + 5)); -// luckysheetTableContent.fillStyle = "#FC6666"; -// luckysheetTableContent.fill(); -// luckysheetTableContent.closePath(); -// } - -// //右边框 -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (start_r + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + offsetTop)); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; - -// if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { -// luckysheetTableContent.strokeStyle = "#000000"; -// } -// else{ -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// } - -// luckysheetTableContent.stroke(); -// luckysheetTableContent.closePath(); - -// //下边框 -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo(Store.devicePixelRatio * (start_c - 2 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 2), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; - -// if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { -// luckysheetTableContent.strokeStyle = "#000000"; -// } -// else{ -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// } - -// luckysheetTableContent.stroke(); -// luckysheetTableContent.closePath(); -// } - -// //非空白单元格渲染 -// let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, canvasType){ -// let checksAF = alternateformat.checksAF(r, c, af_compute); //交替颜色 -// let checksCF = conditionformat.checksCF(r, c, cf_compute); //条件格式 - -// let borderfix = menuButton.borderfix(Store.flowdata, r, c); - -// //文本宽度和高度 -// let fontset = luckysheetfontformat(Store.flowdata[r][c]); -// luckysheetTableContent.font = fontset; - -// let measureText = luckysheetTableContent.measureText(value); -// let textMetrics = measureText.width; -// // let oneLineTextHeight = menuButton.getTextSize("田", fontset)[1]; -// // let oneLineTextHeight = menuButton.getTextSize(value, fontset)[1]; -// let oneLineTextHeight = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent; - -// let textW, textH; - -// if(Store.flowdata[r][c].tb == "2"){ -// let strValue = value.toString(); -// let tbWidth = luckysheetTableContent.measureText(strValue).width; -// let cellWidth = end_c - start_c - 8; - -// if(tbWidth > cellWidth){ -// let strArr = [];//文本截断数组 -// strArr = getCellTextSplitArr(strValue, strArr, cellWidth, luckysheetTableContent); -// textH = strArr.length * oneLineTextHeight; -// } -// else{ -// textH = oneLineTextHeight; -// } -// } -// else if(Store.flowdata[r][c].tr != null && Store.flowdata[r][c].tr != "0"){ -// let tr = Store.flowdata[r][c].tr; - -// if(tr == "1" || tr == "2"){ -// textW = 0.707 * (textMetrics + oneLineTextHeight); -// textH = 0.707 * (textMetrics + oneLineTextHeight); -// } -// else if(tr == "3"){ -// value = value.toString(); - -// let vArr; -// if(value.length > 1){ -// vArr = value.split(""); -// } -// else{ -// vArr = []; -// vArr.push(value); -// } - -// textW = luckysheetTableContent.measureText(vArr[0]).width; -// textH = vArr.length * oneLineTextHeight; -// } -// else if(tr == "4" || tr == "5"){ -// textW = oneLineTextHeight; -// textH = textMetrics; -// } -// } -// else{ -// textW = textMetrics; -// textH = oneLineTextHeight; -// } - -// //水平对齐 -// let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c , "ht"); -// //垂直对齐 -// let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c , "vt"); - -// //水平对齐方式是 居中或居右对齐 且单元格宽度小于文字宽度 (用离屏canvas渲染) -// let canvasName, cellsize; -// if(browser.BrowserType() != "Safari" && (canvasType == "offline" || ((horizonAlign == "0" || horizonAlign == "2") && (end_c - start_c) < textW) || ((end_r - start_r) < textH))){ -// canvasName = offlinecanvas; -// canvasName.font = fontset; - -// cellsize = [ -// Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), -// Store.devicePixelRatio * (start_r + offsetTop + 0.5 + borderfix[1]), -// Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), -// Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3]) -// ]; -// } -// else{ -// canvasName = luckysheetTableContent; - -// cellsize = [ -// Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), -// Store.devicePixelRatio * (start_r + offsetTop + 1 + borderfix[1]), -// Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), -// Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3]) -// ]; -// } - -// //horizonAlign默认为1,左对齐 -// let horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; -// if(horizonAlign == "0"){ -// //居中对齐 -// horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textMetrics) / 2; -// } -// else if(horizonAlign == "2"){ -// //右对齐 -// horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textMetrics); -// } - -// //verticalAlign默认为2,下对齐 -// let verticalFixed = browser.luckysheetrefreshfixed(); -// let verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight; -// let verticalAlignPos_text = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio; -// canvasName.textBaseline = "bottom"; - -// if(verticalAlign == "0"){ -// //居中对齐 -// verticalAlignPos = (start_r + offsetTop + (end_r - start_r) / 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight / 2; -// verticalAlignPos_text = (start_r + offsetTop + (end_r - start_r) / 2 + verticalFixed) * Store.devicePixelRatio; -// canvasName.textBaseline = "middle"; -// } -// else if(verticalAlign == "1"){ -// //上对齐 -// verticalAlignPos = (start_r + offsetTop + 2 + verticalFixed) * Store.devicePixelRatio; -// verticalAlignPos_text = (start_r + offsetTop + 2 + verticalFixed) * Store.devicePixelRatio; -// canvasName.textBaseline = "top"; -// } - -// //单元格 背景颜色 -// canvasName.fillStyle= menuButton.checkstatus(Store.flowdata, r, c , "bg"); - -// //若单元格有交替颜色 背景颜色 -// if(checksAF != null && checksAF[1] != null){ -// canvasName.fillStyle = checksAF[1]; -// } - -// //若单元格有条件格式 背景颜色 -// if(checksCF != null && checksCF["cellColor"] != null){ -// canvasName.fillStyle = checksCF["cellColor"]; -// } - -// //若单元格有标题色 -// if(Store.flowdata[r][c] != null && Store.flowdata[r][c].tc != null){ -// luckysheetTableContent.fillStyle = Store.flowdata[r][c].tc; -// } - -// canvasName.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]); - -// //若单元格有批注 -// if(Store.flowdata[r][c].ps != null){ -// canvasName.beginPath(); -// canvasName.moveTo(Store.devicePixelRatio * (end_c + offsetLeft - 6), Store.devicePixelRatio * (start_r + offsetTop)); -// canvasName.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 1), Store.devicePixelRatio * (start_r + offsetTop)); -// canvasName.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 1), Store.devicePixelRatio * (start_r + offsetTop + 5)); -// canvasName.fillStyle = "#FC6666"; -// canvasName.fill(); -// canvasName.closePath(); -// } - -// //若单元格有条件格式数据条 -// if(checksCF != null && checksCF["dataBar"] != null){ -// let x = Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0] + 2); -// let y = Store.devicePixelRatio * (start_r + offsetTop + 0.5 + borderfix[1] + 2); -// let w = Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2] - 4); -// let h = Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3] - 4); - -// let valueType = checksCF["dataBar"]["valueType"]; -// let valueLen = checksCF["dataBar"]["valueLen"]; -// let format = checksCF["dataBar"]["format"]; - -// if(format.length > 1){ //渐变 -// if(valueType == "minus"){ -// //负数 -// let minusLen = checksCF["dataBar"]["minusLen"]; - -// let my_gradient = canvasName.createLinearGradient(x + w * minusLen * (1 - valueLen), y, x + w * minusLen, y); -// my_gradient.addColorStop(0, "#ffffff"); -// my_gradient.addColorStop(1, "#ff0000"); -// canvasName.fillStyle = my_gradient; -// canvasName.fillRect(x + w * minusLen * (1 - valueLen), y, w * minusLen * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x + w * minusLen * (1 - valueLen), y); -// canvasName.lineTo(x + w * minusLen * (1 - valueLen), y + h); -// canvasName.lineTo(x + w * minusLen, y + h); -// canvasName.lineTo(x + w * minusLen, y); -// canvasName.lineTo(x + w * minusLen * (1 - valueLen), y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = "#ff0000"; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// else if(valueType == "plus"){ -// //正数 -// let plusLen = checksCF["dataBar"]["plusLen"]; - -// if(plusLen == 1){ -// let my_gradient = canvasName.createLinearGradient(x, y, x + w * valueLen, y); -// my_gradient.addColorStop(0, format[0]); -// my_gradient.addColorStop(1, format[1]); -// canvasName.fillStyle = my_gradient; -// canvasName.fillRect(x, y, w * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x, y); -// canvasName.lineTo(x, y + h); -// canvasName.lineTo(x + w * valueLen, y + h); -// canvasName.lineTo(x + w * valueLen, y); -// canvasName.lineTo(x, y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = format[0]; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// else{ -// let minusLen = checksCF["dataBar"]["minusLen"]; - -// let my_gradient = canvasName.createLinearGradient(x + w * minusLen, y, x + w * minusLen + w * plusLen * valueLen, y); -// my_gradient.addColorStop(0, format[0]); -// my_gradient.addColorStop(1, format[1]); -// canvasName.fillStyle = my_gradient; -// canvasName.fillRect(x + w * minusLen, y, w * plusLen * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x + w * minusLen, y); -// canvasName.lineTo(x + w * minusLen, y + h); -// canvasName.lineTo(x + w * minusLen + w * plusLen * valueLen, y + h); -// canvasName.lineTo(x + w * minusLen + w * plusLen * valueLen, y); -// canvasName.lineTo(x + w * minusLen, y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = format[0]; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// } -// } -// else{ //单色 -// if(valueType == "minus"){ -// //负数 -// let minusLen = checksCF["dataBar"]["minusLen"]; - -// canvasName.fillStyle = "#ff0000"; -// canvasName.fillRect(x + w * minusLen * (1 - valueLen), y, w * minusLen * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x + w * minusLen * (1 - valueLen), y); -// canvasName.lineTo(x + w * minusLen * (1 - valueLen), y + h); -// canvasName.lineTo(x + w * minusLen, y + h); -// canvasName.lineTo(x + w * minusLen, y); -// canvasName.lineTo(x + w * minusLen * (1 - valueLen), y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = "#ff0000"; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// else if(valueType == "plus"){ -// //正数 -// let plusLen = checksCF["dataBar"]["plusLen"]; - -// if(plusLen == 1){ -// canvasName.fillStyle = format[0]; -// canvasName.fillRect(x, y, w * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x, y); -// canvasName.lineTo(x, y + h); -// canvasName.lineTo(x + w * valueLen, y + h); -// canvasName.lineTo(x + w * valueLen, y); -// canvasName.lineTo(x, y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = format[0]; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// else{ -// let minusLen = checksCF["dataBar"]["minusLen"]; - -// canvasName.fillStyle = format[0]; -// canvasName.fillRect(x + w * minusLen, y, w * plusLen * valueLen, h); - -// canvasName.beginPath(); -// canvasName.moveTo(x + w * minusLen, y); -// canvasName.lineTo(x + w * minusLen, y + h); -// canvasName.lineTo(x + w * minusLen + w * plusLen * valueLen, y + h); -// canvasName.lineTo(x + w * minusLen + w * plusLen * valueLen, y); -// canvasName.lineTo(x + w * minusLen, y); -// canvasName.lineWidth = Store.devicePixelRatio; -// canvasName.strokeStyle = format[0]; -// canvasName.stroke(); -// canvasName.closePath(); -// } -// } -// } -// } - -// //若单元格有条件格式图标集 -// if(checksCF != null && checksCF["icons"] != null){ -// let l = checksCF["icons"]["left"]; -// let t = checksCF["icons"]["top"]; - -// canvasName.drawImage( -// luckysheet_CFiconsImg, -// l * 42, -// t * 32, -// 32, -// 32, -// cellsize[0], -// verticalAlignPos + 2, -// oneLineTextHeight - 2, -// oneLineTextHeight - 2 -// ); - -// if(horizonAlign != "0" && horizonAlign != "2"){ //左对齐时 文本渲染空出一个图标的距离 -// horizonAlignPos = horizonAlignPos + oneLineTextHeight - 2; -// } -// } - -// //单元格 文本颜色 -// canvasName.fillStyle = menuButton.checkstatus(Store.flowdata, r, c , "fc"); - -// //若单元格有交替颜色 文本颜色 -// if(checksAF != null && checksAF[0] != null){ -// canvasName.fillStyle = checksAF[0]; -// } - -// //若单元格有条件格式 文本颜色 -// if(checksCF != null && checksCF["textColor"] != null){ -// canvasName.fillStyle = checksCF["textColor"]; -// } - -// //单元格有下钻属性,文本颜色变成超链接的颜色 -// if(Store.flowdata[r][c].dd != null){ -// canvasName.fillStyle = "#0000ff"; - -// canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text); - -// canvasName.beginPath(); -// canvasName.strokeStyle = "#0000ff"; -// canvasName.moveTo(horizonAlignPos, verticalAlignPos + oneLineTextHeight); -// canvasName.lineTo(horizonAlignPos + textMetrics, verticalAlignPos + oneLineTextHeight); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// else{ -// //自动换行、旋转、删除线功能 -// if(Store.flowdata[r][c].tb == "2"){ -// canvasName.textBaseline = 'top'; //自动换行 textBaseline以top计算 - -// let strValue = value.toString(); -// let cellWidth = end_c - start_c - 8; - -// let strArr = [];//文本截断数组 -// strArr = getCellTextSplitArr(strValue, strArr, cellWidth, canvasName); - -// for(let iFill = 0; iFill < strArr.length; iFill++){ -// //水平对齐计算 -// let strWidth = canvasName.measureText(strArr[iFill]).width; -// if(horizonAlign == "0"){ -// horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (strWidth)/2; -// } -// else if(horizonAlign == "2"){ -// horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (strWidth); -// } - -// //垂直对齐计算 -// if(verticalAlign == "0"){ -// verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * strArr.length / 2; -// } -// else if(verticalAlign == "1"){ -// verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; -// } -// else{ -// verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * strArr.length; -// } - -// canvasName.fillText(strArr[iFill], horizonAlignPos, (verticalAlignPos + iFill * oneLineTextHeight)); -// } -// } -// else if(Store.flowdata[r][c].tr != null && Store.flowdata[r][c].tr != "0"){ -// canvasName.textBaseline = 'top'; //旋转 textBaseline以top计算 - -// //单元格旋转属性 -// let tr = Store.flowdata[r][c].tr; - -// if(tr == "1" || tr == "2"){ -// //旋转重新计算水平、垂直方向坐标 -// let textW = 0.707 * (textMetrics + oneLineTextHeight); -// let textH = 0.707 * (textMetrics + oneLineTextHeight); - -// let hAP = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; -// if(horizonAlign == "0"){ -// hAP = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textW) / 2; -// } -// else if(horizonAlign == "2"){ -// hAP = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textW); -// } - -// let vAP = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - textH; -// if(verticalAlign == "0"){ -// vAP = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - textH / 2; -// } -// else if(verticalAlign == "1"){ -// vAP = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; -// } - -// //向下倾斜(45 旋转) -// if(tr == "1"){ -// canvasName.save(); -// canvasName.translate(hAP, vAP); -// canvasName.rotate(45 * Math.PI / 180); -// canvasName.translate(-hAP, -vAP); -// canvasName.fillText(value == null ? "" : value, hAP + (0.707 * 0.707 * oneLineTextHeight), vAP - (0.707 * 0.707 * oneLineTextHeight)); -// canvasName.restore(); - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(hAP + oneLineTextHeight / 2, vAP + oneLineTextHeight / 2); -// canvasName.lineTo(hAP + textW - oneLineTextHeight / 2, vAP + textH - oneLineTextHeight / 2); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } - -// //向上倾斜(-45 旋转) -// if(tr == "2"){ -// canvasName.save(); -// canvasName.translate(hAP, vAP + textH); -// canvasName.rotate(-45 * Math.PI / 180); -// canvasName.translate(-hAP, -(vAP + textH)); -// canvasName.fillText(value == null ? "" : value, hAP + (0.707 * 0.707 * oneLineTextHeight), vAP + textH - (0.707 * 0.707 * oneLineTextHeight)); -// canvasName.restore(); - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(hAP + oneLineTextHeight / 2, vAP + textH - oneLineTextHeight / 2); -// canvasName.lineTo(hAP + textW - oneLineTextHeight / 2, vAP + oneLineTextHeight / 2); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } -// } -// else if(tr == "3"){ -// if(!isRealNull(value)){ -// value = value.toString(); - -// let vArr; -// if(value.length > 1){ -// vArr = value.split(""); -// } -// else{ -// vArr = []; -// vArr.push(value); -// } - -// let textW = canvasName.measureText(vArr[0]).width; -// let textH = vArr.length * oneLineTextHeight; - -// for(let i = 0; i < vArr.length; i++){ -// let vWidth = canvasName.measureText(vArr[i]).width; - -// //水平对齐计算 -// if(horizonAlign == "0"){ -// horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (vWidth)/2; -// } -// else if(horizonAlign == "2"){ -// horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (vWidth); -// } -// else{ -// horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; -// } - -// //垂直对齐计算 -// if(verticalAlign == "0"){ -// verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * vArr.length/2; -// } -// else if(verticalAlign == "1"){ -// verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; -// } -// else{ -// verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * vArr.length; -// } - -// canvasName.fillText(vArr[i], horizonAlignPos, (verticalAlignPos + i * oneLineTextHeight)); -// } - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(horizonAlignPos + textW / 2, verticalAlignPos); -// canvasName.lineTo(horizonAlignPos + textW / 2, verticalAlignPos + textH); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } -// } -// else if(tr == "4" || tr == "5"){ -// //旋转重新计算水平、垂直方向坐标 -// let textW = oneLineTextHeight; -// let textH = textMetrics; - -// let hAP = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; -// if(horizonAlign == "0"){ -// hAP = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textW) / 2; -// } -// else if(horizonAlign == "2"){ -// hAP = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textW); -// } - -// let vAP = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - textH; -// if(verticalAlign == "0"){ -// vAP = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - textH / 2; -// } -// else if(verticalAlign == "1"){ -// vAP = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; -// } - -// //向下90(90 旋转) -// if(tr == "4"){ -// canvasName.save(); -// canvasName.translate(hAP, vAP); -// canvasName.rotate(90 * Math.PI / 180); -// canvasName.translate(-hAP, -vAP); -// canvasName.fillText(value == null ? "" : value, hAP, vAP - textW); -// canvasName.restore(); - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(hAP + textW / 2, vAP); -// canvasName.lineTo(hAP + textW / 2, vAP + textH); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } - -// //向上90(-90 旋转) -// if(tr == "5"){ -// canvasName.save(); -// canvasName.translate(hAP + textH, vAP); -// canvasName.rotate(-90 * Math.PI / 180); -// canvasName.translate(-(hAP + textH), -vAP); -// canvasName.fillText(value == null ? "" : value, hAP, vAP - textH); -// canvasName.restore(); - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(hAP + textW / 2, vAP); -// canvasName.lineTo(hAP + textW / 2, vAP + textH); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } -// } -// } -// else{ -// canvasName.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos_text); - -// //是否有删除线 -// let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); -// if(cl == "1" && !isRealNull(value)){ -// canvasName.beginPath(); -// canvasName.strokeStyle = "#000"; -// canvasName.moveTo(horizonAlignPos, verticalAlignPos + oneLineTextHeight / 2); -// canvasName.lineTo(horizonAlignPos + textMetrics, verticalAlignPos + oneLineTextHeight / 2); -// canvasName.closePath(); -// canvasName.stroke(); -// } -// } -// } - -// //水平对齐方式是 居中或居右对齐 且单元格宽度小于文字宽度 (用离屏canvas渲染) -// if(browser.BrowserType() != "Safari" && (canvasType == "offline" || ((horizonAlign == "0" || horizonAlign == "2") && (end_c - start_c) < textW) || ((verticalAlign == "0" || verticalAlign == "2") && (end_r - start_r) < textH))){ -// canvasName.font = luckysheetdefaultstyle.font; - -// if($("#luckysheetTableContentF").length > 0){ -// luckysheetTableContent.drawImage($("#luckysheetTableContentF").get(0), cellsize[0], cellsize[1], cellsize[2], cellsize[3], cellsize[0], cellsize[1], cellsize[2], cellsize[3]); -// } -// else{ -// luckysheetTableContent.drawImage(offlineElement, cellsize[0], cellsize[1], cellsize[2], cellsize[3], cellsize[0], cellsize[1], cellsize[2], cellsize[3]); -// } -// } - -// luckysheetTableContent.font = luckysheetdefaultstyle.font; - -// //右边框 -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (start_r + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + offsetTop)); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; - -// if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { -// luckysheetTableContent.strokeStyle = "#000000"; -// } -// else{ -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// } - -// luckysheetTableContent.stroke(); -// luckysheetTableContent.closePath(); - -// //下边框 -// luckysheetTableContent.beginPath(); -// luckysheetTableContent.moveTo(Store.devicePixelRatio * (start_c - 2 + offsetLeft), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); -// luckysheetTableContent.lineTo(Store.devicePixelRatio * (end_c + offsetLeft - 2), Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); -// luckysheetTableContent.lineWidth = Store.devicePixelRatio; - -// if (!!Store.luckysheetcurrentisPivotTable && !pivotTable.drawPivotTable) { -// luckysheetTableContent.strokeStyle = "#000000"; -// } -// else{ -// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; -// } - -// luckysheetTableContent.stroke(); -// luckysheetTableContent.closePath(); -// } - -// let mcArr = []; - -// for(let cud = 0; cud < cellupdate.length; cud++){ -// let item = cellupdate[cud]; -// let r = item.r, -// c = item.c, -// start_r = item.start_r, -// start_c = item.start_c, -// end_r = item.end_r, -// end_c = item.end_c; -// let firstcolumlen = item.firstcolumlen; - -// if(Store.flowdata[r] == null){ -// continue; -// } - -// if(Store.flowdata[r][c] == null){ //空单元格 -// nullCellRender(r, c, start_r, start_c, end_r, end_c); -// } -// else{ -// let cell = Store.flowdata[r][c]; -// let value = null, er = r, ec = c, end_ec = end_c; - -// if((typeof cell == "object") && "mc" in cell){ -// mcArr.push(cellupdate[cud]); - -// let margeMaindata = cell["mc"]; -// value = getcellvalue(margeMaindata.r, margeMaindata.c, null, "m"); - -// if(value == null){ -// value = getcellvalue(margeMaindata.r, margeMaindata.c); -// } - -// r = margeMaindata.r; -// c = margeMaindata.c; - -// er += margeMaindata.rs; -// ec += margeMaindata.rc; - -// if (c == 0) { -// start_c = -scrollWidth; -// } -// else { -// start_c = Store.visibledatacolumn[c - 1] - scrollWidth; -// } - -// if (r == 0) { -// start_r = -scrollHeight - 1; -// } -// else { -// start_r = Store.visibledatarow[r - 1] - scrollHeight - 1; -// } - -// end_ec = Store.visibledatacolumn[ec] - scrollWidth; -// } -// else{ -// value = getcellvalue(r, c, null, "m"); -// if(value == null){ -// value = getcellvalue(r, c); -// } -// } - -// if(value == null || value.toString().length == 0){ -// nullCellRender(r, c, start_r, start_c, end_r, end_c); - -// //sparklines渲染 -// let borderfix = menuButton.borderfix(Store.flowdata, r, c); -// let cellsize = [ -// Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), -// Store.devicePixelRatio * (start_r + offsetTop + 0.5 + borderfix[1]), -// Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), -// Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3]) -// ]; -// sparklinesRender(r, c, cellsize[0], cellsize[1], "luckysheetTableContent", luckysheetTableContent); -// } -// else{ -// if((r + "_" + c) in dynamicArray_compute){//动态数组公式 -// value = dynamicArray_compute[r + "_" + c].v; -// } - -// cellRender(r, c, start_r, start_c, end_r, end_c, value); -// } -// } -// } - -// //合并单元格再处理 -// for(let m = 0; m < mcArr.length; m++){ -// let item = mcArr[m]; -// let r = item.r, -// c = item.c, -// start_r = item.start_r, -// start_c = item.start_c, -// end_r = item.end_r, -// end_c = item.end_c; -// let firstcolumlen = item.firstcolumlen; - -// let cell = Store.flowdata[r][c]; -// let value = null, er = r, ec = c, end_ec = end_c; - -// let margeMaindata = cell["mc"]; -// value = getcellvalue(margeMaindata.r, margeMaindata.c, null, "m"); - -// if(value == null){ -// value = getcellvalue(margeMaindata.r, margeMaindata.c); -// } - -// r = margeMaindata.r; -// c = margeMaindata.c; - -// er += margeMaindata.rs; -// ec += margeMaindata.rc; - -// if (c == 0) { -// start_c = -scrollWidth; -// } -// else { -// start_c = Store.visibledatacolumn[c - 1] - scrollWidth; -// } - -// if (r == 0) { -// start_r = -scrollHeight - 1; -// } -// else { -// start_r = Store.visibledatarow[r - 1] - scrollHeight - 1; -// } - -// end_ec = Store.visibledatacolumn[ec] - scrollWidth; - -// if(value == null || value.toString().length == 0){ -// nullCellRender(r, c, start_r, start_c, end_r, end_c); - -// //sparklines渲染 -// let borderfix = menuButton.borderfix(Store.flowdata, r, c); -// let cellsize = [ -// Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), -// Store.devicePixelRatio * (start_r + offsetTop + 0.5 + borderfix[1]), -// Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), -// Store.devicePixelRatio * (end_r - start_r - 3 - 0.5 + borderfix[3]) -// ]; -// sparklinesRender(r, c, cellsize[0], cellsize[1], "luckysheetTableContent", luckysheetTableContent); -// } -// else{ -// if((r + "_" + c) in dynamicArray_compute){//动态数组公式 -// value = dynamicArray_compute[r + "_" + c].v; -// } - -// cellRender(r, c, start_r, start_c, end_r, end_c, value, "offline"); -// } -// } - -// //边框单独渲染 -// if(Store.config["borderInfo"] != null && Store.config["borderInfo"].length > 0){ -// //边框渲染 -// let borderLeftRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, canvas){ -// let linetype = style; - -// let m_st = Store.devicePixelRatio * (start_c - 2 + 0.5 + offsetLeft); -// let m_ed = Store.devicePixelRatio * (start_r + offsetTop); -// let line_st = Store.devicePixelRatio * (start_c - 2 + 0.5 + offsetLeft); -// let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop); - -// menuButton.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed); - -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } - -// let borderRightRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, canvas){ -// let linetype = style; +function getCellValueSize(cell, value, canvas, cellWidth, cellHeight, space_width, space_height){ + let textWidth, textHeight; -// let m_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft); -// let m_ed = Store.devicePixelRatio * (start_r + offsetTop); -// let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft); -// let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop); + value = value.toString(); -// menuButton.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed); - -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } + let measureText = canvas.measureText(value); + let textW = measureText.width; + let textH = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent; -// let borderBottomRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, canvas){ -// let linetype = style; + if(cell.tb == '2' && textW > cellWidth - space_width * 2){ + //自动换行 且 文本长度超出单元格长度 + let strArr = [];//文本截断数组 + strArr = getCellTextSplitArr(value, strArr, cellWidth - space_width * 2, canvas); -// let m_st = Store.devicePixelRatio * (start_c - 2 + offsetLeft); -// let m_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop); -// let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft); -// let line_ed = Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop); - -// menuButton.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed); - -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } + textWidth = cellWidth - space_width * 2; + textHeight = textH * strArr.length; + } + else if(cell.tr != null && cell.tr != '0'){ + //旋转 + if(cell.tr == '1' || cell.tr == '2'){ + textWidth = 0.707 * (textW + textH); + textHeight = 0.707 * (textW + textH); + } + else if(cell.tr == '3'){ + let vArr = []; -// let borderTopRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, canvas){ -// let linetype = style; + if(value.length > 1){ + vArr = value.split(''); + } + else{ + vArr.push(value); + } -// let m_st = Store.devicePixelRatio * (start_c - 2 + offsetLeft); -// let m_ed = Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop); -// let line_st = Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft); -// let line_ed = Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop); + let textW_all, textH_all; -// menuButton.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed); + for(let i = 0; i < vArr.length; i++){ + let measureText_i = canvas.measureText(vArr[i]); + textW_all += measureText_i.width; + textH_all += measureText_i.actualBoundingBoxDescent - measureText_i.actualBoundingBoxAscent; + } -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } + textWidth = textW_all / vArr.length; + textHeight = textH_all; + } + else if(cell.tr == '4' || cell.tr == '5'){ + textWidth = textH; + textHeight = textW; + } + } + else{ + textWidth = textW; + textHeight = textH; + } -// let borderInfoCompute = getBorderInfoCompute(); - -// for(let x in borderInfoCompute){ -// let bd_r = x.split("_")[0], bd_c = x.split("_")[1]; - -// if(borderOffset[bd_r + "_" + bd_c]){ -// let start_r = borderOffset[bd_r + "_" + bd_c].start_r; -// let start_c = borderOffset[bd_r + "_" + bd_c].start_c; -// let end_r = borderOffset[bd_r + "_" + bd_c].end_r; -// let end_c = borderOffset[bd_r + "_" + bd_c].end_c; - -// let borderLeft = borderInfoCompute[x].l; -// if(borderLeft != null){ -// borderLeftRender(borderLeft.style, borderLeft.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent); -// } - -// let borderRight = borderInfoCompute[x].r; -// if(borderRight != null){ -// borderRightRender(borderRight.style, borderRight.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent); -// } - -// let borderTop = borderInfoCompute[x].t; -// if(borderTop != null){ -// borderTopRender(borderTop.style, borderTop.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent); -// } - -// let borderBottom = borderInfoCompute[x].b; -// if(borderBottom != null){ -// borderBottomRender(borderBottom.style, borderBottom.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent); -// } -// } -// } -// } - -// //渲染表格时有尾列时,清除右边灰色区域,防止表格有值溢出 -// if(dataset_col_ed == Store.visibledatacolumn.length - 1){ -// luckysheetTableContent.clearRect( -// (fill_col_ed - scrollWidth + offsetLeft - 1) * Store.devicePixelRatio, -// (offsetTop - 1) * Store.devicePixelRatio, -// (Store.ch_width - Store.visibledatacolumn[dataset_col_ed]) * Store.devicePixelRatio, -// (fill_row_ed - scrollHeight) * Store.devicePixelRatio -// ); -// } - -// if(ctx != null){ -// ctx.drawImage( -// luckysheetTableElement, -// 0, -// 0, -// drawWidth, -// drawHeight, -// -drawWidth/2 + offsetLeft, -// -drawHeight/2 + offsetTop, -// drawWidth, -// drawHeight -// ); -// } -// } + return { + width: textWidth, + height: textHeight + } +} function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas) { if (scrollWidth == null) { diff --git a/src/global/formula.js b/src/global/formula.js index 3d7a37191..c154ba5ab 100644 --- a/src/global/formula.js +++ b/src/global/formula.js @@ -18,10 +18,11 @@ import tooltip from './tooltip'; import { rowLocation, colLocation, colLocationByIndex, mouseposition } from './location'; import { luckysheetRangeLast } from './cursorPos'; import { jfrefreshgrid } from './refresh'; -import luckysheet_function from '../function/luckysheet_function'; -import functionlist from '../function/functionlist'; +// import luckysheet_function from '../function/luckysheet_function'; +// import functionlist from '../function/functionlist'; import { luckysheet_compareWith, luckysheet_getcelldata, luckysheet_indirect_check, luckysheet_indirect_check_return, luckysheet_offset_check } from '../function/func'; import Store from '../store'; +import locale from '../locale/locale'; const luckysheetformula = { error: { @@ -39,6 +40,8 @@ const luckysheetformula = { }, errorParamCheck: function(thisp, data, i) { let type, require; + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; if(i < thisp.length){ type = thisp[i].type; require = thisp[i].require; @@ -49,30 +52,30 @@ const luckysheetformula = { } if(require == "o" && (data == null || data == "")){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } if(type.indexOf("all") > -1){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } else{ if(type.indexOf("range") > -1 && (getObjType(data) == "object" || getObjType(data) == "array")){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } if(type.indexOf("number") > -1 && (isRealNum(data) || getObjType(data) == "boolean")){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } if(type.indexOf("string") > -1 && getObjType(data) == "string"){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } if(type.indexOf("date") > -1 && isdatetime(data)){ - return [true, "成功"]; + return [true, locale_formulaMore.tipSuccessText]; } - return [false, "参数类型错误"]; + return [false, locale_formulaMore.tipParamErrorText]; } }, getPureValueByData: function(data){ @@ -787,7 +790,7 @@ const luckysheetformula = { $("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").show(); }, searchHTML: '
    ', - helpHTML: '
    SUM ( A2:A100, 101 )
    示例
    SUM ( A2:A100, 101 )
    摘要
    ${detail}
    ${param}
    ', + helpHTML: '
    SUM ( A2:A100, 101 )
    ${helpExample}
    SUM ( A2:A100, 101 )
    ${helpAbstract}
    ${helpAbstract}
    ${param}
    ', getrangeseleciton: function() { let currSelection = window.getSelection(); let anchor = $(currSelection.anchorNode); @@ -878,6 +881,7 @@ const luckysheetformula = { searchFunctionCell: null, searchFunction: function($editer) { let _this = this; + let functionlist = Store.functionlist; let $cell = _this.getrangeseleciton(); _this.searchFunctionCell = $cell; @@ -989,12 +993,16 @@ const luckysheetformula = { functionlistPosition: {}, helpFunction: function($editer, funcname, paramIndex) { let _this = this; + let functionlist = Store.functionlist; let $func = functionlist[_this.functionlistPosition[$.trim(funcname).toUpperCase()]]; if ($func == null) { return; } + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; + $("#luckysheet-formula-help-c .luckysheet-arguments-help-function-name").html($func.n); $("#luckysheet-formula-help-c .luckysheet-arguments-help-parameter-content").html($func.d); @@ -1020,11 +1028,11 @@ const luckysheetformula = { if (paramitem.repeat == "y") { name += ", ..."; - nameli += '...-可重复'; + nameli += '...-'+locale_formulaMore.allowRepeatText+''; } if (paramitem.require == "o") { name = "[" + name + "]"; - nameli += '-[可选]'; + nameli += '-['+locale_formulaMore.allowOptionText+']'; } fht += '' + name + ', '; @@ -1062,9 +1070,16 @@ const luckysheetformula = { }, helpFunctionExe: function($editer, currSelection) { let _this = this; - + let functionlist = Store.functionlist; + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; if ($("#luckysheet-formula-help-c").length == 0) { - $("body").after(_this.helpHTML); + $("body").after(replaceHtml(_this.helpHTML,{ + helpClose:locale_formulaMore.helpClose, + helpCollapse:locale_formulaMore.helpCollapse, + helpExample:locale_formulaMore.helpExample, + helpAbstract:locale_formulaMore.helpAbstract, + })); $("#luckysheet-formula-help-c .luckysheet-formula-help-close").click(function() { $("#luckysheet-formula-help-c").hide(); }); @@ -4739,6 +4754,9 @@ const luckysheetformula = { }, execfunction: function(txt, r, c, isrefresh, notInsertFunc) { let _this = this; + + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; if(txt.indexOf(_this.error.r) > -1){ return [false, _this.error.r, txt]; @@ -4755,7 +4773,7 @@ const luckysheetformula = { } if (!_this.testFunction(txt, fp) || fp == "") { - tooltip.info("提示", "公式存在错误"); + tooltip.info("",locale_formulaMore.execfunctionError); return [false, _this.error.n, txt]; } @@ -4780,10 +4798,10 @@ const luckysheetformula = { if(funcgRange.sheetIndex == Store.currentSheetIndex && r >= funcgRange.row[0] && r <= funcgRange.row[1] && c >= funcgRange.column[0] && c <= funcgRange.column[1]){ if(isEditMode()){ - alert("公式不可引用其本身的单元格"); + alert(locale_formulaMore.execfunctionSelfError); } else{ - tooltip.info("公式不可引用其本身的单元格,会导致计算结果不准确", ""); + tooltip.info("", locale_formulaMore.execfunctionSelfErrorResult); } diff --git a/src/global/getdata.js b/src/global/getdata.js index dfed0dea5..3b15fa094 100644 --- a/src/global/getdata.js +++ b/src/global/getdata.js @@ -6,7 +6,7 @@ import editor from './editor'; import { dynamicArrayCompute } from './dynamicArray'; import Store from '../store'; -//获取选区范围值 +//Get selection range value export function getdatabyselection(range, sheetIndex) { if(range == null){ range = Store.luckysheet_select_save[0]; @@ -118,7 +118,7 @@ export function getdatabyselectionNoCopy(range) { return data; } -//得到单元格的值 +//Get the value of the cell export function getcellvalue(r, c, data, type) { if (type == null) { type = "v"; @@ -171,7 +171,7 @@ export function getcellvalue(r, c, data, type) { return retv; } -//数据增加行列 +//Data increase in rows and columns export function datagridgrowth(data, addr, addc, iscallback) { if (addr <= 0 && addc <= 0) { return data; diff --git a/src/global/method.js b/src/global/method.js index 7615aeba4..812d993d2 100644 --- a/src/global/method.js +++ b/src/global/method.js @@ -21,7 +21,7 @@ const method = { url = server.loadSheetUrl; } - $("#luckysheet-grid-window-1").append(luckysheetlodingHTML); + $("#luckysheet-grid-window-1").append(luckysheetlodingHTML()); param.currentPage++; let dataType = 'application/json;charset=UTF-8'; @@ -67,7 +67,7 @@ const method = { url = server.loadSheetUrl; } - $("#luckysheet-grid-window-1").append(luckysheetlodingHTML); + $("#luckysheet-grid-window-1").append(luckysheetlodingHTML()); let arg = {"gridKey" : server.gridKey, "index": index}; param = $.extend(true, param, arg); diff --git a/src/global/refresh.js b/src/global/refresh.js index 4f3abe81f..1757c6760 100644 --- a/src/global/refresh.js +++ b/src/global/refresh.js @@ -19,6 +19,12 @@ import { getSheetIndex } from '../methods/get'; import Store from '../store'; function jfrefreshgrid(data, range, cfg, cdformat, RowlChange, isRunExecFunction=true) { + if(data == null){ + data = Store.flowdata; + } + if(range == null){ + range = Store.luckysheet_select_save; + } //单元格数据更新联动 if (isRunExecFunction) { formula.execFunctionExist = []; @@ -268,7 +274,7 @@ function jfrefreshrange(data, range, cdformat) { "curdata": data, "range": range, "sheetIndex": Store.currentSheetIndex, - "cdformat": $.extend(true, [], luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]), + "cdformat": $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]), "curCdformat": cdformat }); } @@ -781,7 +787,7 @@ function jfrefreshgrid_rhcw(rowheight, colwidth){ }, 1); } -//按照scrollHeight, scrollWidth刷新canvas展示数据 +//Refresh the canvas display data according to scrollHeight and scrollWidth function luckysheetrefreshgrid(scrollWidth, scrollHeight) { formula.groupValuesRefresh(); diff --git a/src/global/setdata.js b/src/global/setdata.js index 315550ebe..f2460cb99 100644 --- a/src/global/setdata.js +++ b/src/global/setdata.js @@ -3,9 +3,13 @@ import { isRealNull, isRealNum, valueIsError } from './validate'; import { genarate, update } from './format'; import server from '../controllers/server'; import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting'; +import Store from '../store/index' -//设置单元格的值 +//Set cell value function setcellvalue(r, c, d, v) { + if(d == null){ + d = Store.flowdata; + } let cell = d[r][c]; let vupdate; diff --git a/src/global/tooltip.js b/src/global/tooltip.js index 14dd31ba9..74c563dcd 100644 --- a/src/global/tooltip.js +++ b/src/global/tooltip.js @@ -16,7 +16,7 @@ const tooltip = { "addclass": "", "title": title, "content": content, - "botton": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-info").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(), diff --git a/src/index.html b/src/index.html index 68365816c..4a147c12b 100644 --- a/src/index.html +++ b/src/index.html @@ -32,7 +32,7 @@ luckysheet.create({ container: 'luckysheet', - lang: 'en', + lang: 'zh', plugins: ['chart'], data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable] }) diff --git a/src/locale/en.js b/src/locale/en.js index b6254d843..d699b4478 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -50,6 +50,7 @@ export default { noColorSelectedText:"No color is selected", toolMore:"More", + toolLess:"Less", toolClose:"Close", toolMoreTip:"More features", }, @@ -93,8 +94,28 @@ export default { info:{ detailUpdate: 'New opened', detailSave: 'Local cache restored', - row: 'row', - column: 'column' + row: '', + column: '', + loading:"Loading", + + copy:"Copy", + return:"Exit", + rename:"Rename", + tips:"WorkBook rename", + noName:"Untitled spreadsheet", + wait:"waiting for update", + + add:"Add", + addLast:"more rows at bottom", + backTop:"Back to the top", + pageInfo:'Total ${total},${totalPage} page,current ${currentPage}', + nextPage:"Next", + + tipInputNumber:"Please enter the number", + tipInputNumberLimit:"The increase range is limited to 1-100", + + tipRowHeightLimit:"The value must be between 0 ~ 255", + pageInfoFull:'Total ${total},${totalPage} page,All data displayed', }, currencyDetail:{ RMB:'RMB', @@ -443,6 +464,14 @@ export default { conditionCellBetween:"Is between", conditionCellNotBetween:"Is not between", + filiterMoreDataTip:"Big amount of data! please wait", + filiterMonthText:"Month", + filiterYearText:"Year", + filiterByColorTip:"Filter by cell color", + filiterByTextColorTip:"Filter by font color", + filterContainerOneColorTip:"This column contains only one color", + filterDateFormatTip:"Date format", + }, rightclick: { copy: 'Copy', @@ -533,6 +562,9 @@ export default { splitDataPreview:"Preview", splitTextTitle:"Split text", splitConfirmToExe:"There is already data here, do you want to replace it?", + + tipNoMulti:"Cannot perform this operation on multiple selection areas, please select a single area and try again", + tipNoMultiColumn:"Only one column of data can be converted at a time. The selected area can have multiple rows but not multiple columns. Please try again after selecting a single column range", }, punctuation:{ "tab":"Tab", @@ -613,48 +645,156 @@ export default { resetColor: 'Reset color', cancelText: 'Cancel', chooseText: 'Confirm color', + + tipNameRepeat:"The name of the tab page cannot be repeated! Please revise", + noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.", + confirmDelete:"Are you sure to delete", + redoDelete:"Can be undo by Ctrl+Z", + noHide:"Can't hide, at least keep one sheet tag", + chartEditNoOpt:"This operation is not allowed in chart editing mode!", }, conditionformat: { + conditionformat_greaterThan: 'Conditionformat-GreaterThan', + conditionformat_greaterThan_title: 'Format cells greater than', + conditionformat_lessThan: 'Conditionformat-LessThan', + conditionformat_lessThan_title: 'Format cells smaller than', + conditionformat_betweenness: 'Conditionformat-Betweenness', + conditionformat_betweenness_title: 'Format cells with values between', + conditionformat_equal: 'Conditionformat-Equal', + conditionformat_equal_title: 'Format cells equal to', + conditionformat_textContains: 'Conditionformat-TextContains', + conditionformat_textContains_title: 'Format cells containing the following text', + conditionformat_occurrenceDate: 'Conditionformat-OccurrenceDate', + conditionformat_occurrenceDate_title: 'Format cells containing the following dates', + conditionformat_duplicateValue: 'Conditionformat-DuplicateValue', + conditionformat_duplicateValue_title: 'Format cells containing the following types of values', + conditionformat_top10: 'Conditionformat-Top10', + conditionformat_top10_percent: 'Conditionformat-Top10%', + conditionformat_top10_title: 'Format the cells with the highest value', + conditionformat_last10: 'Conditionformat-Last10', + conditionformat_last10_percent: 'Conditionformat-Last10%', + conditionformat_last10_title: 'Format the cells with the smallest value', + conditionformat_AboveAverage: 'Conditionformat-AboveAverage', + conditionformat_AboveAverage_title: 'Format cells above average', + conditionformat_SubAverage: 'Conditionformat-SubAverage', + conditionformat_SubAverage_title: 'Format cells below average', rule: 'Rule', newRule: 'New rule', editRule: 'Edit rule', deleteRule: 'Delete rule', + deleteCellRule: 'Delete cell rule', + deleteSheetRule: 'Delete sheet rule', + manageRules: 'Management rules', showRules: 'Show its formatting rules', - manageRules: 'Conditional Formatting Rule Manager', + highlightCellRules: 'Highlight cell rules', + itemSelectionRules: 'Item selection rules', + conditionformatManageRules: 'Conditional Formatting Rule Manager', format: 'Format', + setFormat: 'Set format', + setAs: 'Set as', + setAsByArea: 'For the selected area, set to', applyRange: 'Apply range', selectRange: 'Click to select application range', + selectRange_percent: 'Percentage of selected range', + selectRange_average: 'Average value of selected range', + selectRange_value: 'Value in the selected range', + pleaseSelectRange: 'Please select application range', + selectDataRange: 'Click to select data range', + selectCell: 'select cell', + pleaseSelectCell: 'Please select cell', + pleaseSelectADate: 'Please select a date', + pleaseEnterInteger: 'Please enter an integer between 1 and 1000', + onlySingleCell: 'Only a single cell can be referenced', + conditionValueCanOnly: 'The condition value can only be a number or a single cell', ruleTypeItem1: 'Format all cells based on their respective values', ruleTypeItem2: 'Only format cells that contain', + ruleTypeItem2_title: 'Only for cells that meet the following conditions', ruleTypeItem3: 'Format only the top or bottom numbers', + ruleTypeItem3_title: 'Is the value in the following ranking', ruleTypeItem4: 'Format only values above or below the average', + ruleTypeItem4_title: 'Is a value that satisfies the following conditions', ruleTypeItem5: 'Format only unique or repeated values', textColor: 'Text color', cellColor: 'Cell color', confirm: 'Confirm', + confirmColor: 'Confirm color', cancel: 'Cancel', close: 'Close', + clearColorSelect: 'Clear color select', sheet: 'Sheet', currentSheet: 'CurrentSheet', dataBar: 'dataBar', dataBarColor: 'dataBar color', + gradientDataBar_1: 'Blue-white gradient data bar', + gradientDataBar_2: 'Green-white gradient data bar', + gradientDataBar_3: 'Red-white gradient data bar', + gradientDataBar_4: 'Orange-white gradient stripes', + gradientDataBar_5: 'Light blue-white gradient stripes', + gradientDataBar_6: 'Purple-white gradient data bar', + solidColorDataBar_1: 'Blue data bar', + solidColorDataBar_2: 'Green data bar', + solidColorDataBar_3: 'Red data bar', + solidColorDataBar_4: 'Orange data bar', + solidColorDataBar_5: 'Light blue data bar', + solidColorDataBar_6: 'Purple data bar', colorGradation: 'colorGradation', + colorGradation_1: 'Green-yellow-red color gradation', + colorGradation_2: 'Red-yellow-green color gradation', + colorGradation_3: 'Green-white-red color gradation', + colorGradation_4: 'Red-white-green color gradation', + colorGradation_5: 'Blue-white-red color gradation', + colorGradation_6: 'Red-white-blue color gradation', + colorGradation_7: 'White-red color gradation', + colorGradation_8: 'Red-white color gradation', + colorGradation_9: 'Green-white color gradation', + colorGradation_10: 'White-green color gradation', + colorGradation_11: 'Green-yellow color gradation', + colorGradation_12: 'Yellow-green color gradation', icons: 'icons', + pleaseSelectIcon: 'Please click to select a group of icons:', cellValue: 'Cell value', + specificText: 'Specific text', + occurrence: 'Date of occurrence', + greaterThan: 'Greater than', + lessThan: 'Less than', between: 'Between', + equal: 'Equal', in: 'In', between2: '', contain: 'Contain', + textContains: 'Text contains', duplicateValue: 'Duplicate value', uniqueValue: 'Unique value', top: 'Top', + top10: 'Top10', + top10_percent: 'Top10%', last: 'Last', + last10: 'Last10', + last10_percent: 'Last10%', oneself: '', + above: 'Above', aboveAverage: 'Above average', + below: 'Below', belowAverage: 'Below average', + all: 'All', + yesterday: 'Yesterday', + today: 'Today', + tomorrow: 'Tomorrow', + lastWeek: 'Last week', + thisWeek: 'This week', + lastMonth: 'Last month', + thisMonth: 'This month', + lastYear: 'Last year', + thisYear: 'This year', + last7days: 'Last 7 days', + last30days: 'Last 30 days', + next7days: 'Next 7 days', + next30days: 'Next 30 days', + next60days: 'Next 60 days', chooseRuleType: 'Choose rule type', editRuleDescription: 'Edit rule description', newFormatRule: 'New format rule', + editFormatRule: 'Edit format rule', formatStyle: 'Format style', fillType: 'Fill type', color: 'Color', @@ -667,14 +807,29 @@ export default { maxValue: 'Max value', medianValue: 'Median value', minValue: 'Min value', + direction: 'Direction', threeWayArrow: 'Three-way arrow', fourWayArrow: 'Four-way arrow', fiveWayArrow: 'Five-way arrow', threeTriangles: 'Three triangles', + shape: 'Shape', threeColorTrafficLight: 'Three-color traffic light', fourColorTrafficLight: 'Four-color traffic light', + threeSigns: 'Three signs', + greenRedBlackGradient: 'Green-red-black gradient', rimless: 'Rimless', bordered: 'Bordered', + mark: 'Mark', + threeSymbols: 'Three symbols', + tricolorFlag: 'Tricolor flag', + circled: 'Circled', + noCircle: 'No circle', + grade: 'Grade', + grade4: '4 Grade', + grade5: '5 Grade', + threeStars: '3 Stars', + fiveQuadrantDiagram: 'Five-quadrant diagram', + fiveBoxes: '5 Boxes', }, formula:{ sum:"Sum", @@ -738,6 +893,37 @@ export default { "selectFunctionTitle":"Select a function", "calculationResult":"Result", + + tipSuccessText:"Success", + tipParamErrorText:"Parameter type error", + + "helpClose":"Close", + "helpCollapse":"Collapse", + "helpExample":"Example", + "helpAbstract":"Abstract", + + "execfunctionError":'Error in the formula', + "execfunctionSelfError":'Formula cannot refer to its own cell', + "execfunctionSelfErrorResult":'The formula cannot refer to its own cell, which will lead to inaccurate calculation results', + + "allowRepeatText":"Repeat", + "allowOptionText":"Option", + + "selectCategory":"Or select a category", + }, + drag:{ + noMerge:"Cannot perform this operation on merged cells", + affectPivot:"This change cannot be made to the selected cell because it will affect the pivot table!", + noMulti:"Cannot perform this operation on multiple selection areas, please select a single area", + noPaste:"Unable to paste this content here, please select a cell in the paste area and try to paste again", + noPartMerge:"Cannot perform this operation on partially merged cells", + + inputCorrect:"Please enter the correct value", + notLessOne:"The number of rows and columns cannot be less than 1", + offsetColumnLessZero:"The offset column cannot be negative!", + }, + pivotTable:{ + } }; \ No newline at end of file diff --git a/src/locale/zh.js b/src/locale/zh.js index 2872c7660..75169a92e 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -49,6 +49,7 @@ export default { noColorSelectedText:"没有颜色被选择", toolMore:"更多", + toolLess:"少于", toolClose:"收起", toolMoreTip:"更多功能", @@ -94,7 +95,28 @@ export default { detailUpdate: '新打开', detailSave: '已恢复本地缓存', row: '行', - column: '列' + column: '列', + + loading:"渲染中", + copy:"副本", + return:"返回", + rename:"重命名", + tips:"表格重命名", + noName:"无标题的电子表格", + wait:"待更新", + + add:"添加", + addLast:"在底部添加", + backTop:"回到顶部", + pageInfo:'共${total}条,${totalPage}页,当前已显示${currentPage}页', + nextPage:"下一页", + + tipInputNumber:"请输入数字", + tipInputNumberLimit:"增加范围限制在1-100", + + tipRowHeightLimit:"数值必须在0 ~ 255之间", + pageInfoFull:'共${total}条,${totalPage}页,已显示全部数据', + }, currencyDetail:{ RMB:'人民币', @@ -377,6 +399,14 @@ export default { "wrap":"自动换行", "clip":"截断", }, + rotation:{ + "none":"无选装", + "angleup":"向上倾斜", + "angledown":"向下倾斜", + "vertical":"竖排文字", + "rotationUp":"向上90°", + "rotationDown":"向下90°" + }, freezen:{ default:"冻结首行", freezenRow:"冻结首行", @@ -403,6 +433,8 @@ export default { "columnOperation":"列", "secondaryTitle":"次要排序", + "sortTitle":"排序范围", + "sortRangeTitle":"排序范围从", "sortRangeTitleTo":"到", @@ -435,6 +467,8 @@ export default { filterCancel:"取 消", clearFilter:"清除筛选", + + conditionNone:"无", conditionCellIsNull:"单元格为空", conditionCellNotNull:"单元格有数据", @@ -454,6 +488,15 @@ export default { conditionCellNotEqual:"不等于", conditionCellBetween:"介于", conditionCellNotBetween:"不在其中", + + filiterMoreDataTip:"数据量大!请稍后", + filiterMonthText:"月", + filiterYearText:"年", + filiterByColorTip:"按单元格颜色筛选", + filiterByTextColorTip:"按单元格字体颜色筛选", + filterContainerOneColorTip:"本列仅包含一种颜色", + filterDateFormatTip:"日期格式", + }, rightclick: { copy: '复制', @@ -543,6 +586,9 @@ export default { splitDataPreview:"数据预览", splitTextTitle:"文本分列", splitConfirmToExe:"此处已有数据,是否替换它?", + + tipNoMulti:"不能对多重选择区域执行此操作,请选择单个区域,然后再试", + tipNoMultiColumn:"一次只能转换一列数据,选定区域可以有多行,但不能有多列,请在选定单列区域以后再试", }, punctuation:{ "tab":"Tab 键", @@ -622,48 +668,158 @@ export default { resetColor: '重置颜色', cancelText: '取消', chooseText: '确定颜色', + + tipNameRepeat:"标签页的名称不能重复!请重新修改", + noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。", + confirmDelete:"是否删除", + redoDelete:"可以通过Ctrl+Z撤销删除", + noHide:"不能隐藏, 至少保留一个sheet标签", + chartEditNoOpt:"图表编辑模式下不允许该操作!", + }, conditionformat: { + conditionformat_greaterThan: '条件格式——大于', + conditionformat_greaterThan_title: '为大于以下值的单元格设置格式', + conditionformat_lessThan: '条件格式——小于', + conditionformat_lessThan_title: '为小于以下值的单元格设置格式', + conditionformat_betweenness: '条件格式——介于', + conditionformat_betweenness_title: '为介于以下值的单元格设置格式', + conditionformat_equal: '条件格式——等于', + conditionformat_equal_title: '为等于以下值的单元格设置格式', + conditionformat_textContains: '条件格式——文本包含', + conditionformat_textContains_title: '为包含以下文本的单元格设置格式', + conditionformat_occurrenceDate: '条件格式——发生日期', + conditionformat_occurrenceDate_title: '为包含以下日期的单元格设置格式', + conditionformat_duplicateValue: '条件格式——重复值', + conditionformat_duplicateValue_title: '为包含以下类型值的单元格设置格式', + conditionformat_top10: '条件格式——前 10 项', + conditionformat_top10_percent: '条件格式——前 10%', + conditionformat_top10_title: '为值最大的那些单元格设置格式', + conditionformat_last10: '条件格式——最后 10 项', + conditionformat_last10_percent: '条件格式——最后 10%', + conditionformat_last10_title: '为值最小的那些单元格设置格式', + conditionformat_AboveAverage: '条件格式——高于平均值', + conditionformat_AboveAverage_title: '为高于平均值的单元格设置格式', + conditionformat_SubAverage: '条件格式——低于平均值', + conditionformat_SubAverage_title: '为低于平均值的单元格设置格式', rule: '规则', newRule: '新建规则', editRule: '编辑规则', deleteRule: '删除规则', + deleteCellRule: '清除所选单元格的规则', + deleteSheetRule: '清除整个工作表的规则', + manageRules: '管理规则', showRules: '显示其格式规则', - manageRules: '条件格式规则管理器', + highlightCellRules: '突出显示单元格规则', + itemSelectionRules: '项目选取规则', + conditionformatManageRules: '条件格式规则管理器', format: '格式', + setFormat: '设置格式', + setAs: '设置为', + setAsByArea: '针对选定区域,设置为', applyRange: '应用范围', selectRange: '点击选择应用范围', + selectRange_percent: '所选范围的百分比', + selectRange_average: '选定范围的平均值', + selectRange_value: '选定范围中的数值', + pleaseSelectRange: '请选择应用范围', + selectDataRange: '点击选择数据范围', + selectCell: '选择单元格', + pleaseSelectCell: '请选择单元格', + pleaseSelectADate: '请选择日期', + pleaseEnterInteger: '请输入一个介于 1 和 1000 之间的整数', + onlySingleCell: '只能对单个单元格进行引用', + conditionValueCanOnly: '条件值只能是数字或者单个单元格', ruleTypeItem1: '基于各自值设置所有单元格的格式', ruleTypeItem2: '只为包含以下内容的单元格设置格式', + ruleTypeItem2_title: '只为满足以下条件的单元格', ruleTypeItem3: '仅对排名靠前或靠后的数值设置格式', + ruleTypeItem3_title: '为以下排名内的值', ruleTypeItem4: '仅对高于或低于平均值的数值设置格式', + ruleTypeItem4_title: '为满足以下条件的值', ruleTypeItem5: '仅对唯一值或重复值设置格式', textColor: '文本颜色', cellColor: '单元格颜色', confirm: '确定', + confirmColor: '确定颜色', cancel: '取消', close: '关闭', + clearColorSelect: '清除颜色选择', sheet: '表', currentSheet: '当前工作表', dataBar: '数据条', dataBarColor: '数据条颜色', + gradientDataBar_1: '蓝-白渐变数据条', + gradientDataBar_2: '绿-白渐变数据条', + gradientDataBar_3: '红-白渐变数据条', + gradientDataBar_4: '橙-白渐变数据条', + gradientDataBar_5: '浅蓝-白渐变数据条', + gradientDataBar_6: '紫-白渐变数据条', + solidColorDataBar_1: '蓝色数据条', + solidColorDataBar_2: '绿色数据条', + solidColorDataBar_3: '红色数据条', + solidColorDataBar_4: '橙色数据条', + solidColorDataBar_5: '浅蓝色数据条', + solidColorDataBar_6: '紫色数据条', colorGradation: '色阶', + colorGradation_1: '绿-黄-红色阶', + colorGradation_2: '红-黄-绿色阶', + colorGradation_3: '绿-白-红色阶', + colorGradation_4: '红-白-绿色阶', + colorGradation_5: '蓝-白-红色阶', + colorGradation_6: '红-白-蓝色阶', + colorGradation_7: '白-红色阶', + colorGradation_8: '红-白色阶', + colorGradation_9: '绿-白色阶', + colorGradation_10: '白-绿色阶', + colorGradation_11: '绿-黄色阶', + colorGradation_12: '黄-绿色阶', icons: '图标集', + pleaseSelectIcon: '请点击选择一组图标:', cellValue: '单元格值', + specificText: '特定文本', + occurrence: '发生日期', + greaterThan: '大于', + lessThan: '小于', between: '介于', + equal: '等于', in: '和', + to: '到', between2: '之间', contain: '包含', + textContains: '文本包含', duplicateValue: '重复值', uniqueValue: '唯一值', top: '前', + top10: '前 10 项', + top10_percent: '前 10%', last: '后', + last10: '后 10 项', + last10_percent: '后 10%', oneself: '个', + above: '高于', aboveAverage: '高于平均值', + below: '低于', belowAverage: '低于平均值', + all: '全部', + yesterday: '昨天', + today: '今天', + tomorrow: '明天', + lastWeek: '上周', + thisWeek: '本周', + lastMonth: '上月', + thisMonth: '本月', + lastYear: '去年', + thisYear: '本年', + last7days: '最近7天', + last30days: '最近30天', + next7days: '未来7天', + next30days: '未来30天', + next60days: '未来60天', chooseRuleType: '选择规则类型', editRuleDescription: '编辑规则说明', newFormatRule: '新建格式规则', + editFormatRule: '编辑格式规则', formatStyle: '格式样式', fillType: '填充类型', color: '颜色', @@ -676,14 +832,29 @@ export default { maxValue: '最大值', medianValue: '中间值', minValue: '最小值', + direction: '方向', threeWayArrow: '三向箭头', fourWayArrow: '四向箭头', fiveWayArrow: '五向箭头', threeTriangles: '3个三角形', + shape: '形状', threeColorTrafficLight: '三色交通灯', fourColorTrafficLight: '四色交通灯', + threeSigns: '三标志', + greenRedBlackGradient: '绿-红-黑渐变', rimless: '无边框', bordered: '有边框', + mark: '标记', + threeSymbols: '三个符号', + tricolorFlag: '三色旗', + circled: '有圆圈', + noCircle: '无圆圈', + grade: '等级', + grade4: '四等级', + grade5: '五等级', + threeStars: '3个星形', + fiveQuadrantDiagram: '五象限图', + fiveBoxes: '5个框', }, formula:{ sum:"求和", @@ -747,5 +918,36 @@ export default { "selectFunctionTitle":"选择函数", "calculationResult":"计算结果", + + tipSuccessText:"成功", + tipParamErrorText:"参数类型错误", + + "helpClose":"关闭", + "helpCollapse":"收起", + "helpExample":"示例", + "helpAbstract":"摘要", + + "execfunctionError":'提示", "公式存在错误', + "execfunctionSelfError":'公式不可引用其本身的单元格', + "execfunctionSelfErrorResult":'公式不可引用其本身的单元格,会导致计算结果不准确', + + "allowRepeatText":"可重复", + "allowOptionText":"可选", + + "selectCategory":"或选择类别", + }, + drag:{ + noMerge:"无法对合并单元格执行此操作", + affectPivot:"无法对所选单元格进行此更改,因为它会影响数据透视表!", + noMulti:"无法对多重选择区域执行此操作,请选择单个区域", + noPaste:"无法在此处粘贴此内容,请选择粘贴区域的一个单元格,然后再次尝试粘贴", + noPartMerge:"无法对部分合并单元格执行此操作", + + inputCorrect:"请输入正确的数值", + notLessOne:"行列数不能小于1", + offsetColumnLessZero:"偏移列不能为负数!", + }, + pivotTable:{ + } }; diff --git a/src/store/index.js b/src/store/index.js index 2d48c5139..1c72c1733 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -84,7 +84,10 @@ const Store = { lang: 'en', //language createChart: '', highlightChart: '', - zIndex: 15 + zIndex: 15, + + functionList:null, //function list explanation + luckysheet_function:null, } export default Store; \ No newline at end of file