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.

Setting the spreadsheet's print options

Setting the spreadsheet's print options - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Setting the spreadsheet's print options

The code we've created so far, handles the metadata and defaults for the Excel spreadsheet. Before moving on, I just want to tidy up this code here. Tidy code is always much easier to read. We're now going to turn our attention to how the spreadsheet will look when it's printed. Php Excel is capable of creating Excel workbooks that contain multiple spreadsheets, so we need to begin by specifying which spreadsheet we're working on. So let's add a new line at the end of the tri-block. And we need our sheet object, and we need to set the active sheet index, that's exactly what the method is called. Sheets are regarded as being an array, PHP arrays always begin at zero so the first page will be zero. And most of the remaining code needs to be a reference to the active sheet. So rather than getting the active sheet every time, we can store it in a variable. So, we'll create a variable called active sheet. And then use our sheet object, to get the active sheet. To set the orientation of the…

Contents