@slickgrid-universal/text-export
TypeScript icon, indicating that this package has built-in type declarations

4.7.0 • Public • Published

License: MIT TypeScript lerna--lite npm npm

Actions Status Cypress.io jest codecov

Text Export Service (text file)

@slickgrid-universal/text-export

Simple Export to File Service that allows to export as CSV or Text (.csv or .txt), user can also choose which data separator to use for the export (comma, colon, semicolon, ...).

There are a couple of reasons to use this package (it could be used instead of the excel-export)

  • if you want to export to a text file with any type of separator (tab, colon, semicolon, comma)
  • if you have a very large dataset, this export consumes a lot less memory in comparison to the excel-export

Internal Dependencies

External Dependencies

This package requires text-encoding-utf-8 which is use to ensure proper UTF-8 encoding, even emoji will be exported without issues.

Installation

Follow the instruction provided in the main README, you can see a demo by looking at the GitHub Demo page and click on "Export to CSV" from the Grid Menu (aka hamburger menu).

Usage

In order to use the Service, you will need to register it in your grid options via the registerExternalResources as shown below.

ViewModel
import { TextExportService } from '@slickgrid-universal/text-export';

export class MyExample {
  initializeGrid {
    this.gridOptions = {
      enableTextExport: true,
      textExportOptions: {
        sanitizeDataExport: true
      },
      externalResources: [new TextExportService()],
    }
  }
}

If you wish to reference the service to use it with external export button, then simply create a reference while instantiating it.

import { TextExportService } from '@slickgrid-universal/text-export';

export class MyExample {
  exportService: TextExportService;

  constructor() {
    this.exportService = new TextExportService();
  }

  initializeGrid {
    this.gridOptions = {
      enableTextExport: true,
      textExportOptions: {
        sanitizeDataExport: true
      },
      externalResources: [this.exportService],
    }
  }

  exportToFile() {
    this.exportService.exportToFile({ filename: 'export', format: FileType.csv });
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @slickgrid-universal/text-export

Weekly Downloads

275

Version

4.7.0

License

MIT

Unpacked Size

202 kB

Total Files

19

Last publish

Collaborators

  • ghiscoding