Telerik blogs
Did you know that using the core of our brand new spreadsheet component you can easily export data to Excel?

What you need actually is reference to:
Telerik.Windows.Documents.Core.dll
Telerik.Windows.Documents.Spreadsheet.dll
Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.dll
Telerik.Windows.Zip.dll

and simple code for exporting (for example RadGridView):

private static Workbook CreateWorkBook(RadGridView grid)
{
    var workbook = new Workbook();
    var worksheet = workbook.Worksheets.Add();
 
    for (var i = 0; i < grid.Items.Count; i++)
    {
        for (var j = 0; j < grid.Columns.Count; j++)
        {
            var boundColumn = grid.Columns[j] as GridViewBoundColumnBase;
            if (boundColumn != null)
            {
                worksheet.Cells[i, j].SetValue(string.Format("{0}", boundColumn.GetValueForItem(grid.Items[i])));
            }
        }
    }
 
    return workbook;
}

For more info about RadSpreadsheet please check our documentation for Silverlight and WPF!

You can also download two identical example applications for Silverlight and WPF.

Enjoy!

About the Author

Vladimir Enchev

is Director of Engineering, Native Mobile UI & Frameworks

Related Posts

Comments

Comments are disabled in preview mode.