Customize cells #256
Replies: 6 comments
-
|
You probably need to extend the Exportable and add the methods from |
Beta Was this translation helpful? Give feedback.
-
how to do it? |
Beta Was this translation helpful? Give feedback.
-
|
Maybe you figured it out already but I was looking for the same thing. For future reference, here is how I solved it. First, create a custom export as explained here: https://github.com/pxlrbt/filament-excel?tab=readme-ov-file#custom-exports use pxlrbt\FilamentExcel\Actions\Tables\ExportAction;
use pxlrbt\FilamentExcel\Exports\ExcelExport;
use pxlrbt\FilamentExcel\Columns\Column;
class CustomExport extends ExcelExport
{
public function setUp()
{
$this->withFilename('custom_export');
$this->withColumns([
Column::make('name'),
Column::make('email'),
]);
}
}Then make sure the class implements the WithStyles interface: use Maatwebsite\Excel\Concerns\WithStyles;
class CustomExport extends ExcelExport implements WithStyles
{
....At last, implement the public function styles: class CustomExport extends ExcelExport implements WithStyles
{
...
public function styles(Worksheet $sheet)
{
return [
1 => ['font' => ['bold' => true]],
'D' => ['alignment' => ['horizontal' => 'right']],
];
}In this example, the header row will be bold and the 4th column will be right aligned. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
|
@Priet Thanks for sharing. |
Beta Was this translation helpful? Give feedback.
-
|
@Priet is the styles also needed for excel formats? ie- dates become actual date formatted in the exported excel, numbers becomes numbers etc- not just general or strings |
Beta Was this translation helpful? Give feedback.
-
|
@synsyst Late answer, but you can use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any way to customize, for example: Alignment, type of data entered (text, number, general), cell coloring, etc.?
Beta Was this translation helpful? Give feedback.
All reactions