Telerik blogs
DotNetT2 Light_1200x303

Every Telerik release brings awesome new features and enhancements for our Document Processing Libraries that ship with our Telerik products! With the last release, we added the XLS file format support to the RadSpreadProcessing library. Let’s take a deeper dive!

What is XLS File Format?

XLS is the Excel 97-2003 Binary Interchange File Format (BIFF), developed by Microsoft for saving spreadsheets and now is one of the supported by RadSpreadProcessing formats.

In 2007, with the release of Microsoft Excel 2007, the XLS format was replaced by a more open and structured XLSX format (part of Microsoft Office Open XML specification a.k.a. OOXML or OpenXML), but even today the XLS format is still widely used.

Spreadsheet Document Model

The spreadsheet document model is known as Workbook where each workbook can have one or more worksheets. The data is stored and displayed in table format in Worksheet and can span numeric values, text data, formulas, external data connections, images, charts and others.

XLS and RadSpreadProcessing

RadSpreadProcessing library through its format providers (check the Formats and Conversion's General Information help article) lets you import several document formats (CSV, TXT, XLSX, and now XLS) into its Workbook document model and export this workbook data to the same set of formats including the PDF file format.

Project Setup: Adding New References

In addition to the currently required references (check the SpreadProcessing's Assembly References help topic) there is a new one responsible for importing/exporting XLS file formats.

You can reference the new assembly in two ways, via NuGet package or by direct assembly reference.


.NET Framework: Telerik.Windows.Documents.Spreadsheet.FormatProviders.Xls package

Loading RadSpreadProcessing XLS via NuGet .NET Framework

.NET Standard: Telerik.Documents.Spreadsheet.FormatProviders.Xls package

Loading RadSpreadProcessing XLS via NuGet .NET Standard

.NET Standard for Xamarin: Telerik.UI.for.Xamarin.Documents.Spreadsheet.FormatProviders.Xls

Loading RadSpreadProcessing XLS via NuGet .NET Standard for Xamarin

For more detailed information you can check the NuGet Packages help article.

Assembly Reference

.NET Framework: Telerik.Windows.Documents.Spreadsheet.FormatProviders.Xls.dll

Loading RadSpreadProcessing XLS via Assembly .NET Framework

.NET Standard: Telerik.Documents.Spreadsheet.FormatProviders.Xls.dll

Loading RadSpreadProcessing XLS via Assembly .NET Standard

Now that the references are added, we're ready to examine the new format provider class.

Using XlsFormatProvider

If you would like to work with XLS files in the context of the RadSpreadProcessing, the XlsFormatProvider is your man. You can easily import/export a Workbook from/to XLS document format in the following manner:


Workbook workbook = new Workbook();
string xlsFileName = "SampleFile.xls";

using (Stream input = new FileStream(xlsFileName, FileMode.Open))
      IWorkbookFormatProvider formatProvider = new XlsFormatProvider();
      workbook = formatProvider.Import(input);


You can export and store the document as a byte array:

byte[] bytes;
using (MemoryStream output = new MemoryStream())
      IWorkbookFormatProvider formatProvider = new XlsFormatProvider();
      formatProvider.Export(workbook, output);
      bytes = output.ToArray();

Or as any of the supported by the RadSpreadProcessing document formats (Supported formats), like XLS format:

string exportedFileName = "Exported.xls";
using (Stream output = new FileStream(exportedFileName, FileMode.OpenOrCreate))
      IWorkbookFormatProvider formatProvider = new XlsFormatProvider();
      formatProvider.Export(workbook, output);

You can find more information in the Using XlsFormatProvider help article.


XlsFormatProvider supports features like Text Formatting, Merge Cells, Number Formatting, Cell Styles, Themes, Hyperlinks, Formulas, Page Setup, Freeze Panes, Filtering, partially supports Data Validation and Headers & Footers, and many others that can be found in the Features help topic.

Converting XLS to XLSX or Vice Versa

Now you can easily convert a legacy XLS document to the current XSLX document format (or from/to any of the previously mentioned formats supported by the RadSpreadProcessing library) with the help of both XlsFormatProvider and XlsxFormatProvider in the following manner:

Workbook workbook = new Workbook();
string xlsFileName = "Legacy.xls";
string xlsxFileName = "Current.xlsx";

using (Stream input = new FileStream(xlsFileName, FileMode.Open))
      IWorkbookFormatProvider xlsFormatProvider = new XlsFormatProvider();
      workbook = xlsFormatProvider.Import(input);

using (Stream output = new FileStream(xlsxFileName, FileMode.OpenOrCreate))
      IWorkbookFormatProvider xlsxFormatProvider = new XlsxFormatProvider();
      xlsxFormatProvider.Export(workbook, output);

The reverse conversion is also just as easy to be implemented by switching the input and output documents and format providers.

Try RadSpreadProcessing Yourself

Get yourself a free trial of Telerik Document Processing today and start developing your apps better, faster and more easily.

Start My Trial

Share Your Feedback

Let’s continue to build the future of Telerik Document Processing together! So, don’t forget to share your thoughts as a comment below or let us know if you have any suggestions and/or need any features/components by visiting our Telerik Document Processing Feedback Portal.

About the Author

Martin Velikov

Martin is a Software Engineer, part of the Document Processing team in Sofia, Bulgaria since July 2019. He is passionate about new technologies and is always on the crest of a wave with the novelties. In his spare time, Martin likes travelling to new destinations and exploring new cultures, hanging out with friends, reading books, practicing sports, and more.

Related Posts


Comments are disabled in preview mode.