Is it possible to hide excel sheet using phpexcel?

I am creating an excel template and I am using 4 sheets where 3 are just used to store data from an array. This data is used in the data validation list, so I added protection for the 3 sheets that I use only for storing data, but I would like to know if it can be hidden so that the user, when loading the template, will not be able to see these sheets that he does not need to know in order to exist.

Is it possible?

+7
source share
1 answer
$objPHPExcel->getSheetByName('Worksheet 1') ->setSheetState(PHPExcel_Worksheet::SHEETSTATE_HIDDEN); 

or

 $objPHPExcel->getSheetByName('Worksheet 1') ->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN); 

EDIT

You can use Excel Format / Sheet / Hide to hide the entire worksheet. This sets the visible worksheet property for xlSheetHidden. But if you do not protect the password from the structure of the workbook, anyone can select "Format / Sheet / Show" to see the hidden sheet.

If you are using Excel 97 or later, you can "hide" the sheet:

  • Press Alt-F11 to display the Visual Basic Editor
  • in the project window, double-click Microsoft Excel objects and select the sheet that you want to hide.
  • Press F4 to display the properties window.
  • Set the visible property to xlSheetVeryHidden.

Now the sheet is no longer available through Format / Sheet / Unhide

This is what PHPExcel does more simply when you set SheetState to VERYHIDDEN

+10
source

All Articles