Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

488
Views
Export and save excel in a directory using maatwebsite

I am using maatwebsite (laravel) to write customer data into existing excel file and export dynamically from database and my code is working fine.

I am following below link:

maatwebsite

Now I want as excel file will download that should be save in any directory like /uploads/customers/text.xlsx

Edit: See my code:

try {
    Excel::selectSheetsByIndex(1)->load('/public/uploads/new.xlsx', function($reader) {
    $reader->sheet('sheetname',function($sheet)
    {  
      $sheet->appendRow('test','test', 'test');
    });
 }, 'UTF-8')->export('xlsx');
} catch (Exception $ex) {
    echo $ex->getMessage().$ex->getLine();
    return response(Helpers::makeDefaultErrorAjaxResponse());
}

How can I do that using the maatwebsite function, I am not getting any function for doing this?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

In Laravel Excel (Maatwebsite Excel 3) you use store method on Excel facade (Maatwebsite\Excel\Facades\Excel):

Excel::store(new YourExport(), 'customers/fileName.xlsx', 'local');

The third parameter is a filesystem defined in config/filesystems.php (it's optional). If the location where you want to store those Excel files is outside the default local and public filesystems, you can add it to the config file:

'customer_uploads' => [
    'driver' => 'local',
    'root' => '/uploads/customers/',
],

And then save your Excel files with the thrid parameter set to that new filesystem:

Excel::store(new YourExport(), 'fileName.xlsx', 'customer_uploads');

Read more here: https://docs.laravel-excel.com/3.1/exports/store.html

about 4 years ago · Santiago Trujillo Report

0

You can use ->save function to save the generated file to a folder on server. For more details look at https://laravel-excel.maatwebsite.nl/docs/2.1/export/store#docs

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!