valentinloiseau / excel-data-extractor
Excel Data Extractor 会爬取 Excel 文件并提取其中表格的标题和数据。
v0.1.1
2019-12-23 17:54 UTC
Requires
- php: ^7.2
- phpoffice/phpspreadsheet: ^1.10
This package is auto-updated.
Last update: 2024-09-22 20:26:28 UTC
README
Excel Data Extractor 会爬取 Excel 文件并提取其中表格的标题和数据。
安装
$ composer require valentinloiseau/excel-data-extractor
使用方法
$crawler = new Crawler('path/to/my/file.xlsx'); # Make some adjustments Configuration::setLineAttributesFromHeader(true); $table = $crawler->getTable(); $headers = $table->getHeaders(); $lines = $table->getLines();
配置
调用以下类 Configuration
的静态方法
setIgnoreBlankLines
默认为 true
。
设置为 false
以获取所有表格行,包括空白行。
setLineAttributesFromHeader
默认为 false
。
默认情况下,单元格值存储在对应的字符串列索引属性中,例如:如果当前行的第一个单元格值是 'bar',则结果将是 'A' => 'bar'
。
对于相同的示例,如果此配置设置为 true
且猜测的列名为 'foo',则结果将是 'foo' => 'bar'
。