Answer the question
In order to leave comments, you need to log in
Why are borders not being set in PhpExcel?
I'm using PhpExcel and not PhpSpreadsheet because I couldn't install images in the latter.
I need to set cell borders. Tried different options. Here the red text color is set, but the border is not:
$objReader = new PHPExcel_Reader_Excel2007();
$objPHPExcel = $objReader->load('..\..\control-files\templates\storeconfirm.xlsx');
$objPHPExcel->setActiveSheetIndex(0);
$sheet = $objPHPExcel->getActiveSheet();
$styleArray = array(
'font' => array(
'bold' => true,
'color' => array('rgb' => 'FF0000'),
),
'borders' => array(
'bottom' => array(
'borderStyle' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb' => '000000')
),
'top' => array(
'borderStyle' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb' => '000000')
)
)
);
$sheet->getStyle('A'.$coord)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK);
Answer the question
In order to leave comments, you need to log in
If anyone is interested, another option worked:
$borderStyle = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
)
);
$sheet->getStyle('A'.$coord.':J'.$coord)->applyFromArray($borderStyle);
$sheet->mergeCells('D'.$coord.':J'.$coord);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question