px普贤教程PuXian
普贤教程 › 包参考

xlsx 包

最小 .xlsx 写器 + 读器 · 0.2.0

项值
包名xlsx
版本0.2.0
可用版本0.1.0 / 0.2.0
入口xlsx.px
分类数据格式与编解码
文件数 / 行数2 / 514

安装与引入

bash
pxpkg init          # 首次
pxpkg add xlsx@0.2.0
pxpkg install
px
import xlsx
所属分类教程:数据格式与编解码

公开接口

函数参数
xsx_new
xsx_styledoc, name, opts
xsx_adddoc, name, rows
xsx_writedoc, path
xsx_read_sheetpath, idx
xsx_readpath
其余 25 个 def(内部与辅助,可直接调用但不属稳定接口)
函数参数
xsx_col_letteridx
xsx_partsdoc
o_col_lettersref
o_col_idxletter
o_el_childel, name
o_el_textel
o_has_filedir, name
o_parse_sharedxml
o_has_dotv
o_cell_val_parsec, shared
o_cell_valc, shared
o_parse_sheetxml, shared
xp_escs
xp_is_numc
xsx_col_letter_nsidx
xp_font_xmlopts
xp_fill_xmlopts
xp_styles_planstyles
xp_cell_fieldscell
xp_cellcell, col, row, styles_idx
xp_worksheetrows, styles_idx
xp_content_typessheets
xp_root_rels
xp_workbooksheets
xp_workbook_relssheets

包内说明(源码头注释)

text
============================================================
普贤生态库:registry/xlsx —— 最小 .xlsx 写器 + 读器 · 0.2.0
------------------------------------------------------------
纯函数库(构建 parts 无 IO;写出时调 zip_pack),双模式验证
(zip 族 M201 已修复:m204 解释轨 zip_pack/zip_unpack 可用)。
对齐 Python openpyxl / Rust rust_xlsxwriter 心智:
xsx_new()                      → dict       新建文档(无工作表)
xsx_style(doc, name, opts)     → dict       注册命名样式(返回新 doc)
opts     = {"bold": true, "italic": true, "underline": true,
"color": "FF0000", "fill": "FFFF00", "size": 14,
"align": "left|center|right", "valign": "top|center|bottom"}
xsx_add(doc, name, rows)       → dict       追加工作表(返回新 doc)
cell     = str(inlineStr)| int/float(数字)| bool | null(空单元格)
| {"v": 值, "style": "样式名"}             (带样式)
| {"f": "SUM(A1:A2)", "v": 175, "style": "bold"}(公式单元格)
xsx_write(doc, path)           → Ok | Err   写出 .xlsx(zip_pack)
xsx_read(path) / xsx_read_sheet(path, idx) → Ok(rows)
公式单元格读回 → {"f": 公式, "v": 缓存值}
结构:Content_Types + rels + workbook + 每个 worksheet + 动态 styles
(fonts/fills/cellXfs 按命名样式生成,单元格 s="xf 索引")。
============================================================