i was trying to make the aplication that will process excell by taking the data from the excell and save them to the database quickly after user upload the excell i have try to do this by the message come that it is unable public function upload()
{
Yii::$app->session->setFlash(‘success’, ‘am glad you call.’);
if ($this->validate()) {
foreach ($this->excelFiles as $file) {
$spreadsheet = IOFactory::load($file->tempName);
$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
foreach ($sheetData as $rowData) {
$model = new AppServiceleavy();
$model->company_name = $rowData['A'];
$model->payer_id = $rowData['B'];
$model->tin_no = $rowData['C'];
$model->year = $rowData['D'];
$model->january = $rowData['E'];
$model->february = $rowData['F'];
$model->march = $rowData['G'];
$model->april = $rowData['H'];
$model->may = $rowData['I'];
$model->june = $rowData['J'];
$model->july = $rowData['K'];
$model->august = $rowData['L'];
$model->september = $rowData['M'];
$model->october = $rowData['N'];
$model->november = $rowData['O'];
$model->december = $rowData['P'];
$model->totalserviceleavy = $rowData['Q'];
$model->save(false); // Skip validation for simplicity
}
}