Excel Export and Spreadsheet Document API Architecture
- 2 minutes to read
Spreadsheet Document API
The Spreadsheet Document API architecture is based on its internal document model which stores all spreadsheet data in memory. This means that when you load a document, the Spreadsheet Document API component reads the file (using the appropriate file format, for example XLSX) and imports data (cell values, formulas, format settings, etc.) to the document model. At this point, you can use the spreadsheet API to modify the model or perform calculations over cell values. Once complete, you can call the SaveDocument or ExportTo* method and export the document model with modified data to the desired file format.
Generating a new document works in the same way. When you create a new workbook using API methods, the spreadsheet component creates a new document model, generates its content and then exports it to the specified file format. This universal approach allows you to use a single library to both read/edit and create new documents, but it can cause significant problems with performance: generation of very large Excel files will often lead to high memory consumption and associated time delays.
Excel Export Library
Unlike the Spreadsheet Document API, the Excel Export Library does not use an internal document model and writes data directly to the output stream in consecutive order: row by row, cell by cell. This approach allows it to generate Excel files at very high speeds and with very low memory consumption (because there is no need to put data into an in-memory document model and then export the model’s content to the output stream).
So if you need an extremely fast and low-memory footprint engine to export data from your application into Excel formats, then the Excel Export Library is your best option. It is optimized for performance and allows you to create extremely large spreadsheet documents in the most efficient manner (that is very important when you have, for example, a website that needs to generate many Excel files).
The graphic below sums up the described algorithms used by the Spreadsheet Document API and Excel Export Library to generate spreadsheet documents.