node-admin/data-transform-for-excel

description

v1.0.1 2023-08-29 08:27 UTC

This package is auto-updated.

Last update: 2024-12-01 00:14:03 UTC


README

说明

此库为 node-admin 扩展库

用法

安装

composer require node-admin/data-transform-for-excel

表格Action导出

/** @var \NodeAdmin\Lib\NodeContent\Table $table */
$table->actions(function (Table\ActionsContainer $container){
    $export = new DataExport();
    $export->setDataUrl(route('admin.test.export'));
    $container->addAction($export);
});

// export action 
public function export(){
    return Test::query()->paginate();
}

更新日志

1.1.0

增加配置导出模式

use NodeAdmin\DataTransformForExcel\NodeContent\Table\Actions\DataExport;

$table->actions(function (Table\ActionsContainer $container){
    $export = new DataExport();
    $export->setConfigUrl(route('admin.test.export.config'));
    $container->addAction($export);
});

// export config
public function exportConfig()
    {
        return new DataExportConfigResponse(
            route('admin.test.export'), // 导出数据url
            // 字段列表 key为字段名,header为表头
            [ 
                ['key' => 'title', 'header' => '标题'],
            ]
        );
    }

// export action 
public function export(){
    return Test::query()->paginate();
}