Skip to main content
Version: Next

Data Export

Files Referenced in this Document

  • IMyEntityNameAppService.cs
  • MyEntityNameAppService.cs
  • MyEntityNameExcelDto.cs

Table of Contents​

  1. Introduction
  2. Export Logic (ExportAsync)
  3. Filtering and Selection
  4. Performance and Security

Introduction​

Data export allows users to download system data into an Excel file for reporting, backup, or analysis in external tools.

Export Logic (ExportAsync)​

Method Signature: Task<FileContentResult> ExportAsync(MyEntityNameGetListInput input)

Process:

  1. Query: Accepts MyEntityNameGetListInput to filter the data to be exported (e.g., export only "Active" items).
  2. Fetch: Retrieves the filtered data from the database. Note that unlike paging, this might fetch a larger dataset or all matching records.
  3. Map: Converts Entities to MyEntityNameExcelDto.
  4. Generate: Uses the Excel library to write the DTOs into an Excel sheet.
  5. Return: Returns the file content as a binary stream with the correct MIME type (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet).

Filtering and Selection​

The export function reuses the same input DTO (MyEntityNameGetListInput) as the list API. This ensures that "what you see is what you get" — users can filter the list on the UI and export exactly those results.

Performance and Security​

  • Memory Usage: Exporting huge datasets can consume significant memory. Implementations should consider streaming or limiting export size.
  • Permissions: Export operations should be protected by permissions (e.g., MyPluginName.MyEntityNames.Export) to prevent unauthorized data exfiltration.