Skip to main content

Data Exporter Service

DataExporterService is the main entry point of the module.

It resolves the correct exporter provider by type and returns the exported result.

Methods​

MethodDescription
exportAsync(args)Exports data using the provider selected by args.type.

Export types​

TypeDescription
csvExports data as CSV.
excelExports data as an Excel workbook.

Usage​

report.service.ts
import { Injectable } from '@nestjs/common';
import { DataExporterService } from 'nestjs-export-module';

@Injectable()
export class ReportService {
constructor(private readonly dataExporter: DataExporterService) {}

async exportUsersCsv() {
return this.dataExporter.exportAsync({
type: 'csv',
// other args depend on the provider
});
}
}
note

Provider-specific arguments and result details are documented under Providers.