I am trying to load excel from a file path but doesn't load spreadsheet asp.net mvc

1 Answer 165 Views
General Discussions Spreadsheet
Hardik
Top achievements
Rank 1
Iron
Hardik asked on 08 Sep 2021, 02:30 PM | edited on 10 Sep 2021, 12:27 PM

my cshtml file

  @(Html.Kendo().Spreadsheet()
            .Name("spreadsheet").HtmlAttributes(new { style = "width:100%;" })

        )

<script> $(document).ready( function () { var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet"); $.ajax({ type: "POST", url: '@Url.Action("GetFileFromDetails", "Spreadsheets")', contentType: "application/json; charset=utf-8", data: { data: myData }, dataType: "json", success: function (recData) { //alert(recData); spreadsheet.fromJSON(recData.response); }, error: function (ex) { alert(ex); } }); }); </script>

my controller


  [HttpPost]
        public ActionResult GetFileFromDetails()
        {
           
var workbook = Workbook.Load(file.InputStream, Path.GetExtension(file.FileName));
            return Content(workbook.ToJson(), Telerik.Web.Spreadsheet.MimeTypes.JSON);
        }
this method returns same value as shown in upload example still this doesn't load spreadsheet
  [HttpPost]
        public ActionResult Upload(HttpPostedFileBase file)
        {            
            var workbook = Workbook.Load(file.InputStream, Path.GetExtension(file.FileName));
            return Content(workbook.ToJson(), Telerik.Web.Spreadsheet.MimeTypes.JSON);
        }
while using upload sample it works fine. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Hardik
Top achievements
Rank 1
Iron
answered on 10 Sep 2021, 12:28 PM
I have fixed the issue. I was getting sheets in array. selecting particular sheet from response solve my issue.  
Tags
General Discussions Spreadsheet
Asked by
Hardik
Top achievements
Rank 1
Iron
Answers by
Hardik
Top achievements
Rank 1
Iron
Share this question
or