Sameer Borate has a new post to his site sharing a method for converting a CSV to an Excel document using PHP. While you can open a CSV file with Excel correctly, using this method (and library) allows for more control over the end result.
During a recent data conversion project I needed to convert around 250 CSV files to Excel (xls) format. As this was a PHP project I decided to write a small PHP script using the PhpSpreadsheet library.
He then walks through the installation (via Composer) and use of the library to take in a simple CSV of countries and write it out as a
.xls file in a single worksheet. He also includes a modification of the script that can be run from the command line, taking in arguments for the source file and the destination.