Problem creating a diagonal line in a cell

Topics: Developer Forum, User Forum
Jan 31, 2012 at 4:18 PM

I was trying to create a diagonal line in a cell but nothing appears in the exported excel spreadsheet.

I have no problem with setting up other borders like allborders, top, right, except diagonal.

Here is the code i wrote:

// Set Diagonal Line

// alternative method
$styleArray = array(
        'borders' => array(
             'diagonal' => array(
                 'style' => PHPExcel_Style_Borders::DIAGONAL_BOTH,
                 'color' => array('argb' => 'FF000000'),

Could someone help ? Thanks

Feb 1, 2012 at 9:11 PM

Which writer are you using?

Feb 2, 2012 at 8:06 AM
// Output the generated excel file so that the user can save or open the file
header("Content-Type: application/");
header("Content-Disposition: attachment; filename\"MPSFormAReport.xls");
header("Cache-Control: max-age=0");

$objWriter = PHPExcel_IOFactory::createWriter($phpExcel,"Excel5");
Sep 27, 2012 at 3:51 AM

hello leatheric:

I have the same question with you that i want to create a diagonal border from left top to right bottom, and you can try this before create a border:

$sheet-> getActiveSheet() -> getStyle(''AC19') -> getBorders() -> setDiagonalDirection( PHPExcel_Style_Borders::DIAGONAL_BOTH );

because the default diagonal border style is DIAGONAL_NONE means no border if you not set, so you must do this before use.