Import
With RadSpreadStreamProcessing you can read spreadsheet documents from the following file formats:
-
XLSX
-
CSV
This functionality is available starting with R3 2022.
Specifics
The library dynamically reads the document content. To achieve this, the IWorksheetImporter and IWorkbookImporter classes responsible for importing the elements of the document implement IDisposable and keep the corresponding content and settings in memory until disposed.
Read File Data
To read the data from a file, parse the desired elements in sequence keeping the following order:
-
Read the Workbook
-
Read a Worksheet
-
Read Columns (optional)
-
Read Rows
-
Read Cells
Example 1: Read Data from a Document
using (System.IO.FileStream fs = new System.IO.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;
}
}
}
}
}
Through the importer objects, you can access the properties of the different elements.
Starting with R1 2023 SP1, there are separate properties for the formula and the value in the
ICellImporter.