Duplicated
Last Updated: 12 Jul 2024 14:19 by ADMIN
Jeremy
Created on: 10 Jul 2024 22:20
Category: Spreadsheet
Type: Feature Request
1
SpreadsheetCustomTool current cell selection

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);

Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
0 comments