简体   繁体   中英

How to export Excel by Kendo UI on MVC?

Im new Kendo UI, so I have a below code by MVC, so I want to click a button then click -> export to excel base listresult

@(Html.Kendo().Grid(Model)
              .Name("listResult")
              .Columns(columns =>
              {
                  columns.Bound(c => c.Index).Title(ResourceLabel.COMMON_SN);
                  columns.Bound(c => c.Act..);
                  columns.Bound(c => c.Job...;
                  columns.Bound(c => c.Sub...);
                  columns.Bound(c => c.R...);
                  columns.Bound(c => c.Status);
                  columns.Bound(c => c.Job..);
                  columns.Bound(c => c.Id).Title("Action").ClientTemplate("<div class='form-inline action'>" +
                                                                          "#=RenderAction(data)#" +
                                                                          "</div>");
                  //columns.Bound(c => c.Id).Title("Action").ClientTemplate("#=RenderAction(data)#");


              })
              .Pageable()
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .PageSize(10)
                  .ServerOperation(true)
                  .Read(read => read.Action("Search", "...."))
              )
              )

Kendo has a default functionality for exporting the grid data to excel.

Just add

.ToolBar(tools => tools.Excel())

and set

.Excel(excel => excel
    .FileName("Filename.xlsx")
)

with the correct kendo scripts it should work right away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM