We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Programmatically trigger "open" command from backstage

Hi, can you advise on how to programmatically trigger the "open" command from the spreadsheet's backstage? I understand there's an "import" method available,

<div id="Spreadsheet"></div> 
<script>
var excelObj = $("#Spreadsheet").data("ejSpreadsheet"); // Initialize the Spreadsheet object.
var importRequest = { Url:"http://staging.syncfusion.com:7777/ejSpreadsheet/Spreadsheet.xlsx" };
excelObj.import(importRequest); 
</script>
but I would like to take advantage of the file dialog that comes with the backstage open command so the user can import an excel file from the user's local filesystem.

Thanks in advance.

James


1 Reply

SP Sangeetha Priya Murugan Syncfusion Team October 9, 2017 07:20 AM UTC

Hi James Pham,   
 
Thank you for contacting Syncfusion Support. 
 
We have checked your query and your requirement for programmatically trigger the "FILE->Open" option can be achievable in Spreadsheet. Please refer the following code example.  
 
[HTML] 
 
 //…  
 
    <button id="fileImportBtn">File Import</button> 
    <div id="Spreadsheet"></div> 
  
 
[SCRIPT] 
  
$("#Spreadsheet").ejSpreadsheet({  
     //…     
});  
  
$("#fileImportBtn").click(function () { 
        var ssObj = $("#Spreadsheet").data("ejSpreadsheet"); 
         //Import File using ribbon action programmatically. 
         $("#" + ssObj._id + "_file .e-uploadinput").click(); 
}); 
  
 
For your convenience, we have prepared a sample to demonstrate this in JSPlayground.  
  
Regards   
Sangeetha Priya M  


Loader.
Live Chat Icon For mobile
Up arrow icon