New to Telerik UI for WinForms? Download free 30-day trial

Getting Started with WinForms Spreadsheet

This article explains how to add a RadSpreadsheet control to a form and wire it with UI.

It contains the following sections:

Assembly References

The assemblies that contain the implementation of RadSpreadsheet and must be referenced in order to use the control are:

  • Telerik.WinControls.RadSpreadsheet

  • Telerik.WinControls

  • TelerikCommon

  • Telerik.WinControls.UI

  • Telerik.WinControls.GridView.dll

For export and import to XLSX:

  • Telerik.Windows.Zip.dll

  • Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.dll

To export a document to PDF, you will need to add a reference to the corresponding assembly:

  • Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.dll

Spreadsheet and RibbonBar

Now add the RadSpreadsheet control to the form.After that add RadSpreadsheetRibbonBar to the form. Dock it to the top and then Dock the RadSpreadsheet to fill the remaining space. Your layout should look like this.

WinForms RadSpreadsheet with Ribbon UI

Open the Smart Tag of the ribbon and set the associated control.

WinForms RadSpreadsheetRibbonBar Associated Spreadsheet

That is all. You are ready to start the application and examine the control features.

Programmatically loading documents

In some cases you may need to load the document in the code behind, not by using the UI. The following snippet demonstrates how you can load the document directly from file.

Load document with code.

string fileName = @"C:\Test.xlsx";
var formatProvider = new XlsxFormatProvider();
using (Stream input = new FileStream(fileName, FileMode.Open))
{
    radSpreadsheet1.Workbook = formatProvider.Import(input);
}

Dim fileName As String = "C:\Test.xlsx"
Dim formatProvider = New XlsxFormatProvider()
Using input As Stream = New FileStream(fileName, FileMode.Open)
    radSpreadsheet1.Workbook = formatProvider.Import(input)
End Using

Detailed information about the format providers is available here.

See Also

Telerik UI for WinForms Learning Resources

In this article