@csvbox/angular2

中文文档
2.0.0发布于 2026/10/26MITTypeScriptES Module近 30 天下载 3160

Standalone Angular component for csvbox.io supporting Angular version 14 till 22

原始使用文档
文档目录13 节
  1. ✅ Only for Angular version 14 and above
  2. ⚠️ For Angular version 13 or less, please use @csvbox/angul…
  3. Compatibility
  4. Shell
  5. Import
  6. Usage
  7. Example
  8. Events
  9. Importing a file you already have
  10. Several importers on one page
  11. Closing the importer during an import
  12. Readme
  13. License

@csvbox/angular2

Standalone Angular component for csvbox.io supporting Angular version 14 and above

✅ Only for Angular version 14 and above

⚠️ For Angular version 13 or less, please use @csvbox/angular package

NPM JavaScript Style Guide

Compatibility

Angular VersionPackage
8 to 13@csvbox/angular
14 and above@csvbox/angular2 (this package)

Shell

npm install @csvbox/angular2

Import

Add CSVBoxButtonComponent to your module imports

import { CSVBoxButtonComponent } from "@csvbox/angular2";

@NgModule({
  ...
  imports: [
    ...
    CSVBoxButtonComponent
  ]
})

Usage

<csvbox-button [licenseKey]="licenseKey" [isImported]="isImported.bind(this)" [user]="user">Import</csvbox-button>

Example


@Component({
  selector: 'app-root',
  template: `
    <csvbox-button
      [licenseKey]="licenseKey"
      [user]="user"
      [isImported]="isImported.bind(this)">
      Import
    </csvbox-button>
  `
})

export class AppComponent {

  title = 'example';
  licenseKey = 'YOUR_LICENSE_KEY_HERE';
  user = { user_id: 'default123' };

  isImported(result: boolean, data: any) {
    if(result) {
      console.log("Sheet uploaded successfully");
      console.log(data.row_success + " rows uploaded");
    }else{
      console.log("There was some problem uploading the sheet");
    }
  }

}

Events

EventDescription
isReadyTriggers when the importer is initialized and ready for use by the users.
isClosedTriggers when the importer is closed.
isSubmittedTriggers when the user hits the 'Submit' button to upload the validated file. data object is available in this event. It contains metadata related to the import.
isImportedTriggers when the data is pushed to the destination.
Two objects are available in this event:
1. result (boolean): It is true when the import is successful and false when the import fails.
2. data (object): Contains metadata related to the import.

Importing a file you already have

openModalWithFile(file) opens the importer on a File your own page is holding — from your own drop target, your own file input, anything — instead of the importer's file picker. The file still goes through the importer's extension, worksheet and size checks; this skips the picker, not the validation.

Call it through a template reference variable:

<csvbox-button #importer [licenseKey]="licenseKey" [user]="user" [isImported]="isImported.bind(this)">
  Import
</csvbox-button>

<input type="file" (change)="importer.openModalWithFile($any($event.target).files[0])" />

or from the component class with @ViewChild(CSVBoxButtonComponent) importer: CSVBoxButtonComponent; and this.importer.openModalWithFile(file).

The importer can decline a file it is handed, and says why in a console warning ([csvbox] importer declined the supplied file: <reason>):

  • import-in-progress — the importer is open past its upload step, or is still reading an earlier file. An import that is already open stays open.
  • modal-closing — the importer was closing when the file arrived.
  • import-file-url-configured — the sheet is set up to load its own file from a URL.

Pass a File, not a Blob: a Blob has no name to read an extension from, and anything that is not a File is ignored.

When the importer redirects to another host (data-location sheets do this), the file is sent to the host the importer actually ended up on, as long as that host is your importer domain or <region>-<your domain> (for example eu-app.csvbox.io for app.csvbox.io). A file is never sent to any other host.

If the importer does not answer a supplied file within about 8 seconds (for example because it redirected to a host that does not follow that naming, or it is too old to know the message), the importer is put away, the other buttons are enabled again, and the console says [csvbox] the importer did not respond to the supplied file.

Several importers on one page

While an importer is open (or still loading to open), the button of every other CSVBox instance on the page is disabled until it closes, so two importers are not opened by accident. In React, the second argument of the render prop (isLoading) is also true in that state, so a custom trigger can disable itself the same way.

Opening a second importer from code (openModal() or openModalWithFile()) is still possible. The importer opened last is shown on top of the others, and closing it reveals the one underneath.

Closing the importer during an import

If your user submits a file and then closes the importer before the import has finished, the import carries on and your isImported (or onImport) callback is still called with the result when it completes. The importer is reloaded the next time it is opened.

Readme

For usage see the guide here - https://help.csvbox.io/getting-started#2-install-code

License

MIT © csvbox-io

版本与发布记录

@csvbox/angular2 共发布 8 个版本,首次发布于 2025/03/19;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.0.0latest2026/10/2615 天前
1.0.62026/09/301 个月前
1.0.52026/08/192 个月前
1.0.42025/10/171.1 年前
1.0.32025/10/161.1 年前
1.0.22025/07/141.3 年前

关于 @csvbox/angular2 的常见问题

@csvbox/angular2 是什么?

Standalone Angular component for csvbox.io supporting Angular version 14 till 22

如何安装 @csvbox/angular2?

在项目目录运行 npm install @csvbox/angular2,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/core(>=14.0.0 <23.0.0)、@angular/common(>=14.0.0 <23.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@csvbox/angular2 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@csvbox/angular2 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@csvbox/angular2 可以商用吗?

@csvbox/angular2 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@csvbox/angular2 的下载量有多少?

根据 npm 官方下载统计,@csvbox/angular2 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,160 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@csvbox/angular2 还在维护吗?

最新版本 2.0.0 发布于 2026/10/26(15 天前);至今共发布 8 个版本,其中过去 12 个月发布了 3 个;首次发布于 2025/03/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。