Browse Source

fix(internationalization): internationalization,formula

internationalization,formula
master
liurunze 5 years ago
parent
commit
c6901fc884
  1. 2
      docs/guide/data.md
  2. 64
      docs/guide/format.md
  3. 39
      docs/zh/guide/FAQ.md
  4. 2
      docs/zh/guide/data.md
  5. 152
      docs/zh/guide/format.md
  6. 21
      src/controllers/insertFormula.js
  7. 4
      src/core.js
  8. 2
      src/function/functionImplementation.js
  9. 8881
      src/function/functionlist.js
  10. 7
      src/global/formula.js
  11. 2
      src/index.html
  12. 8
      src/locale/zh.js
  13. 5
      src/store/index.js

2
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,

64
docs/guide/format.md

@ -64,13 +64,7 @@
<td>cancelline</td>
<td>Cancelline</td>
<td>0 Regular, 1 Cancelline</td>
<td rowspan="2">Style.Font object's Underline property</td>
</tr>
<tr>
<td>ul</td>
<td>underline</td>
<td>Underline</td>
<td>0 Regular, 1 Underline</td>
<td>Style.Font object's Underline property</td>
</tr>
<tr>
<td>vt</td>
@ -100,13 +94,6 @@
<td>0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90</td>
<td>setRotationAngle</td>
</tr>
<tr>
<td>fl</td>
<td>floatlenght</td>
<td>Decimal places</td>
<td>3</td>
<td></td>
</tr>
<tr>
<td>tb</td>
<td>textbeak</td>
@ -115,15 +102,15 @@
<td>2: setTextWrapped <br> 0和1: IsTextWrapped =&nbsp;true</td>
</tr>
<tr>
<td>ov</td>
<td>originvalue</td>
<td>v</td>
<td>value</td>
<td>Original value</td>
<td></td>
<td></td>
</tr>
<tr>
<td>v</td>
<td>value</td>
<td>m</td>
<td>monitor</td>
<td>Display value</td>
<td></td>
<td></td>
@ -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,13 +166,12 @@ The format is set to:
```json
{
"v": "",
"f": "",
"ct": {
"v": 1,
"f": "#,##0.00",
"t": " Decimal"
}
"fa": "General",
"t": "g"
},
"m": "2424",
"v": 2424
}
```

39
docs/zh/guide/FAQ.md

