Comments (11)
, the broken file has an empty line at the start of the file
That's a known issue of PhpSpreadsheet. You most likely have an empty line or whitespace in front of a <?php
opening tag. It could be in any file in your project.
For the allFields() I've released a patch release, that makes it work again.
from laravel-nova-excel.
@DanielDarrenJones great! Happy you found it so quickly :)
Yes explicit would for sure be better :)
from laravel-nova-excel.
Can you show your code please. It seems your export hasn't "selected" any fields to be exported.
from laravel-nova-excel.
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [
(new DownloadExcel)
->withHeadings()
->allFields(),
];
}
EDIT: I have also tried without the withHeadings and AllFields chains and it still isn't working, it also isnt working across different resources
from laravel-nova-excel.
what's in your fields()
array ? ->allFields()
is supposed to build up a list of fields from there.
Also ->allFields()
is the default behaviour, so you can also remove that call :)
from laravel-nova-excel.
on the original resource I had it on:
/**
* Get the fields displayed by the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Name', 'name')->sortable(),
new Panel('Shopify', $this->shopifyFields()),
new Panel('Amazon', $this->amazonFields()),
new Panel('Wayfair', $this->wayfairFields()),
BelongsToMany::make('Orders'),
];
}
/**
* Get the shopify fields for the resource.
*
* @return array
*/
protected function shopifyFields()
{
return [
Text::make('Shopify SKU', 'shopify_sku')
->sortable()
->hideFromIndex(),
Text::make('Shopify Product ID', 'shopify_product_id')
->sortable()
->hideFromIndex(),
Text::make('Shopify Variant ID', 'shopify_variant_id')
->sortable()
->hideFromIndex(),
ExternalUrl::make('Edit on Shopify', function () {
if ($this->shopify_product_id == null || $this->shopify_product_id == "") {
return null;
}
$link = "https://new-forest-rustic-furniture-ltd.myshopify.com/admin/products/{$this->shopify_product_id}";
if ($this->shopify_variant_id != null && $this->shopify_variant_id != "") {
$link = $link . "/variants/{$this->shopify_variant_id}";
}
return $link;
})
->hideFromIndex(),
];
}
/**
* Get the amazon fields for the resource.
*
* @return array
*/
protected function amazonFields()
{
return [
Text::make('Amazon ASIN', 'amazon_asin')
->sortable()
->hideFromIndex(),
Text::make('Amazon SKU', 'amazon_sku')
->sortable()
->hideFromIndex(),
Text::make('Amazon Marketplace ID', 'amazon_marketplace_id')
->sortable()
->hideFromIndex(),
ExternalUrl::make('Edit on Amazon', function () {
if ($this->amazon_asin == null || $this->amazon_asin == "") {
return null;
}
if ($this->amazon_sku == null || $this->amazon_sku == "") {
return null;
}
$link = "https://catalog-sc.amazon.co.uk/abis/product/DisplayEditProduct?sku={$this->amazon_sku}&asin={$this->amazon_asin}";
if ($this->amazon_marketplace_id != null && $this->amazon_marketplace_id != "") {
$link = $link . "&marketplaceID=A1F83G8C2ARO7P{$this->amazon_marketplace_id}";
}
return $link;
})
->hideFromIndex(),
];
}
/**
* Get the wayfair fields for the resource.
*
* @return array
*/
protected function wayfairFields()
{
return [
Text::make('Wayfair SKU', 'wayfair_sku')
->sortable()
->hideFromIndex(),
ExternalUrl::make('Edit on Wayfair', function () {
if ($this->wayfair_sku == null || $this->wayfair_sku == "") {
return null;
}
return "https://partners.wayfair.com/v/product_catalog/manage_product_description/index?skus={$this->wayfair_sku}";
})
->hideFromIndex(),
];
}
but I have simpler models like users which it isn't working on either:
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make(),
Text::make('Name')
->sortable()
->rules('required', 'max:255'),
Text::make('Email')
->sortable()
->rules('required', 'email', 'max:254')
->creationRules('unique:users,email')
->updateRules('unique:users,email,{{resourceId}}'),
Password::make('Password')
->onlyOnForms()
->creationRules('required', 'string', 'min:6')
->updateRules('nullable', 'string', 'min:6'),
];
}
from laravel-nova-excel.
I just changed the users field to use:
public function actions(Request $request)
{
return [
(new DownloadExcel)
->withHeadings()
->only('name', 'email'),
];
}
but its now giving the following error when opening:
from laravel-nova-excel.
Your first problem is due to ->allFields()
. allFields
in the past referred to exporting all database columns. Removing that, should export all fields visible on the index screen.
For your new problem, how is your file name? It seems something wrong with the extension.
from laravel-nova-excel.
The exports look fine in their names?
is there a simple all for all DB columns or do I need to specify this on all resources now manually?
from laravel-nova-excel.
Weirdly, I can view to contents of the broken exports in text-edit, but the non broken ones are locked and wont show their contents?
Edit: I managed to view in atom instead, the broken file has an empty line at the start of the file, removing it makes excel realise it's a file but still apears broken
from laravel-nova-excel.
@patrickbrouwers aha! yeah there was a whitespace in one of my configs, thanks for the tip there!
Also thanks for adding that back, I should probably define the fields explicitly anyway, but it's a nice helper for testing!
from laravel-nova-excel.
Related Issues (20)
- Enqueue export on demande HOT 1
- Method Laravel\Nova\Fields\FieldCollection::filterForIndex does not exist. HOT 1
- QueuedExport doesn't allow softDeleted data HOT 10
- FileNotFound after upgrade HOT 3
- [BUG] ExportResourceActionRequest::forAllMatchingResources in Nova 4.0 HOT 4
- QUESTION: how to include columns and extra rows from related resources HOT 10
- [BUG] Error in Nova 4.0 using default User Resource - Too few arguments HOT 8
- [QUESTION] How to export a nova resource to excel WITHOUT actions?
- [BUG] Error in Nova 4 when trying to use actions in lenses HOT 1
- [PROPOSAL] Implement strict null comparison
- "Select all"-download doesn't work HOT 9
- [BUG] MemoryCache class methods incompatible with Psr\SimpleCache\CacheInterface HOT 2
- Excel is failed to download in laravel nova HOT 2
- Cannot download excel sheet in forge server HOT 2
- [BUG] Crash with Nova 4.24.0; parameter type declaration mismatch in withName HOT 3
- Belogs to
- Select All via Relationship table Exports Entire Resource
- How to access the Resource/Model in the Query? HOT 1
- [BUG] No longer works with the latest version of Laravel Nova (4.32.9) HOT 3
- How to get Select field displayUsingLabels instead of value!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-nova-excel.