diff --git a/packages/sheets-conditional-format/src/services/calculate-unit/color-scale.ts b/packages/sheets-conditional-format/src/services/calculate-unit/color-scale.ts index 66816156aca..841c47000cf 100644 --- a/packages/sheets-conditional-format/src/services/calculate-unit/color-scale.ts +++ b/packages/sheets-conditional-format/src/services/calculate-unit/color-scale.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ColorKit, ObjectMatrix, Range } from '@univerjs/core'; +import { CellValueType, ColorKit, ObjectMatrix, Range } from '@univerjs/core'; import { isObject } from '@univerjs/engine-render'; import { RuleType } from '../../base/const'; import type { IColorScale, IConditionFormatRule } from '../../models/type'; @@ -34,7 +34,7 @@ export const colorScaleCellCalculateUnit: ICalculateUnit = { Range.foreach(range, (row, col) => { const cell = worksheet?.getCellRaw(row, col); const v = cell && cell.v; - if (!isNullable(v)) { + if (!isNullable(v) && cell?.t === CellValueType.NUMBER) { const _value = Number(v); !Number.isNaN(_value) && matrix.setValue(row, col, _value); } diff --git a/packages/sheets-conditional-format/src/services/calculate-unit/data-bar.ts b/packages/sheets-conditional-format/src/services/calculate-unit/data-bar.ts index 4f8537c17e5..bb181aa4c09 100644 --- a/packages/sheets-conditional-format/src/services/calculate-unit/data-bar.ts +++ b/packages/sheets-conditional-format/src/services/calculate-unit/data-bar.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ObjectMatrix, Range } from '@univerjs/core'; +import { CellValueType, ObjectMatrix, Range } from '@univerjs/core'; import { RuleType } from '../../base/const'; import type { IDataBarRenderParams } from '../../render/type'; import type { IConditionFormatRule, IDataBar } from '../../models/type'; @@ -36,7 +36,7 @@ export const dataBarCellCalculateUnit: ICalculateUnit = { Range.foreach(range, (row, col) => { const cell = worksheet?.getCellRaw(row, col); const v = cell && cell.v; - if (!isNullable(v)) { + if (!isNullable(v) && cell?.t === CellValueType.NUMBER) { const _value = Number(v); !Number.isNaN(_value) && matrix.setValue(row, col, _value); } diff --git a/packages/sheets-conditional-format/src/services/calculate-unit/highlight-cell.ts b/packages/sheets-conditional-format/src/services/calculate-unit/highlight-cell.ts index 5eb8354d515..60ed7b648fb 100644 --- a/packages/sheets-conditional-format/src/services/calculate-unit/highlight-cell.ts +++ b/packages/sheets-conditional-format/src/services/calculate-unit/highlight-cell.ts @@ -110,7 +110,7 @@ export const highlightCellCalculateUnit: ICalculateUnit = { switch (ruleConfig.subType) { case SubRuleType.number:{ const v = cellValue && Number(cellValue.v); - if (isNullable(v) || Number.isNaN(v)) { + if (isNullable(v) || Number.isNaN(v) || cellValue?.t !== CellValueType.NUMBER) { return false; } const subRuleConfig = ruleConfig as INumberHighlightCell; @@ -160,7 +160,7 @@ export const highlightCellCalculateUnit: ICalculateUnit = { } case SubRuleType.timePeriod:{ const value = getCellValue(cellValue!); - if (isNullable(value) || Number.isNaN(Number(value))) { + if (isNullable(value) || Number.isNaN(Number(value)) || cellValue?.t !== CellValueType.NUMBER) { return false; } const subRuleConfig = ruleConfig as ITimePeriodHighlightCell; @@ -228,7 +228,7 @@ export const highlightCellCalculateUnit: ICalculateUnit = { case SubRuleType.average:{ const value = cellValue && cellValue.v; const v = Number(value); - if (isNullable(value) || Number.isNaN(v)) { + if (isNullable(value) || Number.isNaN(v) || cellValue?.t !== CellValueType.NUMBER) { return false; } const subRuleConfig = ruleConfig as IAverageHighlightCell; @@ -263,7 +263,7 @@ export const highlightCellCalculateUnit: ICalculateUnit = { const v = Number(value); - if (isNullable(value) || Number.isNaN(v)) { + if (isNullable(value) || Number.isNaN(v) || cellValue?.t !== CellValueType.NUMBER) { return false; } diff --git a/packages/sheets-conditional-format/src/services/calculate-unit/icon-set.ts b/packages/sheets-conditional-format/src/services/calculate-unit/icon-set.ts index b835d7cf61e..5a6ab0a6d91 100644 --- a/packages/sheets-conditional-format/src/services/calculate-unit/icon-set.ts +++ b/packages/sheets-conditional-format/src/services/calculate-unit/icon-set.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ObjectMatrix, Range } from '@univerjs/core'; +import { CellValueType, ObjectMatrix, Range } from '@univerjs/core'; import type { NumberOperator } from '../../base/const'; import { RuleType } from '../../base/const'; @@ -38,7 +38,7 @@ export const iconSetCalculateUnit: ICalculateUnit = { Range.foreach(range, (row, col) => { const cell = worksheet?.getCellRaw(row, col); const v = cell && cell.v; - if (!isNullable(v)) { + if (!isNullable(v) && cell?.t === CellValueType.NUMBER) { const _value = Number(v); !Number.isNaN(_value) && matrix.setValue(row, col, _value); }