Skip to main content
Version: Next

Data Export

The data export function allows users to download query results as Excel files.

Export Interface​

  • URL: /api/app/{entity-name}/export-excel
  • Method: GET
  • Parameters: Same filtering parameters as the GetList interface (to ensure the exported data matches the current view).

Implementation Logic​

  1. Query: Retrieve data from the database based on the filter conditions.
  2. Mapping: Convert entity objects into a flat DTO structure suitable for export (ExportDto).
  3. Generation: Generate the Excel file stream using the Excel library.
  4. Response: Return the file stream with the MIME type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.
public async Task<IRemoteStreamContent> GetListAsExcelFileAsync(GetIdentityUsersInput input)
{
var users = await _userRepository.GetListAsync(...);
var excelBytes = _excelService.Generate(users);
return new RemoteStreamContent(new MemoryStream(excelBytes), "Users.xlsx");
}