用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/rodydavis/open_xml --skill open-xml-xlsx命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | open-xml-xlsx |
| description | Guide and examples for using OpenXML Xlsx features in the open_xml package. |
The open_xml package provides robust support for generating, editing, and parsing Excel Workbooks.
To create a new Workbook and add a Sheet:
import 'package:open_xml/open_xml.dart';
import 'package:file/local.dart';
Future<void> main() async {
const fs = LocalFileSystem();
final workbook = await Workbook.create(fs);
// Add a new worksheet
final sheet = workbook.addSheet('Sales Report');
await workbook.save(fs.file('sales.xlsx'));
}
You can add rows to a sheet and insert cells of various types.
// Header Row
sheet.addRow()
..addCell('Product')
..addCell('Price')
..addCell('Quantity')
..addCell('Total');
// Data Row (String, Double, Int)
sheet.addRow()
..addCell('Apples')
..addCell(1.20)
..addCell(50)
..addCell('', formula: 'B2*C2');
The formula parameter on addCell computes values dynamically within Excel.
The package provides utility patterns commonly found in examples/xlsx/ to convert standard data shapes to Excel sheets.
If you have a JSON list:
final List<Map<String, dynamic>> jsonData = [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
];
final sheet = workbook.addSheet('Users');
// Add Header
sheet.addRow()
..addCell('ID')
..addCell('Name');
// Add Rows
for (final row in jsonData) {
sheet.addRow()
..addCell(row['id'])
..addCell(row['name']);
}
Similar looping mechanisms can be used to convert CSV arrays or SQLite streams directly into Excel cells dynamically.
You can add internal links (linking to other cells or sheets within the same workbook) and external hyperlinks.
// Internal Link to Cell A1 on another sheet
sheet.addRow().addCell(
'Go to Sheet 2',
hyperlink: '#\'Sheet 2\'!A1'
);
// External Web Hyperlink
sheet.addRow().addCell(
'Visit Website',
hyperlink: 'https://example.com'
);
You can open existing Excel workbooks and read row data.
final workbook = await Workbook.open(fs.file('data.xlsx'));
for (final sheet in workbook.sheets) {
for (final row in sheet.rows) {
for (final cell in row.cells) {
print(cell.value);
}
}
}