|
1 | | -# EXCEL2HTML |
| 1 | +# Excel 解析模块 / Excel Parsing Module |
2 | 2 |
|
3 | | -XSLX/XLS files into HTML сonverter |
| 3 | +## 概述 / Overview |
4 | 4 |
|
5 | | -## Usage: |
| 5 | +本模块负责从 Excel 文件(`.xlsx` 和 `.xls`)中提取纯文本内容,供全文检索使用。 |
| 6 | + |
| 7 | +This module extracts plain text content from Excel files (`.xlsx` and `.xls`) for full-text search purposes. |
| 8 | + |
| 9 | +## 文件结构 / File Structure |
| 10 | + |
| 11 | +``` |
| 12 | +excel/ |
| 13 | +├── excel.cpp / excel.hpp # 入口类,根据扩展名分发解析 |
| 14 | +├── excel_xlsxio.cpp / .hpp # XLSX 解析(基于 xlsxio SAX 流式) |
| 15 | +├── excel_libxls.cpp / .hpp # XLS 解析(基于 libxls) |
| 16 | +├── xlsxio/ # xlsxio 库源码 |
| 17 | +│ ├── xlsxio_read.c # SAX 流式读取实现 |
| 18 | +│ ├── xlsxio_read_sharedstrings.c # 共享字符串表处理 |
| 19 | +│ └── xlsxio_read.h / *.h # 头文件 |
| 20 | +└── libxls/ # libxls 库源码 |
| 21 | + ├── xls.c / ole.c / xlstool.c # OLE + BIFF 解析实现 |
| 22 | + ├── endian.c / locale.c # 字节序与编码处理 |
| 23 | + └── include/ # 头文件 |
| 24 | + ├── xls.h |
| 25 | + └── libxls/ |
6 | 26 | ``` |
7 | | -#include "excel/excel.hpp" |
8 | 27 |
|
9 | | -excel::Excel document("test.xlsx", "xlsx"); |
10 | | -document.convert(true, true, 0); |
11 | | -document.saveHtml("out_dir", "test.html"); |
| 28 | +## 架构 / Architecture |
| 29 | + |
| 30 | +``` |
| 31 | +Excel::convert() |
| 32 | + │ |
| 33 | + ├── .xlsx ──→ parseXlsxWithXlsxio() |
| 34 | + │ └── xlsxio (SAX 流式解析,expat + minizip) |
| 35 | + │ |
| 36 | + └── .xls ──→ parseXlsWithLibxls() |
| 37 | + └── libxls (OLE + BIFF 解析,内置 UTF-8 转换) |
12 | 38 | ``` |
13 | 39 |
|
14 | | -## Features |
15 | | -| Extension | Text | Styles extraction | Images extraction | |
16 | | -| :---: | :---:| :---: | :---: | |
17 | | -| XLSX | Yes | Yes | Yes | |
18 | | -| XLS | Yes | Yes | No | |
| 40 | +## 外部依赖 / External Dependencies |
| 41 | + |
| 42 | +| 依赖 | 用途 | 许可证 | |
| 43 | +|------|------|--------| |
| 44 | +| expat | xlsxio 的 XML SAX 解析 | MIT | |
| 45 | +| minizip | xlsxio 的 ZIP 解压 | Zlib | |
| 46 | +| zlib | minizip 的底层依赖 | Zlib | |
| 47 | +| iconv | libxls 的编码转换(系统库) | LGPL | |
19 | 48 |
|
20 | | -- Table cell styles |
21 | | -- Images |
22 | | -- Bold/Italic/Underline/Strike/Sup(sub)string font style |
23 | | -- Font colors and names |
24 | | -- Horizontal and vertical aligment |
| 49 | +xlsxio 和 libxls 的源码已直接包含在本目录中,无需额外下载。 |
| 50 | + |
| 51 | +The xlsxio and libxls sources are bundled locally; no additional download required. |
| 52 | + |
| 53 | +## 输出格式 / Output Format |
| 54 | + |
| 55 | +每个非空单元格的值后跟换行符 `\n`,所有工作表的内容顺序拼接: |
| 56 | + |
| 57 | +Each non-empty cell value is followed by a newline `\n`; all sheet contents are concatenated in order: |
| 58 | + |
| 59 | +``` |
| 60 | +A1的值 |
| 61 | +B1的值 |
| 62 | +A2的值 |
| 63 | +... |
| 64 | +``` |
25 | 65 |
|
26 | | -## Dependencies |
27 | | -- iconv |
| 66 | +## 第三方库版本 / Bundled Library Versions |
28 | 67 |
|
29 | | -## Thanks |
30 | | -- [python-excel](https://github.com/python-excel/xlrd) - XLSX and XLS converter (Python) |
| 68 | +- **xlsxio**: 基于 [brechtsanders/xlsxio](https://github.com/brechtsanders/xlsxio) (MIT License) |
| 69 | +- **libxls**: 基于 [libxls/libxls](https://github.com/libxls/libxls) v1.6.3 (BSD-2-Clause License) |
0 commit comments