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

Reading in Excel file to Spreadsheet control

Hi, Is there a sample for reading in an Excel file to the Spreadsheet control?

I am able to use a collection as the Datasource but would now like to read in a .xlsx file

3 Replies

MK Mohan Kumar Ramasamy Syncfusion Team March 2, 2016 11:12 AM UTC

Hi Morrison,


Thanks for your interest in Syncfusion products.


We suggest you to use “importUrl” property to load the excel file and “ImportMapper” property is used to map the import controller action. Please refer below code snippets.


View.cshtml


@(Html.EJ().Spreadsheet<object>("Spreadsheet")

----------

.ImportSettings(import =>

    {         

import.ImportMapper("Import");

import.ImportUrl("http://staging.syncfusion.com:7777/ejSpreadsheet/Spreadsheet.xlsx");

    })

)




Controller.cs



      [AcceptVerbs(HttpVerbs.Post)]

        public ActionResult Import(ImportRequest importRequest)

        {

            return importRequest.SpreadsheetActions();

        }



Note: To open local files we can use “File -> Open” option in ribbon.


For your convenience, we have created a simple sample to demonstrate this and same can be downloaded from below link.


Sample Link: http://www.syncfusion.com/downloads/support/forum/123256/ze/SyncfusionMvcApplication1-1474419519


Please let us know if you need any further assistance.


Regards,

Mohankumar R



MA Mark March 3, 2016 04:48 AM UTC

Thanks - that's great.

I need to set the file on the server side. Is there a way I can do this from the Controller?

Can I load the file from a stream?


MK Mohan Kumar Ramasamy Syncfusion Team March 3, 2016 02:37 PM UTC

Hi Morrison,


We considered this “Importing excel file url from the control action on initial load” as an improvement task and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.


https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents


Regards,

Mohankumar R


Loader.
Up arrow icon