0 values are blanc in Excel #242

Closed
opened 2025-11-24 09:31:43 +00:00 by wpas81 · 6 comments
wpas81 commented 2025-11-24 09:31:43 +00:00 (Migrated from github.com)

Hi

when the value of a cell is 0 it is shown as a blanc cell in the exported Excel file. How can I set this to show the 0?

ExcelExport::make()
                        ->fromTable()
                        ->withColumns([
                                Column::make('id'),
                                Column::make('payed'), //shows 1 if payed, 0 if not, blanc in Excel,
                                Column::make('payed')->formatStateusing( fn ($record) => $record->payed ? 1 : 0,, //show blanc in Excel if 0
                            ]),
Hi when the value of a cell is 0 it is shown as a blanc cell in the exported Excel file. How can I set this to show the 0? ``` ExcelExport::make() ->fromTable() ->withColumns([ Column::make('id'), Column::make('payed'), //shows 1 if payed, 0 if not, blanc in Excel, Column::make('payed')->formatStateusing( fn ($record) => $record->payed ? 1 : 0,, //show blanc in Excel if 0 ]), ```
pxlrbt commented 2025-11-24 18:30:25 +00:00 (Migrated from github.com)

Can you try converting it to a string?

Can you try converting it to a string?
wpas81 commented 2025-11-25 06:54:16 +00:00 (Migrated from github.com)

that remains the same. Event this doesn't seem to do anything (column remains blanc for value 0 or 1 for value 1)

Column::make('payed')->formatStateUsing(fn ($state) => 'test'),

In the table definition this is an IconColumn although

IconColumn::make('payed')
                        ->state(fn ($record) => $record->payed)
                        ->boolean()
                        ->sortable()
                        ->alignCenter(),
that remains the same. Event this doesn't seem to do anything (column remains blanc for value 0 or 1 for value 1) `Column::make('payed')->formatStateUsing(fn ($state) => 'test'),` In the table definition this is an IconColumn although ``` IconColumn::make('payed') ->state(fn ($record) => $record->payed) ->boolean() ->sortable() ->alignCenter(), ```
pxlrbt commented 2025-11-25 13:58:58 +00:00 (Migrated from github.com)

->formatStateUsing() is only applied after. You'd need to use ->getStateUsing()

`->formatStateUsing()` is only applied after. You'd need to use `->getStateUsing()`
wpas81 commented 2025-11-25 15:00:50 +00:00 (Migrated from github.com)

that's the tric! Many thanks! You may want to update the documentation :)

that's the tric! Many thanks! You may want to update the documentation :)
pxlrbt commented 2025-11-25 15:23:35 +00:00 (Migrated from github.com)

I should fix the issue that 0 is treated as an empty value 😅
Not sure which part of the docs I should update? That specific edge-case is not mentioned. Otherwise ->formatStateUsing() should work.

I should fix the issue that 0 is treated as an empty value 😅 Not sure which part of the docs I should update? That specific edge-case is not mentioned. Otherwise `->formatStateUsing()` should work.
wpas81 commented 2025-11-26 06:40:46 +00:00 (Migrated from github.com)

that's an option too :) Anyway many thanks for making this package! Made exporting tables a whole lote easier :)

that's an option too :) Anyway many thanks for making this package! Made exporting tables a whole lote easier :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pxlrbt/filament-excel#242
No description provided.