Changing the active sheet in ASP.NET Core Spreadsheet control
24 Jul 20261 minute to read
You can change the active sheet of the imported file by updating the activeSheetIndex property in the openComplete event.
To change the active sheet after importing an Excel file:
- Bind the
openCompleteevent to the Spreadsheet. - In the event handler, set the
activeSheetIndexproperty to the index of the sheet you want to activate. - Open an Excel file in the Spreadsheet.
- After the file is loaded, the Spreadsheet displays the sheet specified by the
activeSheetIndexproperty.
The following code example demonstrates how to change the active sheet after importing an Excel file.
<ejs-spreadsheet id="spreadsheet" openUrl="Open" openComplete="openComplete">
</ejs-spreadsheet>
<script>
function openComplete(args) {
var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');
if (spreadsheetObj) {
spreadsheetObj.activeSheetIndex = 2;
}
}
</script>public IActionResult Open(IFormCollection openRequest)
{
OpenRequest open = new OpenRequest();
open.File = openRequest.Files[0];
return Content(Workbook.Open(open));
}