Search code examples
phpexport-to-excel

How can I write data into an excel using PHP?


Is it possible to append content to an .xls file using PHP fwrite()?

When I try this using fwrite(), the resulting file causes an error message in Excel 2007.

Is there a specific separator I can use to accomplish this?

Is it possible without a third party library?


Solution

  • You can use the PhpSpreadsheet library, to read an existing Excel file, add new rows/columns to it, then write it back as a real Excel file.

    Disclaimer: I am one of the authors of this library.