Get all models in ActiveDataProvider


Is there a way to get all the models from a ActiveDataProvider ? getModels() returns only the models in the current page even when i set setPagination() to false.

I’m trying to use spout to export my data to a Excel file but only the current page get exported.


$writer = WriterFactory::create(Type::XLSX);


$xx = $dataProvider->getModels();

foreach ($xx as $N_xx) {





Why complicate things with a dataprovider?

$xx = \app\models\MyModel::find()->all();

Or, for a (possibly) large resultset:


I already did a similar thing (execute the query in the controller and pass it to the view) but I wanted to use the same data and was just curious why it didn’t work.