-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not export columns with empty value #35
Comments
Yep - I've just run into this exact same issue.
If |
So following on from what @jfeid said - if you make this change, it seems to be fix the issue: foreach (array_diff($only, array_keys($row)) as $attribute) {
if ($model->{$attribute}) {
$row[$attribute] = $model->{$attribute};
}
+ else {
+ $row[$attribute] = '';
+ }
}
I'm just not sure of any side effects of that? It seems to solve it for me...? |
Can you PR that. |
Merged
@patrickbrouwers - done. |
Fixed in latest release. Thanks @laurencei for the PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, thanks for this great package.
When I am asking to export all attributes from a resource like follows:
it fails to export attributes with empty value. This consequently mangles the export data with mismatched column/data.
For example, if the a resource in database has the following rows:
and I am using the following Nova resource fields (you see
Year
is not an index field):will eventually export:
First row has 5 columns but 2nd row has 4 columns.
Debugging the code, I see that this line:
https://github.com/Maatwebsite/Laravel-Nova-Excel/blob/4ecc6c0f815da56e2874d15e79735734930fea0a/src/Actions/ExportToExcel.php#L306
prevents to export attribute if it is empty.
Similar problem is referenced in #18 and #19.
The text was updated successfully, but these errors were encountered: