Grid export to EXCEL

2 posts, 0 answers
  1. Karen
    Karen avatar
    2 posts
    Member since:
    Jun 2017

    Posted 15 Jun 2017 Link to this post

    Hi,
    I'm trying to Export Telerik Grid to Excel by using code(SharePoint 2013):
    using Telerik.Windows.Documents.Spreadsheet;
    using Telerik.Windows.Documents.Spreadsheet.FormatProviders;
    using Telerik.WinControls.Export;
    using Telerik.Windows.Documents.Core;
    using Telerik.Windows.Zip;
    using Telerik.Web.UI.Export;
    using Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml;
    using Telerik.Windows.Documents.Spreadsheet.Model;
    using Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx;
    using Telerik.Windows.Documents.Fixed;



            protected void btnEportToXLS_Click(object sender, EventArgs e)
            {

                if (TicketsGrid.Items.Count > 0)
                {
                    try
                    {

                        TicketsGrid.Rebind();
                        TicketsGrid.ExportSettings.ExportOnlyData = true;
                        TicketsGrid.ExportSettings.IgnorePaging = true;
                        TicketsGrid.ExportSettings.OpenInNewWindow = true;
                        TicketsGrid.MasterTableView.UseAllDataFields = true;
                        TicketsGrid.ExportSettings.FileName = "C:\\ExcelFile.xlsx";// Guid.NewGuid().ToString();
                        TicketsGrid.MasterTableView.ExportToExcel();
                    }
                    catch (Exception exc)
                    {

                    }
                }

            }

            private GridItemType[] supportedItemTypes = new GridItemType[] 
            { 
                GridItemType.Header, 
                GridItemType.AlternatingItem, 
                GridItemType.Item 
            };

    After executing the code getting exception:
    Could not load file or assembly 'Telerik.Windows.Documents.Spreadsheet, Version=2016.1.106.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.
    Any suggestions please?
  2. Dinko
    Admin
    Dinko avatar
    937 posts

    Posted 20 Jun 2017 Link to this post

    Hi Karen,

    Thank you for contacting us.

    You are getting this exception because you haven't referenced the Telerik.Windows.Documents.Spreadsheet DLL. You can take a look at ExportToXlsx help article in our documentation which describes the required assemblies which you need to referenced and how you can export the grid to Xlsx format.

    Hope this information is helpful.

    Regards,
    Dinko
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top