I'm attempting to create a custom spreadsheet tool that updates the values of the cells the user has selected. The problem is that I can't get the current cell selection from the TelerikSpreadsheet control.
I attempted to get it by exporting it from the control and importing it into an XlsxFormatProvider. I thought what I needed might be in the 'Worksheet.ViewState.SelectionState.ActiveCellIndex' object but it always seems to be set to Cell[0,0]. Is there somewhere else I can find the selection?
The following code works but always updates A1.
byte[] excelFileContent = await SpreadsheetRef.ExportToExcelAsync();
XlsxFormatProvider formatProvider = new();
Workbook workbook = formatProvider.Import(excelFileContent);
Worksheet worksheet = workbook.ActiveWorksheet;
CellIndex cellRange = worksheet.ViewState.SelectionState.ActiveCellIndex;
worksheet.Cells.GetCellSelection(cellRange).SetValue("Selected!!");
byte[] newExcelFileContent;
using (MemoryStream ms = new())
{
formatProvider.Export(workbook, ms);
newExcelFileContent = ms.ToArray();
}
FileData = newExcelFileContent;
await InvokeAsync(StateHasChanged);