How to install a excel lib to generate formatted excel file
Step 1) Go to the magento 2 root folder then execute following command
Copysudo -uwww-data composer require phpoffice/phpspreadsheet
sudo -uwww-data composer require phpoffice/phpspreadsheet