Getting Started
This article will get you started in using the RadSpreadStreamProcessing library.
If you still don't have Telerik Document Processing installed, check the First Steps topic to learn how you can obtain the packages through the different suites.
Package References
You can find the required references in the SpreadStreamProcessing NuGet packages section.
Create a Spreadsheet Document
This section will explain how a document could be created. If you need more detailed information about the classes that export the different document elements, you can check the articles from the Model section.
When creating a document with RadSpreadStreamProcessing, the order in which the elements are created is very important. In order to minimize resource consumption, the library writes the content directly to a stream, and due to the structure of the file format, it is necessary to create the elements in the following order:
-
Create a Workbook
-
Create a Worksheet
-
Create Columns (optional)
-
Create Rows (a worksheet must contain at least one row)
-
Create Cells (optional)
-
Merge Cells (optional)
Example 1 shows how you could create a simple document.
Example 1: Create a document
using (FileStream stream = File.OpenWrite("sample.xlsx"))
{
using (IWorkbookExporter workbook = SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Xlsx, stream))
{
using (IWorksheetExporter worksheet = workbook.CreateWorksheetExporter("My sheet"))
{
worksheet.SkipColumns(1);
using (IColumnExporter column = worksheet.CreateColumnExporter())
{
column.SetWidthInPixels(80);
}
worksheet.SkipRows(3);
using (IRowExporter row = worksheet.CreateRowExporter())
{
row.SkipCells(3);
using (ICellExporter cell = row.CreateCellExporter())
{
cell.SetValue("Merged cell.");
cell.SetFormat(new SpreadCellFormat()
{
HorizontalAlignment = SpreadHorizontalAlignment.Center,
VerticalAlignment = SpreadVerticalAlignment.Center
});
}
}
using (IRowExporter row = worksheet.CreateRowExporter())
{
row.SetHeightInPixels(200);
using (ICellExporter cell = row.CreateCellExporter())
{
cell.SetValue(123.456);
}
using (ICellExporter cell = row.CreateCellExporter())
{
SpreadCellFormat format = new SpreadCellFormat()
{
NumberFormat = "dd/mm/yyyy",
IsBold = true
};
cell.SetFormat(format);
cell.SetValue(42370);
}
}
worksheet.MergeCells(3, 3, 6, 6);
}
}
}
Figure 1 shows the result of executing the code from Example 1.
Figure 1: The document created in Example 1

Read Existing Document
When reading a document with RadSpreadStreamProcessing, the order of parsing the content is very important. To minimize resource consumption, the library parses only the parts required by the user and, due to the file structure, it is necessary to read the desired elements in the following order:
-
Read the Workbook
-
Read a Worksheet
-
Read Columns (optional)
-
Read Rows (a worksheet must contain at least one row)
-
Read Cells (optional)
Example 2 demonstrates how you could read the data from an existing document.
Example 2: Read data from a document
using (FileStream fs = new FileStream(fileName, FileMode.Open))
{
using (IWorkbookImporter workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, fs))
{
foreach (IWorksheetImporter worksheetImporter in workBookImporter.WorksheetImporters)
{
foreach (IRowImporter rowImporter in worksheetImporter.Rows)
{
foreach (ICellImporter cell in rowImporter.Cells)
{
string value = cell.Value;
}
}
}
}
}
For more complete examples head to the Developer Focused Examples section of the library.