Export
Use RadSpreadStreamProcessing when you need to export large spreadsheet documents directly to a stream with a low memory footprint. The library is optimized for forward-only writing, which makes it suitable for server-side generation and high-volume export scenarios.
Supported Export Formats
RadSpreadStreamProcessing can export spreadsheet documents to these formats:
- XLSX
- CSV
Choose XLSX when you need a workbook file that preserves spreadsheet structure. Choose CSV when you need a text-based export of worksheet data.
How the Streaming Export Works
RadSpreadStreamProcessing writes document content directly to the target stream as you create each workbook element. To support that behavior, the exporter types implement IDisposable and write their corresponding content and settings when they are disposed.
Because of this streaming model, you must create and dispose elements in the correct order. The export process is sequential, so once an element is written to the stream, the library does not keep the entire document in memory for later restructuring.
This predefined creation and disposal sequence is described in Getting Started with RadSpreadStreamProcessing.
Typical Export Workflow
In most scenarios, the export flow looks like this:
- Open the target
Stream. - Create an IWorkbookExporter for the desired format.
- Create worksheets, rows, and cells in the required order.
- Dispose each element when you finish writing to it.
- Dispose the
IWorkbookExporterto finalize the document.
Setting Export Format
The supported formats follow different output patterns, so you must choose the export format when you start creating the document, which means when you instantiate IWorkbookExporter.
Starting with R3 2017, the encoding used to export CSV documents is UTF-8 with BOM.
Example 1: Specify the Export Format
IWorkbookExporter workbook = SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Csv, stream);
Creating IWorkbookExporter starts writing the file by using the Stream instance that you pass to the CreateWorkbookExporter() method. Writing finishes when the IWorkbookExporter instance is disposed.
What to Verify After Export
After the export finishes, verify these points:
- The output stream contains the expected file format.
- The workbook structure is complete and no elements were skipped because of an incorrect creation or disposal order.
- CSV output uses the expected UTF-8 with BOM encoding when you export to CSV.
Next Steps
Continue with the article that matches your next task:
- Read Getting Started for the full workbook, worksheet, row, and cell creation sequence.
- Read Workbook for details about
IWorkbookExporterand workbook-level export behavior. - Review the SpreadStreamProcessing Large Document Export Demo to see streaming export in a larger scenario.