Hi there,

I have a dashboard which I would like to include a button which when clicked generates an Excel spreadsheet to download. I've created a Button class:

<?php

namespace Pulse\Button;

use Carbon\Carbon;
use koolreport\dashboard\inputs\Button;
use koolreport\excel\ExcelExportable;
use Pulse\DataSource\WaylandOrderwiseDB;

class DownloadOutstandingLinesButton extends Button
{
	use ExcelExportable;

	public function onInit(): void
	{
		$this->text("Download")
			->type("primary")
			->onClick(function() {
				return WaylandOrderwiseDB::rawSQL("
				SELECT
				  vad_description,
				  oli_qty_tbsent,
				  oli_foreign_gross,
				  oli_foreign_vat,
				  oli_foreign_net,
				  os_description
				FROM 
					order_line_item
				    INNER JOIN order_header ON oli_oh_id = oh_id
				    INNER JOIN order_status ON oh_os_id = os_id
				    INNER JOIN variant_detail ON oli_vad_id = vad_id
				WHERE 
					oli_qty_tbsent > 0 
					AND oh_os_id IN(1, 4)
			")
			->run()
			->sort(['vad_description' => 'asc'])
			->exportToExcel()
			->toBrowser(sprintf("outstanding_orders_%s", Carbon::now('Europe/London')->format('Y-m-d')));
		});
	}
}

However I'm getting the following error:

Message: Call to undefined method koolreport\core\DataStore::exportToExcel()

I thought as I included the trait use ExcelExportable it would be fine?

Could someone point me in the direction of how I could do this please?