throw new Exception('The file type ' . $ext . ' is not supported');
}
+ public static function excelToArrayRaw($file, $force = false)
+ {
+ return self::_excelToArray($file, false, $force);
+ }
/**
* @throws Exception
return $res;
}
- public static function excelToArrayIndexKeyVars($file, $skipEmptyId = false, $force = false)
+ /**
+ * @param $file
+ * @param $force
+ * @return \PhpOffice\PhpSpreadsheet\Spreadsheet
+ * @throws Exception
+ */
+ protected static function _excelToArrayKeyVarsCommon($file, $force = false)
{
-
$e = explode('#', $file);
$file = $e[0];
} else {
$worksheet = array_shift($worksheets);
}
+ return $worksheet;
+ }
+ /**
+ * @throws Exception
+ */
+ public static function excelToArrayIndexKeyVars($file, $force = false)
+ {
+ $worksheet = self::_excelToArrayKeyVarsCommon($file, $force);
$res = [];
foreach ($worksheet as $i => $line) {
if ($i === 0) {
return $res;
}
+ /**
+ * @throws Exception
+ */
public static function excelToArrayKeyVars($file, $skipEmptyId = false, $force = false)
{
- $e = explode('#', $file);
- $file = $e[0];
-
- $worksheets = self::_excelToArray($file, false, $force);
-
- if (isset($e[1])) {
- $sheetName = trim($e[1]);
- }
-
- if (isset($sheetName, $worksheets[$sheetName])) {
- $worksheet = $worksheets[$sheetName];
- } else {
- $worksheet = array_shift($worksheets);
- }
-
-
+ $worksheet = self::_excelToArrayKeyVarsCommon($file, $force);
$res = [];
foreach ($worksheet as $i => $line) {
if ($i === 0) {
return $res;
}
- public static function excelToArrayKeyValMulti($file,$force = false)
+ /**
+ * @throws Exception
+ */
+ public static function excelToArrayKeyValMulti($file, $force = false)
{
- $worksheets = self::_excelToArray($file, false, $force);
+ $worksheets = self::_excelToArray($file, false, $force);
$res = [];
foreach ($worksheets as $worksheet) {
foreach ($worksheet as $line) {
return $res;
}
+ /**
+ * @param $s
+ * @return array
+ */
protected static function _assocSheet($s)
{
$res = [];