I have this code in my action page, which centers text in a range in the J column of my active worksheet:
$objPHPExcel->setActiveSheetIndex(0);
$lastrow = $objPHPExcel->getActiveSheet()->getHighestRow();
$objPHPExcel->getActiveSheet()
->getStyle('J1:J'.$lastrow)
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
This works fine, except that when I trigger the opening of MS Excel, and it opens the worksheet, the entire J column is highlighted. What I want is for the client to open the spreadsheet, but not have any columns or cells highlighted or selected.
I do not know how to unselect all cells, but you can select the cell A1, which is the top left cell. That will give the appearance of "no cell selected" and will open the sheet scrolled to the top and left. The function call is simple:
setSelectedCells('A1')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With