我正在使用 simplexlsx
处理 excel 文件类和我的输入 excel 文件中将有多个工作表。
<?php
require "simplexlsx.php";
if ( $xlsx = @SimpleXLSX::parse("test.xlsx") ) {
print_r( $xlsx->rows(1) ); // Sheet numeration started 0, we select second worksheet
foreach ( $xlsx->rows() as $r => $row ) {
print_r($row);
echo "<br>";
}
}else{
echo SimpleXLSX::parseError();
}
?>
我正在尝试的是逐页读取excel文件中的数据。
我想要一种方法来了解 excel 中的工作表数量并选择工作表进行数据处理。
最佳答案
<?php
require "simplexlsx.php";
if ( $xlsx = @SimpleXLSX::parse("test.xlsx") ) {
// Sheet numeration started 0, we select second worksheet
$sheets=$xlsx->sheetNames();
foreach($sheets as $index => $name){
echo "Reading sheet :".$name."<br>";
foreach ( $xlsx->rows($index) as $r => $row ) {
print_r($row);
echo "<br>";
}
echo "<hr>";
}
}else{
echo SimpleXLSX::parseError();
}
?>
关于php - 逐张从excel文件中提取数据。单工lsx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60564376/