From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Formatting columns in PHPExcel

Formatting columns in PHPExcel - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Formatting columns in PHPExcel

Let's take another look at the finished spreadsheet that we are creating with php xl. The default horizontal alignment in each cell has been set to center, but columns B and G are left aligned. The text in column G has also been wrapped so that long lines don't extend beyond the column width. If I just zoom out a little you can see that better. The mileage values in column D have been formatted with a thousands separator and the prices in column F have been formatted as currency with a dollar sign, a thousands separator, and two decimal places. So we need to make a note of those columns and format them. Let's go back to our editing program and work with PHPExcel. The code needs to go at the bottom of the tribe lock after the code that we created in previous videos, so I'm just going to add in a couple of more lines and start work on line 54. To format a column, you need to apply the getStyle method to the active sheet and specify a range of cells. You specify a range in exactly the…

Contents