如何使用Laravel在maatwebsite上获取导入xlsx的公式结果?我得到公式而不是公式的值

时间:2019-05-03 12:49:39

标签: php laravel maatwebsite-excel

请指教! 在导入xlsx文件的过程中,我得到公式而不是公式的结果。

已将配置文件excel.php更改为在导入时将'calculate'=>设置为true,但仍然不起作用。

MyModel

namespace App\Imports;

use App\ImpData;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithCalculatedFormulas;

class ImpDataImport implements ToModel
{
    public function model(array $row)
    {
        return new ImpData([
            'f1' => $row[1],
            'f2' => $row[2],
            'f3' => $row[3],
            'f4' => $row[4],
            'f5' => $row[5],
            'f6' => $row[6],
            'f7' => $row[7],
            'f8' => $row[8],
            'f9' => $row[9],
            'f10' => $row[10],
            'f11' => $row[11],
            'f12' => $row[12],
            'f13' => $row[13],
            'f14' => $row[14],
            'f15' => $row[15],
            'f16' => $row[16],
            'f17' => $row[17],
            'f18' => $row[18]
        ]);
    }
}

在我的控制器中

$data = Excel::toArray(new ImpDataImport(), $file);

源文件:

A1 = '1'
A2 = '2'
A3 = '=A1+B1'

导入后,我得到:

array:1 [▼
  0 => array:1 [▼
    0 => array:3 [▼
      0 => 1.0
      1 => 2.0
      2 => "=A1+B1"
    ]
  ]
]

0 个答案:

没有答案