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:

  1. Bind the openComplete event to the Spreadsheet.
  2. In the event handler, set the activeSheetIndex property to the index of the sheet you want to activate.
  3. Open an Excel file in the Spreadsheet.
  4. After the file is loaded, the Spreadsheet displays the sheet specified by the activeSheetIndex property.

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