Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a table in spreadsheet with PHPExcel

Tags:

php

phpexcel

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?

like image 270
Luke Shaheen Avatar asked May 09 '12 15:05

Luke Shaheen


1 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

like image 120
Mark Baker Avatar answered Sep 18 '22 12:09

Mark Baker