Detecting hidden cells

Topics: Developer Forum
Mar 23, 2012 at 4:49 PM

Hi,

Is it possible to (and how do you) use PHPExcel to detect if a cell (or row) is hidden in an Excel file?

thanks,

-- Tim.

 

Mar 25, 2012 at 1:07 AM
Edited Mar 25, 2012 at 1:09 AM

Hey Tim,

As you know, individual cells cannot be hidden, only columns or rows.  In PHPExcel the Column and Rows themselves are called Dimensions.  

The downloadable documentation (though not the best doc in the world) gives examples for both row and column.  You should probably search there before posting here (though I could understand if you searched for "hidden" and didn't find it, the methods are get/setVisible and the heading says show/hide).  The examples below are how to set visibility.  To detect visibility just use getVisible() instead of setVisible().

4.6.29. Show/hide a columnTo set a worksheet’s column visibility, you can use the following code. The first line explicitly shows the column C, the second line hides column D.

 

$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);

4.6.32. Show/hide a rowTo set a worksheet’s row visibility, you can use the following code. The following example hides row number 10.

 

$objPHPExcel->getActiveSheet()->getRowDimension('10')->setVisible(false);
Mar 25, 2012 at 9:19 AM

Thanks!

I had indeed searched for 'hidden' in both docs and via google, and drawn a blank.

-- Tim.