shuangying0001-beep/tabular-exporter

记录数据一键导出 Excel/CSV(带样式):表头冻结、斑马纹、是/否,中文防乱码。适合运营报表、数据导出、日志归档。

Qu'est-ce que tabular-exporter ?

tabular-exporter is a Claude Code agent skill that 记录数据一键导出 Excel/CSV(带样式):表头冻结、斑马纹、是/否,中文防乱码。适合运营报表、数据导出、日志归档。.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/tabular-exporter

Installed? Explore more Productivité et collaboration skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

tabular-exporter —— 记录数组导出为表格

把任意「数组 of 对象」变成带样式的 Excel 或带 BOM 的 CSV。 零依赖:xlsx 由纯 JS 生成(ZIP STORE 法,内置 CRC32),CSV 自带 UTF-8 BOM。无需 npm install 任何包。

适用场景

  • 把采集 / 接口返回的结构化数据导出成可交付的 Excel / CSV
  • 后台「导出」功能、数据报表、数据迁移
  • 需要中文不乱码、带表头样式、冻结首行

提供的函数

函数说明
exportToExcel(rows, columns, opts?)生成带样式 xlsx(Buffer),可选落盘 filePath
exportToCsv(rows, columns, opts?)生成带 BOM 的 CSV 字符串
exportTable(rows, columns, opts?)统一入口,opts.format = 'xlsx' | 'csv'
columnsFromKeys(keys, widths?)由 key 列表快速生成列配置

columns 形如 [{ key, header?, width? }]rows 为对象数组。

样式特性:

  • 表头:加粗 + 白字 + 蓝底(4472C4
  • 冻结首行
  • 斑马纹(偶数行浅灰底)
  • 布尔值 → 是/否;数组 → 换行;对象 → JSON
  • xlsx 与 Excel / WPS / LibreOffice 兼容(标准 OOXML)

用法

import { exportTable, columnsFromKeys } from './scripts/exporter.mjs';

const rows = [
  { title: '无线鼠标', price: 99.5, inStock: true },
  { title: '机械键盘', price: 299, inStock: false },
];
const columns = [
  { key: 'title', header: '标题', width: 40 },
  { key: 'price', header: '价格', width: 12 },
  { key: 'inStock', header: '有货', width: 8 },
];

// 导出 xlsx(直接落盘)
exportTable(rows, columns, { format: 'xlsx', filePath: 'out.xlsx', sheetName: '商品' });

// 导出 csv(返回字符串)
const csv = exportTable(rows, columns, { format: 'csv' });

自测

node scripts/exporter.mjs --selftest

Skills associés