setActiveSheet

setActiveSheet

BASIC / ADVANCED / PREMIUM

Sets the active sheet.

Description
public setActiveSheet($options)

This method sets the internal active sheet.

This internal active sheet is used to add new contents in the chosen sheet. It doesn't change the active sheet value in the worksheet.

Parameters

options

Key Type Description
name string Sheet name.
position int Sheet position. 0 is the first sheet. -1 choose the last sheet.

An existing name or position must be chosen.

Exceptions

The name or the position don't exist.

Code samples

Example #1

The resulting XLSX looks like:

Example #2

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.0:
    • -1 as position to choose the last sheet.
  • phpxlsx 1.0:
    • new method.