23 lines
509 B
PHP
23 lines
509 B
PHP
<?php
|
|
|
|
namespace Stemcell\Catalog\Helper;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
class Excel
|
|
{
|
|
/**
|
|
* @param string $filePath 文件路径
|
|
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
|
|
* @throws \Exception
|
|
*/
|
|
public static function getExcelSheet(string $filePath)
|
|
{
|
|
if (!file_exists($filePath)) {
|
|
throw new \Exception(sprintf('File %s does not exist', $filePath));
|
|
}
|
|
|
|
return IOFactory::load($filePath)->getActiveSheet();
|
|
}
|
|
}
|