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

Grid export to EXCEL

1 Answer 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Karen
Top achievements
Rank 1
Karen asked on 15 Jun 2017, 05:39 PM
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?

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Jun 2017, 08:26 AM
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.
Tags
General Discussions
Asked by
Karen
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or