arogachev / yii2-excel

ActiveRecord import and export based on PHPExcel for Yii 2 framework
Other
65 stars 25 forks source link

Attribute not exist error #11

Closed aimchina closed 9 years ago

aimchina commented 9 years ago

Error when preparing data for import: sheet "Tests", cell "A1". Attribute not exist.

arogachev commented 9 years ago

Please show your config and Excel file.

aimchina commented 9 years ago

$importer = new Importer([

        'filePath' => Yii::getAlias('@backend/web/upload/234.xlsx'),

        'standardModelsConfig' => [
            [
                'className' => ShipIng::className(),
                'standardAttributesConfig' => [
                    [
                        'name' => 'ship_id',
                        'valueReplacement' => function ($value) {
                            return $value;
                        },
                    ],

                    [
                        'name' => 'tender_id',
                        'valueReplacement' => function ($value) {
                            return $value ? Html::tag('p', $value) : '';
                        },
                    ],

                    [
                        'name' => 'company_id',
                        'valueReplacement' => function ($value) {
                            return $value;
                        },
                    ],
                ],
            ],
        ],
    ]);
aimchina commented 9 years ago

1

aimchina commented 9 years ago

please as soon as reply

arogachev commented 9 years ago

Make sure there are no redundant spaces and line breaks in attribute names in Excel file.

Current standard attributes config doesn't make sense, you need to modify it according to your model..

The component is designed for user friendly filling, it's better to write actuak company names instead of ids.

arogachev commented 9 years ago

Did my answer help?

arogachev commented 9 years ago

I'm closing this because of missing feedback. Reopen if it's necessary.

j1myx commented 7 years ago

Hi, I just had the same problem, so I proceeded to debug the library and managed to find the call to that exception; In this way I realized that in order not to fall in it the cabacera of the xlsx file must be equal to that of the attributeLabels of the model. :D