From 328209a72b6cc7dba5374263802d3a537a3d9520 Mon Sep 17 00:00:00 2001 From: Dmitriy Orlov Date: Thu, 29 Aug 2024 15:14:03 +0600 Subject: [PATCH] Changed where the string is processed to get the table column Added string changes when clicking on a range inside the table --- cell/model/FormulaObjects/parserFormula.js | 16 ++++++---------- cell/model/Workbook.js | 3 +-- cell/model/WorkbookElems.js | 4 ++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cell/model/FormulaObjects/parserFormula.js b/cell/model/FormulaObjects/parserFormula.js index 78ee89d170..e524252950 100644 --- a/cell/model/FormulaObjects/parserFormula.js +++ b/cell/model/FormulaObjects/parserFormula.js @@ -2369,11 +2369,9 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara if (this.hdtIndexes.length > 0 && this.isDynamic && isLocal && this.hdtIndexes[0] === AscCommon.FormulaTablePartInfo.thisRow) { let hdtcstart = this.hdtcstartIndex ? this.hdtcstartIndex.name.replace(/([#[\]])/g, "'$1") : null; let hdtcend = this.hdtcendIndex ? this.hdtcendIndex.name.replace(/([#[\]])/g, "'$1") : null; - // TODO вместо replace, попоробовать изменять строку ТОЛЬКО при получении столбца при первом парсинге + // replace all single quotes with double-single quote hdtcstart = hdtcstart ? hdtcstart.replace(/'/g, "''") : hdtcstart; - - // replace all single quotes with double-single quote hdtcend = hdtcend ? hdtcend.replace(/'/g, "''") : hdtcend; tblStr += "@"; @@ -2434,7 +2432,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara startCol = val['oneColumn'].replace(/'([#[\]])/g, '$1'); // replace all double-single quotes with single quote - startCol = startCol.replace(/''/g, "'"); + // startCol = startCol.replace(/''/g, "'"); if (startCol[0] === "@") { this.isDynamic = true; @@ -2447,10 +2445,8 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara endCol = val['colEnd'].replace(/'([#[\]])/g, '$1'); // replace all double-single quotes with single quote - startCol = startCol.replace(/''/g, "'"); - - // replace all double-single quotes with single quote - endCol = endCol ? endCol.replace(/''/g, "'") : startCol; + // startCol = startCol.replace(/''/g, "'"); + // endCol = endCol ? endCol.replace(/''/g, "'") : startCol; if (!endCol) { endCol = startCol; @@ -2489,7 +2485,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara startCol = hdtcstart.replace(/'([#[\]])/g, '$1'); // replace all double-single quotes with single quote - startCol = startCol.replace(/''/g, "'"); + // startCol = startCol.replace(/''/g, "'"); this.hdtcstartIndex = this.wb.getTableIndexColumnByName(this.tableName, startCol); bRes = !!this.hdtcstartIndex; @@ -2497,7 +2493,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara endCol = hdtcend.replace(/'([#[\]])/g, '$1'); // replace all double-single quotes with single quote - startCol = startCol.replace(/''/g, "'"); + // endCol = endCol.replace(/''/g, "'"); this.hdtcendIndex = this.wb.getTableIndexColumnByName(this.tableName, endCol); bRes = !!this.hdtcendIndex; diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 0ee7c19f06..3b6d9d1da8 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -8492,9 +8492,8 @@ { if(this.TableParts[i].DisplayName.toLowerCase() === tableName.toLowerCase()) { - // todo при открытии файла можно использовать этот вариант вместо нескольких .replace в _parseVal // replace all double-single quotes with single quotes - // columnName = columnName.replace(/''/g, "'"); + columnName = columnName.replace(/''/g, "'"); res = this.TableParts[i].getTableIndexColumnByName(columnName); break; diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index e5040896d1..809531bd20 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -9014,6 +9014,10 @@ function RangeDataManagerElem(bbox, data) let startCol = this.getTableNameColumnByIndex(handleSelectionRange.c1 - this.Ref.c1); let endCol = this.getTableNameColumnByIndex(handleSelectionRange.c2 - this.Ref.c1); + // replace single quote with double-single quotes + startCol = startCol.replace(/'/g, "''"); + endCol = endCol.replace(/'/g, "''"); + if (this.Ref.isEqual(handleSelectionRange)) { //Table1[#All] return this.DisplayName + "[" + AscCommon.cStrucTableReservedWords.all + "]";