ABD
ABD

Reputation: 889

phpexcel line break automatically

I refered this question How to set auto-line break PhpExcel?

But I am little unclear. So here's the question.

I am getting a paragraph from the $content

If i directly do the $objPHPExcel->getActiveSheet()->setCellValue('A9', $content); i am not getting line breaks,

I just want to make it like exact way did in the 05featureddemo.inc.php

It says to do $objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum); But i can't find where the size of the coloumn given, i.e.,

I ask because even if i remove the style from the below array

$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
        array(
            'font'    => array(
                'bold'      => true
            ),
            'alignment' => array(
                'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
            ),
            'borders' => array(
                'top'     => array(
                    'style' => PHPExcel_Style_Border::BORDER_THIN
                )
            ),
            'fill' => array(
                'type'       => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR,
                'rotation'   => 90,
                'startcolor' => array(
                    'argb' => 'FFA0A0A0'
                ),
                'endcolor'   => array(
                    'argb' => 'FFFFFFFF'
                )
            )
        )
);

$objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray(
        array(
            'alignment' => array(
                'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
            ),
            'borders' => array(
                'left'     => array(
                    'style' => PHPExcel_Style_Border::BORDER_THIN
                )
            )
        )
);

and make it as

$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
        array(

        )
);

$objPHPExcel->getActiveSheet()->getStyle('A3')->applyFromArray(
        array(

        )
);

It works,

So the question is how can i set the line break for particular coloumn and group of coloumn for 20px say)

Upvotes: 2

Views: 8622

Answers (1)

Mark Baker
Mark Baker

Reputation: 212412

Taken exactly from 05featureddemo.inc.php:

// Set the cell (or group of cells) to enable text wrap in those cells
$objPHPExcel->getActiveSheet()
    ->getStyle('A3:A6')
    ->getAlignment()
    ->setWrapText(true);

// Set the column to a fixed width
$objPHPExcel->getActiveSheet()
    ->getColumnDimension('A')
    ->setWidth(80);

Upvotes: 5

Related Questions