Python implementations of common Microsoft Excel functions, layered API and Excel-like error values.
Project description
PyExcelFunctionsImpl / excel-funcs-py
在 Python 中复现常用 Microsoft Excel 工作表函数 的行为,提供三层 API:纯函数(Layer 1)、按功能区分类的 Facade(Layer 2)、统一入口 ExcelFunctions(Layer 3)。
安装
cd PyExcelFunctionsImpl
pip install -e .
仅开发依赖:
pip install -e ".[dev]"
快速开始
from excel_funcs import ExcelFunctions, SUM, IF
# 函数式(与 Excel 名称对应的大写别名,见 __init__.py)
print(SUM(1, 2, 3, [4, 5])) # 15.0
print(IF(True, "yes", "no"))
# 文本转数字请用 VALUE_FROM_TEXT(与错误常量 VALUE 区分)
from excel_funcs import VALUE_FROM_TEXT
print(VALUE_FROM_TEXT("123.45"))
# 分层入口(IDE 友好)
xf = ExcelFunctions()
print(xf.math.sum(1, 2, 3))
print(xf.logical.if_(True, "A", "B"))
命令行小演示:
python -m excel_funcs
与 Microsoft Excel 的差异(重要)
| 主题 | 说明 |
|---|---|
| 单元格与区域 | Python 使用 list、tuple 或嵌套列表表示区域;空单元格请显式传 None 或 ""(视函数而定)。 |
| 日期 | 默认使用 datetime.date / datetime.datetime;部分函数支持 Excel 序列号需查看各函数文档。 |
| 错误值 | #N/A、#VALUE! 等以不可变对象 ExcelErrorValue 表示,可用 ISERROR / ISNA 判断;与 Excel 完全一致的边缘情况仍在迭代中。 |
| 数组公式 / 动态数组 | UNIQUE、SORT、FILTER 等提供基于列表的简化实现;复杂溢出行为与 Excel 365 可能不同。 |
| 本地化 | 小数点、参数分隔符等以 Python 语法为准,不模拟区域格式。 |
完整函数清单与实现状态见 docs/function-list.md。
发布到 PyPI
- 在 PyPI 搜索并确认发行名
excel-funcs-py(pyproject.toml里[project] name)未被占用;import 包名仍为excel_funcs,二者可以不同。 - 安装构建工具:
pip install build twine - 构建:
python -m build - 检查:
twine check dist/* - 上传测试索引(可选):
twine upload --repository testpypi dist/* - 正式上传:
twine upload dist/*
请使用 API token 或可信凭据,切勿将 token 写入仓库。
项目布局
PyExcelFunctionsImpl/
src/excel_funcs/ # 可导入包 excel_funcs
docs/ # 函数列表与设计说明
tests/ # pytest
许可证
MIT,见 LICENSE。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file excel_funcs_py-0.1.0.tar.gz.
File metadata
- Download URL: excel_funcs_py-0.1.0.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f50c6429514e0c5d73f9c361acb0221ac5c4b6978efd90516eaa7c30fba3a00a
|
|
| MD5 |
6641fdd25e5685fef297a55f149ade5e
|
|
| BLAKE2b-256 |
44890b0539acde2e6d90586fdad3f10fbd859f1bfd0e80074b3637ed07dfecca
|
File details
Details for the file excel_funcs_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: excel_funcs_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
611f54995e29691cbb2550a52b9e267d64decc26b026a919ffc122991d7a735c
|
|
| MD5 |
7dd7a7b6261c1d007360c6e6c94443fc
|
|
| BLAKE2b-256 |
141727de019f99afc630eef2ea62411cfbcf86f14df5a302660b090b5275787f
|