excel-export-plugin
v1.0.6
Published
A plugin for exporting data to Excel files
Readme
excelExportPlugin
A lightweight and flexible plugin for exporting data to Excel files. It supports exporting data from arrays or Blob objects, with customizable headers and file names.
一个轻量级且灵活的插件,用于将数据导出为 Excel 文件。支持从数组或 Blob 对象导出数据,并支持自定义表头和文件名。
Features / 功能
Export from arrays or
Blobobjects: Easily export structured data or raw binary data.Customizable headers: Define column headers for better control over the exported file format.
Lightweight and easy to use: Minimal dependencies and simple API.
File name customization: Specify the name of the exported Excel file.
Cross-browser support: Works in modern browsers.
支持从数组或
Blob对象导出:轻松导出结构化数据或原始二进制数据。支持自定义表头:定义列标题,便于控制导出的文件格式。
轻量级,易于使用:依赖最少,API 简单。
支持文件名自定义:可指定导出的 Excel 文件名。
跨浏览器支持:适用于现代浏览器。
Installation / 安装
Install the plugin via npm:
通过 npm 安装插件:
npm install excel-export-pluginUsage / 使用方法
Basic Example / 基本示例
import { exportExcel } from "excel-export-plugin";
const data = [
{ id: 1, name: "Alice", email: "[email protected]" },
{ id: 2, name: "Bob", email: "[email protected]" },
];
exportExcel({
data,
columns: [
{ key: "id", title: "User ID" },
{ key: "name", title: "User Name" },
{ key: "email", title: "Email Address" },
],
fileName: "users.xlsx",
});API Reference / API 参考
exportExcel(options)
Exports data to an Excel file.
将数据导出为 Excel 文件。
Parameters / 参数
options.data(Array | Blob)
The data to be exported. Can be an array of objects or aBlobobject.
要导出的数据,可以是对象数组或Blob对象。options.columns(Array)
An array of column definitions. Each column should have akey(data field) and atitle(header name).
列定义数组。每列应包含key(数据字段)和title(表头名称)。options.fileName(String)
The name of the exported Excel file (e.g.,data.xlsx).
导出的 Excel 文件名(例如:data.xlsx)。
Example / 示例
exportExcel({
data: [
{ id: 1, name: "Alice", email: "[email protected]" },
{ id: 2, name: "Bob", email: "[email protected]" },
],
columns: [
{ key: "id", title: "User ID" },
{ key: "name", title: "User Name" },
{ key: "email", title: "Email Address" },
],
fileName: "users.xlsx",
});Use Cases / 使用场景
- Exporting user data from a web application.
从 Web 应用导出用户数据。 - Generating reports in Excel format.
生成 Excel 格式的报告。 - Saving raw data for offline analysis.
保存原始数据以供离线分析。
License / 许可证
MIT License. See LICENSE for details.
MIT 许可证。详情请参阅 LICENSE。
