From 040bfe4b456eb910dc7ddbcc3f5ae0e42d440951 Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Wed, 29 Jul 2020 14:59:58 +0800 Subject: [PATCH 1/3] feat(zh en): zh en zh en --- src/controllers/conditionformat.js | 467 +++++++++++++++------------ src/controllers/menuButton.js | 502 ++++++++++++++--------------- src/locale/en.js | 116 +++++++ src/locale/zh.js | 117 +++++++ 4 files changed, 737 insertions(+), 465 deletions(-) diff --git a/src/controllers/conditionformat.js b/src/controllers/conditionformat.js index c9d3c6e..c54e1f0 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") @@ -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/menuButton.js b/src/controllers/menuButton.js index af19b5e..e37b712 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/locale/en.js b/src/locale/en.js index b6254d8..bdb8625 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -615,46 +615,147 @@ export default { chooseText: 'Confirm color', }, 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', + highlightCellRules: 'Highlight cell rules', + itemSelectionRules: 'Item selection rules', manageRules: '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 +768,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", diff --git a/src/locale/zh.js b/src/locale/zh.js index 2872c76..ec159ec 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -624,46 +624,148 @@ export default { chooseText: '确定颜色', }, 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: '显示其格式规则', + highlightCellRules: '突出显示单元格规则', + itemSelectionRules: '项目选取规则', manageRules: '条件格式规则管理器', 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 +778,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:"求和", From 8baf378407f67684b77e62bacf6894e4359ed2d3 Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Wed, 29 Jul 2020 17:17:09 +0800 Subject: [PATCH 2/3] fix(bug): bug bug --- src/controllers/conditionformat.js | 2 +- src/global/draw.js | 1439 ---------------------------- src/locale/en.js | 2 +- src/locale/zh.js | 2 +- 4 files changed, 3 insertions(+), 1442 deletions(-) diff --git a/src/controllers/conditionformat.js b/src/controllers/conditionformat.js index c54e1f0..e50207f 100644 --- a/src/controllers/conditionformat.js +++ b/src/controllers/conditionformat.js @@ -1642,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": ` `, diff --git a/src/global/draw.js b/src/global/draw.js index 8ab294d..6ebbc9b 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -2302,1445 +2302,6 @@ function getCellValueSize(cell, value, canvas, cellWidth, cellHeight, space_widt } } -// 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; - -// 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); - -// menuButton.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed); - -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } - -// let borderBottomRender = 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 + 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(); -// } - -// let borderTopRender = 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 + 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); - -// menuButton.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed); - -// canvas.strokeStyle = color; - -// canvas.stroke(); -// canvas.closePath(); -// canvas.restore(); -// } - -// 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 -// ); -// } -// } - function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas) { if (scrollWidth == null) { scrollWidth = $("#luckysheet-cell-main").scrollLeft(); diff --git a/src/locale/en.js b/src/locale/en.js index 554ef75..d699b44 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -688,7 +688,7 @@ export default { showRules: 'Show its formatting rules', highlightCellRules: 'Highlight cell rules', itemSelectionRules: 'Item selection rules', - manageRules: 'Conditional Formatting Rule Manager', + conditionformatManageRules: 'Conditional Formatting Rule Manager', format: 'Format', setFormat: 'Set format', setAs: 'Set as', diff --git a/src/locale/zh.js b/src/locale/zh.js index 7e3e98d..75169a9 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -712,7 +712,7 @@ export default { showRules: '显示其格式规则', highlightCellRules: '突出显示单元格规则', itemSelectionRules: '项目选取规则', - manageRules: '条件格式规则管理器', + conditionformatManageRules: '条件格式规则管理器', format: '格式', setFormat: '设置格式', setAs: '设置为', From f19a26eab08bc44a5c380afd883d4e730f681062 Mon Sep 17 00:00:00 2001 From: liurunze <1414556676@qq.com> Date: Wed, 29 Jul 2020 18:43:54 +0800 Subject: [PATCH 3/3] docs(api): api luckysheet function BREAKING CHANGE: 1. luckysheet.flowdata change to luckysheet.flowdata() 2.all apis list in documentation --- docs/.vuepress/config.js | 14 ++- docs/guide/FAQ.md | 24 ++++ docs/guide/feature.md | 138 ++++++++++++--------- docs/guide/format.md | 255 +++++++++++++++++++++++++++++++------- docs/zh/guide/FAQ.md | 15 --- docs/zh/guide/feature.md | 129 +++++++++++-------- docs/zh/guide/format.md | 220 ++++++++++++++++++++++++++++---- src/controllers/select.js | 2 +- src/core.js | 49 ++++++-- src/global/getdata.js | 6 +- src/global/refresh.js | 8 +- src/global/setdata.js | 6 +- src/index.html | 2 +- 13 files changed, 652 insertions(+), 216 deletions(-) create mode 100644 docs/guide/FAQ.md diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 75e9f09..65962bb 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 0000000..eed5db5 --- /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/feature.md b/docs/guide/feature.md index d3e9047..9bb1a65 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 4ad0854..61d2425 100644 --- a/docs/guide/format.md +++ b/docs/guide/format.md @@ -175,50 +175,217 @@ The format is set to: } ``` -|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 index 5c59b26..37f8767 100644 --- a/docs/zh/guide/FAQ.md +++ b/docs/zh/guide/FAQ.md @@ -21,19 +21,4 @@ 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),例举了可用的单元格格式 ------------- -## luckysheetfile中的data和celldata有什么区别? - -**A** : - ------------- -## luckysheetfile中的data和celldata有什么区别? - -**A** : - ------------- -## luckysheetfile中的data和celldata有什么区别? - -**A** : - ------------ \ No newline at end of file diff --git a/docs/zh/guide/feature.md b/docs/zh/guide/feature.md index e25ba63..14085f2 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 354084f..8069909 100644 --- a/docs/zh/guide/format.md +++ b/docs/zh/guide/format.md @@ -181,28 +181,14 @@ |t|Type类型|如"g"| 可选择的设置如下: -| 格式 | ct.fa值 | ct.t值 | m值示例 |备注 | +| 格式 | ct.fa | ct.t | m 值示例 |备注 | |----------|----------|-------------------------|------------------------- |------------------------- | -| 自动 | General | g | Luckysheet || +| 自动 | General | g | Luckysheet || | 纯文本 | @ | s | Luckysheet || |


    **数字格式** | | | | | -| 整数 | 0 | n | 1235 | 0位小数 || -| 数字一位小数 | 0.0 | n | 1234.6 | 0.0中,点后面0的个数就代表小数位数,原始数字位数大,设置位数小时会做四舍五入 | +| 整数 | 0 | n | 1235 | 0位小数 || +| 数字一位小数 | 0.0 | n | 1234.6 | 点后面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 || @@ -212,13 +198,195 @@ | 万元 | 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 || -| 货币 | ¥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 \ No newline at end of file +注意: 导入/导出只用考虑用户看到的数据样式,例如excel中处理日期格式的方式为把日期统一转换为数字:42736 代表 2017-1-1 \ No newline at end of file diff --git a/src/controllers/select.js b/src/controllers/select.js index beb1185..03a4078 100644 --- a/src/controllers/select.js +++ b/src/controllers/select.js @@ -22,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(); diff --git a/src/core.js b/src/core.js index 1714f62..3eacee3 100644 --- a/src/core.js +++ b/src/core.js @@ -14,13 +14,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 = {}; @@ -130,17 +132,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/global/getdata.js b/src/global/getdata.js index dfed0de..3b15fa0 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/refresh.js b/src/global/refresh.js index 4f3abe8..d5e3446 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 = []; @@ -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 315550e..f2460cb 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/index.html b/src/index.html index 6836581..4a147c1 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] })