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

@notadd/ngx-xlsx

v1.1.7

Published

基于[SheetJS/js-xlsx](https://github.com/SheetJS/js-xlsx),Angular导入、导出Excel,支持单个或者多个工作表导出、支持自定义表头、支持自定义工作表名称。

Downloads

79

Readme

ngx-xlsx

基于SheetJS/js-xlsx,Angular导入、导出Excel,支持单个或者多个工作表导出、支持自定义表头、支持自定义工作表名称。

How to use

step-1

安装@notadd/ngx-xlsx

  • npm install @notadd/ngx-xlsx -S

安装依赖

  • npm install xlsx -S
  • npm install file-saver -S

step-2

  • 添加NgxXLSXModule到你的AppModule
  import { NgxXLSXModule } from '@notadd/ngx-xlsx';

  @NgModule({
    imports: [
        ...
        NgxXLSXModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
  })
  export class AppModule { }

step-3

  • 在你的component中引入 NgxXLSXService
  import { NgxXLSXService } from '@notadd/ngx-xlsx';

step-4

  • 注入service并在需要的地方调用导出方法 exportAsExcelFile
  • 注入service并在需要的地方调用导入方法 importForExcelFile

exportAsExcelFile 方法

参数

| 参数名 | 类型 | 是否必填 | 默认值 | 说明 | |:-------------|:--------|:--------|:------|:---------------------------------------------------------------------------------------------------------------------------------------| | json | any[] | 必填 | | 需要导出的数据json 多个工作表导出时数据为二维数组:[[工作表1],[工作表2],[工作表三]] 单个工作表导出时数据为一维数组:[工作表1] | | exportOptions | ExportOptions | 非必填 | {} | 导出配置 |

Interface

export interface ExportOptions {
  /* 文件名, 默认为时间戳 */
  fileName?: string;     

  /* 表头,默认为 json 数组对象的 Object.keys, 长度必须与 json 数组对象的 Object.keys 长度相等 */
  /* 多个工作表可以对应多个表头或单个表头,多个表头为二维数组,与多个工作表匹配 */
  headers?: Array<string | Array<string>>;   

  /* Excel 工作表名称,默认为 'sheet' +索引(从1开始) 多个工作表导出时长度必须与 json 数组长度相等 单个工作表导出时长度必须等于1 */   
  sheetNames?: Array<string>;

  /* 需要合并单元格的数组,['A1:B1'] 和 [['0,0', '0,1']] 等效,两种写法都支持 */
  merges?: Array<string | Array<string>>;
}

importForExcelFile 方法

参数

| 参数名 | 类型 | 是否必填 | 默认值 | 说明 | |:-------------|:--------|:--------|:------|:---------------------------------------------------------------------------------------------------------------------------------------| | file | File | 必填 | | 需要导入的 Excel 文件对象 | | importOptions | ImportOptions | 非必填 | {} | 导入配置 |

Interface

export interface ImportOptions {
  /* 表头行数,默认为1,当 `headerKeys` 不为 `[]` 时导入的数据会按表头行数截取数组 */
  headerRows?: number;   

  /* Excel 表头对应的导入 `json` 的 `key`,默认为 Excel 表头 */
  /* 多个工作表可以对应多个`key`数组或单个`key`数组,多个`key`数组为二维数组 */
  headerKeys?: Array<string | Array<string>>;
}