Changing the active sheet in ASP.NET MVC 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.
@Html.EJS().Spreadsheet("spreadsheet").OpenUrl("Home/Open").OpenComplete("openComplete").Render()
<script>
function openComplete(args) {
var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');
if (spreadsheetObj) {
spreadsheetObj.activeSheetIndex = 2;
}
}
</script>public ActionResult Open(OpenRequest openRequest)
{
return Content(Workbook.Open(openRequest));
}