Skip to content

Novis\Spreadsheet\Reader::Visibility

Whether a sheet of a workbook shows its tab in Excel.

  • Visible is a normal sheet.
  • Hidden is a sheet without a tab. A person can show it again in Excel.
  • VeryHidden is a sheet that only a program can show again.

When you write a workbook, the sheet option hidden sets it. hidden: true is Hidden, and hidden: 'very' is VeryHidden. When you read a file, Reader::sheets gives the visibility of each sheet.

Good to know: a hidden sheet is not secret. Any program that reads the file can read its cells.

Examples

Hidden and very hidden

<?nvs
// Shows the `Reader::Visibility` of a sheet written with each value of the option `hidden`.
use Novis\Spreadsheet\Reader;
use Novis\Spreadsheet\Workbook;
class Visibilities
{
public static function name(Reader::Visibility $visibility): string
{
return match ($visibility) {
Reader::Visibility::Visible => 'Visible',
Reader::Visibility::Hidden => 'Hidden',
Reader::Visibility::VeryHidden => 'VeryHidden',
};
}
}
var $book = Workbook::createInMemory();
$book->addSheet('Prices')->addRow(['Tea', 2.5]);
$book->addSheet('Rates', { hidden: true })->addRow(['EUR', 1.0]);
$book->addSheet('Codes', { hidden: 'very' })->addRow(['A1', 'Shop']);
var $reader = Reader::open($book->finish()->bytes ?? Core\Bytes::fill(0, 0));
// This prints "Prices: Visible", "Rates: Hidden" and "Codes: VeryHidden".
foreach ($reader->sheets() as var $info) {
echo $info->name, ': ', Visibilities::name($info->visibility), "\n";
}
Output
Prices: Visible
Rates: Hidden
Codes: VeryHidden