This is a migrated thread and some comments may be shown as answers.

How to view xlsx file in the Spreadheet Control?

1 Answer 135 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Artur
Top achievements
Rank 1
Artur asked on 15 Oct 2015, 08:43 AM

Hello Telerik Team,

Let's assume there is a xlsx file and I want to load this file to Spreadheet control.

 

Controller code:

var workbook = Workbook.Load(​path);  
var workbookJson = workbook.ToJson();
                                        
var model = new ExcelViewerViewModel()
{
Name = "Test",
Sheets = JsonConvert.DeserializeObject<IEnumerable<SpreadsheetSheet>>(workbookJson),   <--- the problem to deserialize sheets
};

return PartialView("~/Views/Shared/_ExcelViewer.cshtml", model);

 

The View code:

            @(Html.Kendo().Spreadsheet()
                .Name("excelViewer")                                
                .Toolbar(false)                       
                .BindTo(Model.Sheets))

 

So the question is how to get IEnumerable<SpreadsheetSheet>> type from workbook?

 

 Thank You

 

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 19 Oct 2015, 10:45 AM
Hi,

I'm copying the reply to your support ticket for community reference:

This is a good question. Ideally, the Spreadsheet helper will take a Workbook reference directly.
But this would require introducing a dependency to Telerik.Web.Spreadsheet and all assemblies required by it (which are a whole lot).

We're still pondering on how to solve this. Perhaps a third assembly, say Telerik.Web.Spreadsheet.Model, containing only the model interface definitions will solve this.
There might be some breaking changes regarding this, but we haven't made a decision yet.

For the moment, my recommendation is to load the JSON data directly on the client:
  var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
  $.getJSON("/kendo-ui/content/web/spreadsheet/products.json")
  .done(function (sheets) {
     spreadsheet.fromJSON({ sheets: sheets });
  }); 

I hope this helps.

Regards,
T. Tsonev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Spreadsheet
Asked by
Artur
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or