startRow function does not effect when exporting
Expected behavior:
when i return the integer value 5 I expect for the sheet to start from the fifth row
Actual behavior:
It always starts from the first row
Any additional information, configuration or data that might be necessary to reproduce the issue.
Please show us your entire export class
app/Exports/VendorListExport.php (One Sheet)
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use App\CompanyContact;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\WithStartRow;
class VendorListExport implements FromCollection, WithMapping, WithHeadings, ShouldAutoSize, WithTitle, WithStartRow
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return CompanyContact::whereHas('company.vendor', function($q) {
$q->where('form_status', 'approved');
})->with('company')->with('company.vendor')->get();
}
public function map($contact): array
{
return [
$contact->company->vendor->register_code,
'',
$contact->company->vendor->user->company_name,
$contact->company->legal_english_name,
$contact->company->legal_arabic_name,
$contact->company->established_at,
'',
'',
'',
$contact->country,
$contact->city,
'',
'',
$contact->address,
'',
$contact->telephone,
$contact->fax,
$contact->email,
$contact->website,
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
$contact->company->renewal_at,
'',
'',
'',
'',
'',
'',
'',
$contact->company->vendor->form_status,
$contact->company->vendor->user->name,
$contact->company->vendor->geo_details,
'',
'',
$contact->company->vendor->user->name,
$contact->company->vendor->company->banks()->first()->name,
'',
'',
$contact->title,
];
}
public function headings(): array
{
return [
'Vendor Code',
'Article Association Ref.',
'Name',
'Description',
'Arabic Name',
'Company Establish Year',
'Chairman Name',
'GM Name',
'Casual Vendor',
'Country',
'City',
'District',
'Area',
'Address',
'PO Box',
'Telephone',
'Fax',
'E-mail',
'Web Site',
'Department',
'Vendor Category',
'Vendor Type',
'Tax ID',
'Register No. at Chamber of Commerce',
'Register No. at EGPC',
'Account',
'Registration Date',
'Vendor No. at Finance',
'Vendor No. at Contracts',
'Comments',
'Block Date',
'Block Release Date',
'Last Renewal Date',
'Last General Evaluation %',
'Last General Evaluation Result',
'Last PO Evaluation %',
'Last PO Evaluation Date',
'Last PO Evaluation Result',
'Last General Evaluation Date',
'Overall PO Evaluation %',
'Status',
'CompanyContact Person',
'Foreign/Local',
'Record Flag',
'Arabic Address',
'CompanyContact Person_',
'Bank',
'Company Geo-Operations',
'Commercial Reg. Certificate Ref.',
'CompanyContact Person Job Title',
'Income TAX Certificate Ref.',
];
}
public function title() : String
{
return 'Approved Vendors List';
}
public function startRow() : int
{
return 3;
}
}
app/Exports/ApprovedVendorsExport.php (The Excel)
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\Exportable;
class ApprovedVendorsExport implements WithMultipleSheets
{
use Exportable;
public function sheets(): array
{
$sheets = [];
$sheets[0] = new VendorListExport;
$sheets[1] = new ContactListExport;
$sheets[2] = new CommodityListExport;
$sheets[3] = new BankListExport;
$sheets[4] = new AgentListExport;
$sheets[5] = new DocumentListExport;
$sheets[6] = new NotesListExport;
$sheets[7] = new TransactionTracingListExport;
return $sheets;
}
}
app/Http/Controllers/Admin/ExportController.php (The Controller)
<?php
namespace App\Http\Controllers\Admin;
use App\Exports\ApprovedVendorsExport;
use App\Http\Controllers\Controller;
class ExportController extends Controller
{
public function exportApprovedVendors()
{
return (new ApprovedVendorsExport)->download('export.xlsx');
}
}
WithStartRow is an import concern. You are looking for WithCustomStartCell
Sorry for that, I changed the title because it's not really a bug, Thank you
Most helpful comment
WithStartRowis an import concern. You are looking forWithCustomStartCell