bur-gmbh / xlsx2data
此包的最新版本(dev-master)没有可用的许可证信息。
dev-master
2019-04-05 12:34 UTC
Requires
- cocur/slugify: ^3.2
- phpoffice/phpspreadsheet: ^1.6
- symfony/yaml: ^4.2
This package is auto-updated.
Last update: 2024-09-06 23:21:15 UTC
README
PHP 库,用于将 Microsoft Excel 文件转换为 xml、yaml 或 json 数据
安装
使用 composer 是使用转换器最方便的方式
composer require bur-gmbh/xlsx2data
用法
要加载 Microsoft Excel 文件,只需使用构造函数并传递文件路径和工作表名称
$file = 'myExcel.xlsx';
$sheet = 'Worksheet';
$converter = new Converter($file, $sheet);
如果您未传递工作表名称,转换器将使用活动工作表。
XML
要转换 Excel 数据为 XML,请使用 toXml
函数。
$converter->toXml();
您还可以直接使用以下方式保存数据:
$converter->saveXml('output.xml');
JSON
要转换 Excel 数据为 JSON,请使用以下 toJson
函数。
$converter->toJson()
保存 JSON
$converter->saveJson('output.json');
YAML
使用 toYaml
命令获取 Excel 数据的 Yaml 格式。
$converter->toYaml()
保存为 YAML
$converter->saveYaml('output.yaml');