Home » Php » php – Create a table in spreadsheet with PHPExcel

php – Create a table in spreadsheet with PHPExcel

Posted by: admin July 12, 2020 Leave a comment


In searching for an answer, I found lots of questions regarding turning a table into a spreadsheet, or outputting a spreadsheet into a table, but nothing about creating an Excel table within a spreadsheet with PHPExcel.

I’d like to create a table within Excel – that is, I’d like to isolate a section of cells/data from the rest of the spreadsheet, so that the data can be sorted and filtered independently from the rest of the sheet. This is the same as doing Insert -> Table in Excel.

This seems like a pretty common thing to do, but I can’t find any way of doing it in the PHPExcel documentation.

How do I create a table within a spreadsheet using PHPExcel?

How to&Answers:

Insert/Table is simply a GUI “shortcut” method for styling and setting autofilters against a block of cells. Both of these can be done as individual tasks using PHPExcel, but the library does not provide a “shortcut” way of doing this with a single method call.

Take a look at section 4.6.25 of the Developer documentation, and the 10autofilter.php example in the /Tests directory of the distribution