New to Telerik UI for ASP.NET Core? Download free 30-day trial

Excel Export

This article provides solutions for issues you might encounter while exporting the content of the Telerik UI Grid component for ASP.NET Core.

JSZip Is Not Found

Clicking the Export to Excel button or calling the saveAsExcel throws an exception if the JSZip JavaScript library is not found.

Solution Include JSZip in the page. For more information on the export of the Grid to Excel, refer to this article.

Export Does Not Work in Internet Explorer and Safari

Internet Explorer versions below 10 and Safari cannot save a file and require the implementation of a server proxy.

Solution Set the ProxyURL option to specify the server proxy URL.

The following example demonstrates the user server proxy.

    public class ProxyController : Controller
    {
        [HttpPost]
        public ActionResult Save(string contentType, string base64, string fileName)
        {
            var fileContents = Convert.FromBase64String(base64);

            return File(fileContents, contentType, fileName);
        }
    }
    <%: Html.Kendo().Grid<MvcApplication.Models.ProductViewModel>()
        .Name("grid")
        .ToolBar(tools => tools.Excel())
        .Excel(excel => excel
            .AllPages(true)
            .ProxyURL(Url.Action("Save", "Proxy"))
        )
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Products_Read", "Home"))
        )
    %>

    @(Html.Kendo().Grid<MvcApplication.Models.ProductViewModel>()
        .Name("grid")
        .ToolBar(tools => tools.Excel())
        .Excel(excel => excel
            .AllPages(true)
            .ProxyURL(Url.Action("Save", "Proxy"))
        )
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Products_Read", "Home"))
        )
    )

    <kendo-grid name="grid">
        <toolbar>
            <toolbar-button name="excel" ></toolbar-button>
        </toolbar>
        <excel all-pages="true" proxy-url="@Url.Action("Save", "Proxy")" />
        <datasource type="DataSourceTagHelperType.Ajax" page-size="20"
            <schema data="Data" total="Total">
                <model id="ProductID">
                    <fields>
                        <field name="ProductID" type="number" editable="false"></field>
                        <field name="ProductName" type="string"></field>
                        <field name="UnitPrice" type="number"></field>
                        <field name="UnitsInStock" type="number"></field>
                        <field name="UnitsOnOrder" type="number"></field>
                        <field name="Discontinued" type="boolean"></field>
                    </fields>
                </model>
            </schema>
            <transport>
                <read url="@Url.Action("Products_Read" "Grid")" />
                <update url="@Url.Action("Products_Update" "Grid")" />
                <create url="@Url.Action("Products_Create" "Grid")" />
                <destroy url="@Url.Action("Products_Destroy" "Grid")" />
            </transport>
        </datasource>
    </kendo-grid>

See Also

In this article