# Editing Cell Values of Existing Documents using SpreadStreamProcessing

## Environment

| Version    | Product                   | Author                                                                          |
| ---------- | ------------------------- | ------------------------------------------------------------------------------- |
| 2026.1.210 | RadSpreadStreamProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

[RadSpreadStreamProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadstreamprocessing/overview) cannot directly edit existing cell values in-place. It is designed as a forward-only, low-memory streaming API. This design gives you great performance for very large Excel files, but it also introduces an important limitation:

* Read existing Excel files sequentially
* Generate new Excel files sequentially
* **Cannot** seek back or modify cells in an already-existing XLSX document in place

Once a row or cell has been read from the stream, you cannot go back and change it. Likewise, you cannot open an XLSX file and update a cell while keeping the same file instance.

This article shows how to edit cells in existing XLSX documents using the SpreadStreamProcessing library.

![Edit Cell Values With SpreadStreamProcessing](https://www.telerik.com/document-processing-libraries/documentation/assets/51c647fb173a9cf1316f9a6bff5b8112/edit-cell-values-with-spreadstreamprocessing.png)

## Solution

You can effectively edit data by:

1. Reading the existing Excel file with RadSpreadStreamProcessing
2. Modifying values during the read
3. Writing everything to a new XLSX file

   ```csharp
           static void Main(string[] args)
        {
            string inputFilePath = "input.xlsx";
            string outputFilePath = "modified.xlsx";

            CreateWorksheet(inputFilePath); 
            UpdateExistingWorksheet(inputFilePath, outputFilePath);
            
            Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true }); 
        }
        private static void CreateWorksheet(string inputFilePath)
        {

            File.Delete(inputFilePath);
            using (FileStream stream = new FileStream(inputFilePath, FileMode.Create, FileAccess.Write))
            using (IWorkbookExporter workbookExporter =
                   SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Xlsx, stream))
            {
                using (IWorksheetExporter worksheetExporter =
                       workbookExporter.CreateWorksheetExporter("DummyData"))
                {
                    for (int row = 0; row < 10; row++)
                    {
                        using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
                        {
                            for (int col = 0; col < 10; col++)
                            {
                                using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
                                {
                                    cellExporter.SetValue($"R{row + 1}C{col + 1}");
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Excel file generated successfully.");

        }
        private static void UpdateExistingWorksheet(string inputFilePath, string outputFilePath)
        {

            File.Delete(outputFilePath);
            using (FileStream input = File.OpenRead(inputFilePath))
            using (FileStream output = File.Create(outputFilePath))

            using (IWorkbookImporter importer = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, input))
            {
                using (IWorkbookExporter exporter = SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Xlsx, output))
                {
                    foreach (IWorksheetImporter worksheetImporter in importer.WorksheetImporters)
                    {
                        using (IWorksheetExporter worksheetExporter = exporter.CreateWorksheetExporter(worksheetImporter.Name))
                        {
                            foreach (IRowImporter rowImporter in worksheetImporter.Rows)
                            {
                                using (IRowExporter rowExporter = worksheetExporter.CreateRowExporter())
                                {
                                    foreach (ICellImporter cellImporter in rowImporter.Cells)
                                    {
                                        using (ICellExporter cellExporter = rowExporter.CreateCellExporter())
                                        {
                                            string value = cellImporter.Value;

                                            if (cellImporter.ColumnIndex == 2 && cellImporter.RowIndex == 1)
                                            {
                                                value = "Updated value";
                                            }

                                            cellExporter.SetValue(value);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
   ```

## See Also

* [SpreadStreamProcessing Overview](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadstreamprocessing/overview)
* [Getting Started with SpreadStreamProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radspreadstreamprocessing/getting-started)
