Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi Andre, the latest version of Dashboard does support excel and csv export already. Here're the online example and source code for these features:
https://github.com/koolreport/dashboard-demo/tree/main/src/excelcsv
Sorry for not updating the documentation for Dashboard's excel and csv export yet. We will upload it soon. Tks,
I tried this.
Can you please guide me on where I'm going wrong?
My Report:
<?php
namespace namespace;
use path\AutoMaker;
use Illuminate\Support\Facades\DB;
use koolreport\dashboard\widgets\KWidget;
class ReportOne extends KWidget
{
protected function dataSource()
{
$query = AutoMaker::procedure()->call(
"db.GetData",[
]
);
return $query;
}
protected function onCreated()
{
$this
->use(\koolreport\datagrid\DataTables::class)
->settings([
"paging"=>array(
"pageSize"=>10,
),
"options"=>array(
"searching"=>true,
"colReorder"=>true,
"fixedHeader"=>false,
"select"=>true,
"paging"=>true,
"autoWidth" => false,
"responsive" => true,
"CSVExportable" => (true),
"ExcelExportable" => (true),
),
"columns" => [
"Date",
"Name",
"Something",
"SomethingElse",
],
]);
}
}
My Board:
<?php
namespace namespace;
use koolreport\dashboard\containers\Html;
use koolreport\dashboard\containers\Panel;
use koolreport\dashboard\containers\Row;
use \koolreport\dashboard\Dashboard;
use koolreport\dashboard\inputs\Dropdown;
use \koolreport\dashboard\widgets\Text;
use \koolreport\dashboard\inputs\Button;
use \koolreport\dashboard\Client;
use \koolreport\export\Exportable;
use \koolreport\excel\ExcelExportable;
class ReportOneBoard extends Dashboard
{
protected function widgets()
{
return [
Text::create()->text("
<br>
<h3>ReportOne</h3>
")->asHtml(true),
Row::create([
Panel::create()->header("<b>Inbound Details with Recording</b>")->sub([
Html::div([
Dropdown::create("exporting")
->title("Export")
->align("right")
->items([
Dropdown::menuItem()
->text("Export to Excel")
->icon("far fa-file-excel")
->onClick(
Client::widget("ReportOne")
->exportToXLSX("ReportOne")
),
Dropdown::menuItem()
->text("Export to CSV")
->icon("fa fa-file-csv")
->onClick(
Client::widget("ReportOne")
->exportToCSV("ReportOne")
),
]),
])->class("text-right"),
Text::create()->text("<br>")->asHtml(true),
ReportOne::create()
->xlsxExportable(true)
->csvExportable(true)
])->width(2/2),
]),
];
}
}
If you use KWidget pls add the following fields() and dataView() methods to it:
<?php
namespace namespace;
use path\AutoMaker;
use Illuminate\Support\Facades\DB;
use koolreport\dashboard\widgets\KWidget;
use \koolreport\dashboard\fields\Text; // add this field depending on your column type
use \koolreport\dashboard\fields\Number; // add this field depending on your column type
class ReportOne extends KWidget
{
...
protected function fields()
{
return [
Text::create("Name"),
Number::create("Something"),
];
}
public function dataView()
{
$dataView = parent::dataView();
$fields = $this->fields();
return $dataView
->fields($fields); // exportable expects dataview's fields property
}
}
Is there something else I need to do for this to work?
I do not get any errors and can see from the developer tools that the event is initiated, but the onClick does not start the download.
Do you have to follow the setup process like with PDF and if so, is the below correct?
protected function export()
{
return ExportHandler::create()
->storage(
dirname(__DIR__)."/storage")
->csvEngine(
LocalExport::create()
)
->xlsxEngine(
LocalExport::create()
);
}
You should use another engine for xls and csv, the LocalExport is for PDF and image, you should do this:
->csvEngine(
\koolreport\dashboard\export\CSVEngine::create()
)
->xlsxEngine(
\koolreport\dashboard\export\XLSXEngine::create()
)
Let us know if you need further assistance.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo