webgriffe / associative-spreadsheet-iterator
1.6.1
2015-11-12 14:40 UTC
Requires
- phpoffice/phpexcel: @stable
Requires (Dev)
- mikey179/vfsstream: @stable
README
这个PHP库允许您以关联方式遍历电子表格。每个遍历的行都按列名索引。支持phpoffice/phpexcel支持的所有格式。
例如,给定如下电子表格
您可以通过这种方式遍历它,并将每一行作为如下关联数组获取
array(
array(
'Name' => 'RaspberryPi',
'Description' => 'Raspberry PI Modell B, 512 MB',
'Price' => 37.05,
'Stock' => 12,
),
array(
'Name' => 'SanDisk Ultra SDHC',
'Description' => 'SanDisk Ultra SDHC 8 GB 30 MB/s Classe 10',
'Price' => 6.92,
'Stock' => 54,
),
),
安装
您可以使用 Composer 安装此库
$ composer require webgriffe/associative-spreadsheet-iterator @stable
使用方法
简单地将Composer的自动加载器包含在内,并通过传递文件路径实例化迭代器
<?php
require 'vendor/autoload.php'
$file = '/path/to/spreadsheet.xlsx';
$spreadsheetIterator = new Webgriffe\AssociativeSpreadsheetIterator\Iterator($file);
foreach ($iterator as $row) {
// $row is an associative array indexed by column name
}