From 863410f6eb47169dd02767a26e9c83d9df026ec4 Mon Sep 17 00:00:00 2001 From: kdevilpf <459373440@qq.com> Date: Thu, 17 Dec 2020 14:38:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86src/methods/get.?= =?UTF-8?q?js=E7=9A=84getRangetxt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/methods/get.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/methods/get.js b/src/methods/get.js index 55461cc..606b8db 100644 --- a/src/methods/get.js +++ b/src/methods/get.js @@ -19,7 +19,17 @@ function getRangetxt(sheetIndex, range, currentIndex) { } if (sheetIndex != currentIndex) { - sheettxt = Store.luckysheetfile[getSheetIndex(sheetIndex)].name + "!"; + //sheet名字包含'的,引用时应该替换为'' + sheettxt = Store.luckysheetfile[getSheetIndex(sheetIndex)].name.replace(/'/g,"''"); + //如果包含除a-z、A-Z、0-9、下划线等以外的字符那么就用单引号包起来 + if(/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/.test(sheettxt)) + { + sheettxt = sheettxt+"!"; + } + else + { + sheettxt="'"+sheettxt+"'!"; + } } let row0 = range["row"][0], row1 = range["row"][1]; @@ -86,4 +96,4 @@ export { getconfig, getvisibledatarow, getvisibledatacolumn, -} \ No newline at end of file +} From 364314aac3956889ba405199ceaaf8e141404f2d Mon Sep 17 00:00:00 2001 From: kdevilpf <459373440@qq.com> Date: Thu, 17 Dec 2020 16:22:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?sheet=E5=90=8D=E7=A7=B0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=92=8Cexcel=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/sheetBar.js | 7 +++++-- src/locale/zh.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/sheetBar.js b/src/controllers/sheetBar.js index df8aacb..b15bb67 100644 --- a/src/controllers/sheetBar.js +++ b/src/controllers/sheetBar.js @@ -281,9 +281,12 @@ export function initialSheetBar(){ let $t = $(this); let txt = $t.text(), oldtxt = $t.data("oldtxt"); - var reg1 = new RegExp("[\\[\\]:\\?*\/'\"]"); - if(reg1.test(txt)){ + if(txt.length>31 || txt.charAt(0)=="'" || txt.charAt(txt.length-1)=="'" || /[:\:\\\/?\?\*\[\]]+/.test(txt)){ alert(locale_sheetconfig.sheetNameSpecCharError); + setTimeout(()=>{ + luckysheetsheetnameeditor($(this)); + $(this).focus(); + }, 1); return; } diff --git a/src/locale/zh.js b/src/locale/zh.js index 65612e5..7a83126 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -9769,7 +9769,7 @@ export default { redoDelete:"可以通过Ctrl+Z撤销删除", noHide:"不能隐藏, 至少保留一个sheet标签", chartEditNoOpt:"图表编辑模式下不允许该操作!", - sheetNameSpecCharError:"名称不能包含:[ ] : \ ? * / ' \"", + sheetNameSpecCharError:"名称不能超过31个字符,首尾不能是' 且名称不能包含:\r\n[ ] : \\ ? * /", sheetNamecannotIsEmptyError:"名称不能为空" }, conditionformat: {