作成日: 2023/12/04 最終更新日: 2024/02/28
文書種別
不具合
状況
修正済み
詳細
セルに書式を設定しない状態で、()で括った数値を入力すると負数として表示されます。
例)
(10) → -10
しかし、セルに書式を設定した場合()で括った数値は、負数では無く文字列として認識されます。
回避方法
SpreadJS (Ver.17.0.4)で修正済み。
Ver.17.0.4より前のバージョンでは、セル編集時に入力値変換処理を追加することで回避可能です。
サンプルコード
var editCellCmdExecFn = GC.Spread.Sheets.Commands.editCell.execute;
GC.Spread.Sheets.Commands.editCell.execute = function (context, options, isUndo) {
var sheet = context.getSheetFromName(options.sheetName), row = options.row, col = options.col, sheetArea = options.sheetArea;
var fmt = sheet?.getFormatter(row, col, sheetArea), newVal = options.newValue;
if (fmt && fmt !== '@' && newVal !== null && newVal !== undefined && typeof newVal === 'string') {
const ret = newVal.match(/^\((?<num>\d*\.?\d*)\)$/);
if (ret && ret[0] === newVal && ret[0] !== '()') {
options.newValue = (+ret.groups.num * -1) + '';
}
}
return editCellCmdExecFn.apply(this, arguments);
}