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

Getting Started with the Telerik WebForms Spreadsheet

This article will get you started in using the RadSpreadsheet control. It contains the following sections:

Assembly References

In order to use the RadSpreadsheet control in your project you need to add references to the following assemblies:

  • Telerik.Web.Spreadsheet.dll
  • Newtonsoft.Json.dll

You can access the needed assemblies from the AdditionalLibraries folder in the Telerik® UI for ASP.NET AJAX installation (automated and manual) and from the internal builds archive. They support .NET 4 and .NET 4.5, so depending on the target framework of your project, you need to take the assemblies from the Bin40 or the Bin45 folder respectively.

The following assemblies are required in order to be able to use the control with the predefined SpreadsheetDocumentProvider (applicable for most scenarios):

  • Telerik.Windows.Documents.Core.dll — the main assembly from the Telerik document processing libraries.

  • Telerik.Windows.Zip.dll — needed for working with zipped formats (DOCX, XLSX) and PDF.

  • Telerik.Windows.Documents.Spreadsheet.dll — the main assembly for the spreadsheet processing. It is needed for processing XLSX, CSV, TXT documents.

  • Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.dll — needed for processing XLSX documents.

You could find the above assemblies in the AdditionalLibraries folder of the installation directory on your machine (C:\Program Files\Progress\UI for ASP.NET AJAX RX YYYY).

Creating a Simple RadSpreadsheet

To create a new instance of RadSpreadsheet on your page using the designer, you should follow the below steps:

  • Drag a RadSpreadsheet control from the Toolbox onto your Web Page.

  • The Smart Tag should appear automatically. Within the Smart Tag menu, from the Skin drop-down chose the desired Skin for this control:

spreadsheet-overview

  • Run the application. You should see the newly created empty RadSpreadsheet on your page:

spreadsheet-overview

Binding a RadSpreadsheet to a provider at runtime

Binding the RadSpreadsheet to a provider at runtime requires two simple steps:

  • Create an excel file and copy it to the App_Data folder of your project. In this example we have created a file with a name "Spreadsheet.xlsx".

  • Set the Provider property in the code behind, by assigning it an instance of the Telerik.Web.UI.SpreadsheetDocumentProvider class, with the path to the excel file as a parameter:


protected void Page_Init(object sender, EventArgs e)
{
    RadSpreadSheet1.Provider = new SpreadsheetDocumentProvider(Server.MapPath("~/App_Data/Spreadsheet.xlsx"));
}


Protected Sub Page_Init(sender As Object, e As EventArgs)
    RadSpreadSheet1.Provider = New SpreadsheetDocumentProvider(Server.MapPath("~/App_Data/Spreadsheet.xlsx"))
End Sub

You have now bound your RadSpreadsheet using the Provider property at runtime:

spreadsheet-overview

See Also

In this article