diff --git a/src/BlazorDatasheet.Core/Edit/Editor.cs b/src/BlazorDatasheet.Core/Edit/Editor.cs index 0dd1f372..b20002b2 100644 --- a/src/BlazorDatasheet.Core/Edit/Editor.cs +++ b/src/BlazorDatasheet.Core/Edit/Editor.cs @@ -85,6 +85,7 @@ public Editor(Sheet sheet) /// /// If true, the editor should hold on to the edit when arrow keys are pressed. /// Details on the method that was used to begin the edit. + /// Details on the method that was used to begin the edit. /// The key that was used to begin the edit, if the entry mode was using the keyboard public void BeginEdit(int row, int col, bool isSoftEdit = true, EditEntryMode mode = EditEntryMode.None, string? key = null) @@ -155,7 +156,7 @@ public bool AcceptEdit() } var formulaResult = isFormula ? Sheet.FormulaEngine.Evaluate(parsedFormula) : CellValue.Empty; - var editValue = isFormula ? formulaResult : new CellValue(this.EditValue); + var editValue = isFormula ? formulaResult : GetValueAsCellValue(EditCell.Row, EditCell.Col, EditValue); var beforeAcceptEdit = new BeforeAcceptEditEventArgs(EditCell, editValue, parsedFormula, formulaString); BeforeEditAccepted?.Invoke(this, beforeAcceptEdit); @@ -196,6 +197,18 @@ public bool AcceptEdit() return false; } + private CellValue GetValueAsCellValue(int row, int col, string editValue) + { + var type = Sheet.Cells.GetCellType(row, col); + switch (type) + { + case "text": + return CellValue.Text(editValue); + } + + return new CellValue(editValue); + } + private void ClearEdit() { IsEditing = false; diff --git a/src/BlazorDatasheet/DatasheetRow.razor b/src/BlazorDatasheet/DatasheetRow.razor index 1520197c..f7559699 100644 --- a/src/BlazorDatasheet/DatasheetRow.razor +++ b/src/BlazorDatasheet/DatasheetRow.razor @@ -73,6 +73,7 @@ @switch (visualCell.CellType) { case "default": + case "text": case "datetime":