PHPSpreadsheet Library Support Excel
Yes, the "phpoffice/phpspreadsheet" library also supports creating and manipulating Microsoft Excel files, as well as other spreadsheet file formats such as CSV, OpenDocument Spreadsheet, and PDF.
To create a new Excel file using the "phpoffice/phpspreadsheet" library, you can use the following code:
Install it using composer.
composer require phpoffice/phpspreadsheet
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
// Add data to the spreadsheet
$writer = new Xlsx($spreadsheet);
$writer->save('example.xlsx');
In this example, you create a new Spreadsheet
object and add data to it, just like when creating an Apple Numbers file. However, instead of creating an AppleNumbers
writer, you create an Xlsx
writer, which is used to write Excel files.
You can then save the Excel file to a location on your server by calling the save()
method and passing a file path.
Overall, the "phpoffice/phpspreadsheet" library is a versatile PHP library that supports creating and manipulating various types of spreadsheet files, including Apple Numbers and Microsoft Excel files.