Spreadsheet HtmlHelper Overview

The Telerik UI Spreadsheet HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Spreadsheet widget.

The Spreadsheet allows you to edit and visualize tabular data by using cell formatting options, styles, and themes.

Basic Configuration

  1. Create a new ASP.NET MVC 5 application using any of the following templates:

  2. Add a Spreadsheet to the Index view in Views/Home/Index.cshtml.

        <%:Html.Kendo().Spreadsheet()
            .Name("spreadsheet")
            .Sheets(sheets => {
                sheets.Add()
                    .Name("Food Order")
                    .MergedCells("A1:F1", "C15:E15")
                    .Columns(columns =>
                    {
                        columns.Add().Width(100);
                        columns.Add().Width(215);
                        columns.Add().Width(115);
                        columns.Add().Width(115);
                        columns.Add().Width(115);
                        columns.Add().Width(155);
                    })
                    .Rows(rows =>
                    {
                        rows.Add().Height(50).Cells(cells =>
                        {
                            cells.Add()
                                .Value("My Company")
                                .FontSize(25)
                                .Background("rgb(142,196,65)")
                                .TextAlign(SpreadsheetTextAlign.Center)
                                .Color("white");
                        });
    
                        rows.Add().Height(25).Cells(cells =>
                        {
                            cells.Add()
                                .Value("ID")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Product")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Quantity")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Price")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Tax")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Amount")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
                        });
                    });
                })
        %>
    
        @(Html.Kendo().Spreadsheet()
            .Name("spreadsheet")
            .Sheets(sheets => {
                sheets.Add()
                    .Name("Food Order")
                    .MergedCells("A1:F1", "C15:E15")
                    .Columns(columns =>
                    {
                        columns.Add().Width(100);
                        columns.Add().Width(215);
                        columns.Add().Width(115);
                        columns.Add().Width(115);
                        columns.Add().Width(115);
                        columns.Add().Width(155);
                    })
                    .Rows(rows =>
                    {
                        rows.Add().Height(50).Cells(cells =>
                        {
                            cells.Add()
                                .Value("My Company")
                                .FontSize(25)
                                .Background("rgb(142,196,65)")
                                .TextAlign(SpreadsheetTextAlign.Center)
                                .Color("white");
                        });
    
                        rows.Add().Height(25).Cells(cells =>
                        {
                            cells.Add()
                                .Value("ID")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Product")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Quantity")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Price")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Tax")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
    
                            cells.Add()
                                .Value("Amount")
                                .Background("rgb(212,223,50)")
                                .TextAlign(SpreadsheetTextAlign.Center);
                        });
                    });
            })
        )
    
  3. Build and run the application.

    The final result

Functionality and Features

The Spreadsheet provides options for server-side processing of data.

Events

You can subscribe to all Spreadsheet events. For a complete example on basic Spreadsheet events, refer to the demo on using the events of the Spreadsheet.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    <%:Html.Kendo().Spreadsheet()
        .Name("spreadsheet")
        .Events(e => e
            .Render("spreadsheetRender")
        )
    %>

    <script>
        function spreadsheetRender() {
            // Handle the render event.
        }
    </script>
    @(Html.Kendo().Spreadsheet()
        .Name("spreadsheet")
        .Events(e => e
            .Render("spreadsheetRender")
        )
    )

    <script>
        function spreadsheetRender() {
            // Handle the render event.
        }
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

@(Html.Kendo().Spreadsheet()
    .Name("spreadsheet")
    .Events(e => e
        .Render(@<text>
            function() {
                // Handle the render event inline.
            }
        </text>)
    )
)

Referencing Existing Instances

To reference an existing Spreadsheet instance, use the jQuery.data() configuration option. Once a reference is established, use the Spreadsheet API to control its behavior.

@(Html.Kendo().Spreadsheet()
    .Name("spreadsheet")
)

<script>
    $(function() {
        // The Name() of the Spreadsheet is used to get its client-side instance.
        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article