Closed ChristianBundgaard closed 4 years ago
Can you show your code? I don't think this package does any data transformation before inserting, perhaps PhpSpreadsheet does.
@patrickbrouwers
I suppose, it can be PhpSpreadsheet, but in that case... is it possible to do anything to avoid it?
namespace App\Exports;
use App\Product;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\Exportable;
ini_set('memory_limit', '2048M');
class ProductExport implements FromQuery, WithMapping, WithHeadings
{
use Exportable;
public function query()
{
// Query
}
public function map($product): array
{
return [
$product->id,
$product->name,
$product->shortDescriptionWithVariables(),
url($product->slug ? $product->slug->name : ''),
! empty($product->images) ? $product->images[0] : $product->thumbnail,
$product->availability && $product->buyable ? 'in stock' : 'out of stock',
$product->formatted_price,
$product->category ? $product->category->name : null,
$product->brand_name,
$product->ean,
! empty($product->ean) ? 'yes' : 'no',
'new',
$product->primaryColor ? $product->primaryColor->name : null,
$product->feed_name,
];
}
public function headings(): array
{
return [
'id',
'title',
'description',
'link',
'image_link',
'availability',
'price',
'product_type',
'brand',
'gtin',
'identifier_exists',
'condition',
'color',
'custom_label_0',
];
}
}
I was most interested in the map logic, but I assume you don't do any "weird" things there?
I'm not sure how to avoid, I don't have any experience with TSV. I'm afraid you'll have to step through the PhpSpreadsheet code and see what part adds those hidden chars. Perhaps something to do with encoding.
@patrickbrouwers, I've added the mapping now - but no, I don't think so.
Hmm okay, thanks for your answer.
If there's anything we can fix in the package for it, feel free to PR it
Bit late perhaps, but maybe using a custom heading key formatter might be a step into the right direction:
https://docs.laravel-excel.com/3.1/imports/heading-row.html#custom-formatter
I'll close this tickets as it's quite old, feel free to reopen if needed.
Prerequisites
Versions
Description
I'm using this package to export a TSV feed for Google Shopping. It has a long list of fields, ex 'custom_label_0' and 'identifierexists'. Everything works fine, except for those fields with a header that includes an ''.
Google Support says, it is because the feed includes some hidden characters, and that it can be identified with this tool: https://meyerweb.com/eric/tools/dencoder/
Correctly, if I copy "custom_label_0" from my file and encode it, I get:
And if I just write it, it becomes...
Any suggestions? I'm just using the basic functions from this package, and I can't see what can be done differently.