/install excelize
\r \r
Description\r
\r Package excelize-py is a Python port of Go Excelize library, providing a set of functions that allow you to write and read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and writing spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports complex components by high compatibility, and provided streaming API for generating or reading data from a worksheet with huge amounts of data. This library needs Python version 3.9 or later. The full API docs can be found at docs reference.\r \r
Basic Usage\r
\r
Installation\r
\r
pip install excelize\r
```\r
\r
### Create spreadsheet\r
\r
Here is a minimal example usage that will create spreadsheet file.\r
\r
```python\r
import excelize\r
\r
f = excelize.new_file()\r
try:\r
# Create a new sheet.\r
index = f.new_sheet("Sheet2")\r
# Set value of a cell.\r
f.set_cell_value("Sheet2", "A2", "Hello world.")\r
f.set_cell_value("Sheet1", "B2", 100)\r
# Set active sheet of the workbook.\r
f.set_active_sheet(index)\r
# Save spreadsheet by the given path.\r
f.save_as("Book1.xlsx")\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
finally:\r
err = f.close()\r
if err:\r
print(err)\r
```\r
\r
### Reading spreadsheet\r
\r
The following constitutes the bare to read a spreadsheet document.\r
\r
```python\r
import excelize\r
\r
try:\r
f = excelize.open_file("Book1.xlsx")\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
exit()\r
try:\r
# Get value from cell by given worksheet name and cell reference.\r
cell = f.get_cell_value("Sheet1", "B2")\r
print(cell)\r
# Get all the rows in the Sheet1.\r
rows = f.get_rows("Sheet1")\r
for row in rows:\r
for cell in row:\r
print(f"{cell} ", end="")\r
print()\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
finally:\r
# Close the spreadsheet.\r
err = f.close()\r
if err:\r
print(err)\r
```\r
\r
### Add chart to spreadsheet file\r
\r
With Excelize chart generation and management is as easy as a few lines of code. You can build charts based on data in your worksheet or generate charts without any data in your worksheet at all.\r
\r
\x3Cp align="center">\x3Cimg width="650" src="https://github.com/xuri/excelize-py/raw/main/chart.png" alt="Excelize">\x3C/p>\r
\r
```python\r
import excelize\r
\r
f = excelize.new_file()\r
data = [\r
[None, "Apple", "Orange", "Pear"],\r
["Small", 2, 3, 3],\r
["Normal", 5, 2, 4],\r
["Large", 6, 7, 8],\r
]\r
try:\r
for idx, row in enumerate(data):\r
cell = excelize.coordinates_to_cell_name(1, idx + 1, False)\r
f.set_sheet_row("Sheet1", cell, row)\r
chart = excelize.Chart(\r
type=excelize.ChartType.Col3DClustered,\r
series=[\r
excelize.ChartSeries(\r
name="Sheet1!$A$2",\r
categories="Sheet1!$B$1:$D$1",\r
values="Sheet1!$B$2:$D$2",\r
),\r
excelize.ChartSeries(\r
name="Sheet1!$A$3",\r
categories="Sheet1!$B$1:$D$1",\r
values="Sheet1!$B$3:$D$3",\r
),\r
excelize.ChartSeries(\r
name="Sheet1!$A$4",\r
categories="Sheet1!$B$1:$D$1",\r
values="Sheet1!$B$4:$D$4",\r
),\r
],\r
title=[excelize.RichTextRun(text="Fruit 3D Clustered Column Chart")],\r
)\r
f.add_chart("Sheet1", "E1", chart)\r
# Save spreadsheet by the given path.\r
f.save_as("Book1.xlsx")\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
finally:\r
err = f.close()\r
if err:\r
print(err)\r
```\r
\r
### Add picture to spreadsheet file\r
\r
```python\r
import excelize\r
\r
try:\r
f = excelize.open_file("Book1.xlsx")\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
exit()\r
try:\r
# Insert a picture.\r
f.add_picture("Sheet1", "A2", "image.png", None)\r
# Insert a picture to worksheet with scaling.\r
f.add_picture("Sheet1", "D2", "image.jpg", excelize.GraphicOptions(\r
scale_x=0.5,\r
scale_y=0.5,\r
))\r
# Insert a picture offset in the cell with printing support.\r
f.add_picture("Sheet1", "H2", "image.gif", excelize.GraphicOptions(\r
print_object=True,\r
lock_aspect_ratio=False,\r
offset_x=15,\r
offset_y=10,\r
locked=False,\r
))\r
# Save the spreadsheet with the origin path.\r
f.save()\r
except (RuntimeError, TypeError) as err:\r
print(err)\r
finally:\r
# Close the spreadsheet.\r
err = f.close()\r
if err:\r
print(err)\r
```\r
\r
## References\r
\r
- Source Code: [github.com/xuri/excelize-py](https://github.com/xuri/excelize-py)\r
- Docs Repo: [github.com/xuri/excelize-py-docs](https://github.com/xuri/excelize-py-docs)\r
- PyPI: [pypi.org/project/excelize](https://pypi.org/project/excelize)\r
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install excelize - 安装完成后,直接呼叫该 Skill 的名称或使用
/excelize触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Excelize 是什么?
Use when you need to reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 196 次。
如何安装 Excelize?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install excelize」即可一键安装,无需额外配置。
Excelize 是免费的吗?
是的,Excelize 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Excelize 支持哪些平台?
Excelize 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Excelize?
由 xuri(@xuri)开发并维护,当前版本 v0.0.1。