#435·OfficeCLI

xlsx 中的 "get" 和 "view text" 在共享字符串表中是二次函数

作者: rpinckne创建于 2026年9月24日更新于 2026年9月25日

Minimal SpreadsheetML: one sheet, N rows x 1 column of unique strings. mode "shared": t="s" cells + xl/sharedStrings.xml (what Excel writes) mode "inline": t="inlineStr" cells (no shared-strings table) import sys, zipfile n, mode, out = int(sys.argv[1]), sys.argv[2], sys.argv[3] NS = 'xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"' R = 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"' if mode == "shared": rows = "".join(f'{i-1}' for i in range(1, n + 1)) sst = f'<sst {NS} count="{n}" uniqueCount="{n}">' + "".join(f"item {i}" for i in range(n)) + "" else: rows = "".join(f'item {i-1}' for i in range(1, n + 1)) with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as z: z.writestr("[Content_Types].xml", '' + ('' if mode == "shared" else "") + "") z.writestr("_rels/.rels", '<Relationship Id="rId1"

内容来源: iOfficeAI/OfficeCLI