opencat/filter-xlsx
Composer 安装命令:
composer require opencat/filter-xlsx
包简介
Excel (.xlsx) file filter for the OpenCAT Framework
README 文档
README
Microsoft Excel XLSX file filter for the CAT Framework.
Installation
composer require catframework/filter-xlsx
Requires ext-dom, ext-libxml, and ext-zip.
Usage
use CatFramework\FilterXlsx\XlsxFilter; $filter = new XlsxFilter(); // Extract translatable segments $document = $filter->extract('data.xlsx', 'en', 'fr'); foreach ($document->getSegmentPairs() as $pair) { $pair->target = new Segment('seg-t', [$translatedText]); } // Write the translated XLSX $filter->rebuild($document, 'data.fr.xlsx');
What gets extracted
XLSX stores cell text in two places; the filter handles both:
| Storage type | Location in ZIP | Notes |
|---|---|---|
| Shared strings | xl/sharedStrings.xml |
Deduplicated across the workbook; only strings actually referenced by cells are extracted |
| Inline strings | xl/worksheets/sheet*.xml (cells with t="inlineStr") |
Extracted and replaced per cell |
Non-translatable strings are skipped automatically: pure numbers, currency values, percentages, and empty strings are detected by a regex heuristic and omitted from extraction.
Rich-text shared strings (multiple <r> runs with different formatting) preserve their formatting as InlineCode pairs on the segment.
On rebuild, xl/calcChain.xml is deleted so Excel recomputes formula dependencies on next open (avoids stale cell reference errors).
Skeleton format
The skeleton is a temporary XLSX file written to the system temp directory at extract time:
['path' => '/tmp/cat-<uniqid>.skl']
The skeleton is a copy of the original XLSX ZIP with translatable cell values replaced by {{SEG:NNN}} tokens. Do not delete it between extract() and rebuild() calls.
Limitations
- Formula cells: cells containing formulas (
=SUM(...)) are not extracted — only their stored text values if present. - Number-format strings: strings that look purely numeric (digits, commas, currency symbols,
%) are silently skipped. If a string like"1,234 units"should be translatable, it will be skipped due to the numeric heuristic. - Worksheet names: tab names are not extracted.
- Skeleton lifetime: the
.skltemp file must survive betweenextract()andrebuild(). For long-lived workflows, persist$document->skeleton['path'].
opencat/filter-xlsx 适用场景与选型建议
opencat/filter-xlsx 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 opencat/filter-xlsx 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 opencat/filter-xlsx 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-09