npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mini-mat-table-exporter

v9.0.0

Published

Provides exporting support for @angular/material tables

Downloads

9

Readme

Angular Material Table Exporter

JavaScript Style Guide: Good Parts Node version Total Downloads

This package is to make MatTable components exportable in excel, csv, txt and json formats. Pagination is also supported. Applying MatTableExporter directive to your MatTable is enough to make it exportable. The directive uses different exporter services for different exporting types. You can also implement your own exporter and use it for your custom exporting requirements.

This project employs xlsx sheetjs, which is a great library and mature enough for the excel creation itself. In order to achieve a cross-browser file saving capability FileSaverjs is employed.

The MatTableExporter directive inside this package is a mini-cdk-table-exporter subtype and provides support for angular material's cdkTable. mini-cdk-table-exporter facilitates the common exporting related functionalities for CdkTable implementations abstracting the behavior that can change among different CdkTables.

 

Getting Started

Angular Material Users

If you are employing angular material in your project. Install mini-mat-table-exporter

npm install --save mini-mat-table-exporter

NOTE: For the previous major versions of Angular install version 1.2.5

npm install --save [email protected]

After installing mini-mat-table-exporter import MatTableExporterModule in your ngModule

import { MatTableExporterModule } from 'mini-mat-table-exporter';

Other than Angular Material

Install mini-cdk-table-exporter if you are not using angular material in your project. In this case you have to implement your version of CdkTableExporter abstract class to use as your directive.

npm install --save mini-cdk-table-exporter

NOTE: For the previous major versions of Angular install version 1.2.5

npm install --save [email protected]

After installing mini-cdk-table-exporter import CdkTableExporterModule in your ngModules

import { CdkTableExporterModule } from 'mini-cdk-table-exporter';

 

Usage

Angular Material Users

matTableExporter is the directive selector.

<mat-table matTableExporter [dataSource]="dataSource" #exporter="matTableExporter">
<button mat-button (click)="exporter.exportTable('csv')"></button>

 

* Stackblitz demo: mte-demo.
* Stackblitz demo of custom exporter mte-cex-demo.

 

##API

MatTableExporterDirective

| Input/Output | Property | Type | Description | | --- | --- | --- | --- | | @Input | hiddenColumns | Array<number> | (Optional) The indexes of the columns that are not wanted in the output file | | @Input | exporter | Exporter<Options> | (Optional) The actual exporting implementation that defines the strategy to be applied to the rows extracted from MatTable. | | @Output | exportStarted | EventEmitter<void> | (Optional) Event that's fired when the export started | | @Output | exportCompleted | EventEmitter<void> | (Optional) Event that's fired when the export completed |

 

| Method | Description | |----------|-------------| | exportTable(exportType?: ExportType, options?: Options) | Called to trigger the export of MatTable|

 

ExportType

export enum ExportType {
  XLS = 'xls',
  XLSX = 'xlsx',
  CSV = 'csv',
  TXT = 'txt',
  JSON = 'json',
  OTHER = 'other'
}

 

Options

| Property | Type | Description | |----------|--------|-------------| | fileName | string |(Optional) Name of the exported file|

 

ExcelOptions

ExcelOptions wraps the WritingOptions of sheetjs library. All other export types share the common Options interface. In the next releases, options will be enriched for the other export types.

| Property | Type | Description | |----------|--------|-------------| | fileName | string |(Optional) Name of the exported file| | type | 'base64', 'binary', 'buffer', 'file', 'array', 'string' |(Optional) Output data encoding| | bookSST | boolean |(Optional) Generate Shared String Table @default false| | sheet | string |(Optional) Name of the exported sheet| | compression | boolean |(Optional) Use ZIP compression for ZIP-based formats @default false| | ignoreEC | boolean |(Optional) Suppress "number stored as text" errors in generated files @default true| | Props | Properties |(Optional) Workbook properties like Author, Title, Subject etc.| | columnWidths | Array<number> | (Optional) Column widths in maximum char |  

Licence

Apache-2.0