@ -0,0 +1,39 @@
# FAQ
## luckysheetfile中的data和celldata有什么区别?
**<span style="font-size:20px;">A</span>** : 表格初始化时使用一维数组格式的 [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)
```
------------
## 单元格的类型有哪些?
**<span style="font-size:20px;">A</span>** : 参考[单元格格式列表](https://mengshukeji.github.io/LuckysheetDocs/zh/guide/format.html#%E5%8D%95%E5%85%83%E6%A0%BC%E6%A0%BC%E5%BC%8F),例举了可用的单元格格式
------------
## luckysheetfile中的data和celldata有什么区别?
**<span style="font-size:20px;">A</span>** :
------------
## luckysheetfile中的data和celldata有什么区别?
**<span style="font-size:20px;">A</span>** :
------------
## luckysheetfile中的data和celldata有什么区别?
**<span style="font-size:20px;">A</span>** :
------------

2
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,

152
docs/zh/guide/format.md

@ -64,13 +64,7 @@
<td>cancelline</td>
<td>删除线</td>
<td>0 常规 、 1 删除线</td>
<td rowspan="2">Style.Font object's Underline property</td>
</tr>
<tr>
<td>ul</td>
<td>underline</td>
<td>下划线</td>
<td>0 常规 、 1 下划线</td>
<td>Style.Font object's Underline property</td>
</tr>
<tr>
<td>vt</td>
@ -100,13 +94,6 @@
<td>0: 0、1: 45 、2:-45、3 竖排文字、4: 90 、5:-90</td>
<td>setRotationAngle</td>
</tr>
<tr>
<td>fl</td>
<td>floatlenght</td>
<td>小数位数</td>
<td>3</td>
<td></td>
</tr>
<tr>
<td>tb</td>
<td>textbeak</td>
@ -115,15 +102,15 @@
<td>2:setTextWrapped <br> 0和1:IsTextWrapped =&nbsp;true</td>
</tr>
<tr>
<td>ov</td>
<td>originvalue</td>
<td>v</td>
<td>value</td>
<td>原始值</td>
<td></td>
<td></td>
</tr>
<tr>
<td>v</td>
<td>value</td>
<td>m</td>
<td>monitor</td>
<td>显示值</td>
<td></td>
<td></td>
@ -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,59 @@
```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();`<br>`currencyStyle.Number = 8;`|
|f|Format:格式的定义串 `$#,##0;$-#,##0`|`var currencyStyle = book.CreateStyle();`<br>`currencyStyle.Custom  = "#,##0 SEK";`|
|t|Type类型:<br>0:General<br>1:Decimal<br>2:Currency<br>3:Percentage<br>4:Scientific<br>5:Fraction<br>6:Date<br>7:Time<br>8:Accounting<br>9:Text<br>10:DateTime|类型是前端区分的格式,excel导入时根据导入format字符的关键字来区分是哪种类型:<br>1.含YYYY、MM、DD的是6|
|fa|Format格式的定义串| 如"General"|
|t|Type类型|如"g"|
可选择的设置如下:
| 格式 | ct.fa值 | ct.t值 | m值示例 |备注 |
|----------|----------|-------------------------|------------------------- |------------------------- |
| 自动 | General | g | Luckysheet ||
| 纯文本 | @ | s | Luckysheet ||
| <br><br><br>**数字格式** | | | | |
| 整数 | 0 | n | 1235 | 0位小数 ||
| 数字一位小数 | 0.0 | n | 1234.6 | 0.0中,点后面0的个数就代表小数位数,原始数字位数大,设置位数小时会做四舍五入 |
| 数字两位小数 | 0.00 | n | 1234.56 ||
| 更多数字格式 | #,##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 ||
| 百分比整数 | 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 ||
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 | @ |
| 货币 | ¥0.00 或者 ¥ #.00 | n ||
| 日期 | yyyy-MM-dd | d ||
| 时间 | hh:mm AM/PM | d ||
| 时间24H | hh:mm | d ||
| 日期时间 | yyyy-MM-dd hh:mm AM/PM | d ||
| 日期时间24H | yyyy-MM-dd hh:mm | d ||
| 日期时间24H | yyyy-MM-dd hh:mm | d ||
导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1
导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1

21
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;
}
//参数选区显示,参数值显示
@ -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;

4
src/core.js

@ -19,6 +19,7 @@ import {
setconfig,
} from './methods/set';
import { luckysheetrefreshgrid } from './global/refresh';
import functionlist from './function/functionlist';
let luckysheet = {};
@ -81,6 +82,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;

2
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;
}

8881
src/function/functionlist.js

File diff suppressed because it is too large

7
src/global/formula.js

@ -18,8 +18,8 @@ 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';
@ -878,6 +878,7 @@ const luckysheetformula = {
searchFunctionCell: null,
searchFunction: function($editer) {
let _this = this;
let functionlist = Store.functionlist;
let $cell = _this.getrangeseleciton();
_this.searchFunctionCell = $cell;
@ -989,6 +990,7 @@ 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) {
@ -1062,6 +1064,7 @@ const luckysheetformula = {
},
helpFunctionExe: function($editer, currSelection) {
let _this = this;
let functionlist = Store.functionlist;
if ($("#luckysheet-formula-help-c").length == 0) {
$("body").after(_this.helpHTML);

2
src/index.html

@ -32,7 +32,7 @@
luckysheet.create({
container: 'luckysheet',
lang: 'zh',
lang: 'en',
plugins: ['chart'],
data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable]
})

8
src/locale/zh.js

@ -377,6 +377,14 @@ export default {
"wrap":"自动换行",
"clip":"截断",
},
rotation:{
"none":"无选装",
"angleup":"向上倾斜",
"angledown":"向下倾斜",
"vertical":"竖排文字",
"rotationUp":"向上90°",
"rotationDown":"向下90°"
},
freezen:{
default:"冻结首行",
freezenRow:"冻结首行",

5
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;
Loading…
Cancel
Save