Style from array and XLSX problem

Topics: Developer Forum, User Forum
Mar 11, 2008 at 9:37 AM
Hi,

i'm a newby and have some questions regarding to styling and create Excel 2007 Files.
I want to set wraptext and NUMBER-FORMATING by using an array but i didn't get it working.
Here is my Code:

$wertnormalcenterpercentage = array('font' => array('size' => 8),'alignment' => array('horizontal' => PHPExcelStyleAlignment::HORIZONTALCENTER, 'wraptext' => true),'borders' => array('right' => array('style' => PHPExcelStyleBorder::BORDERTHIN)), 'numberformat' => array('formatcode' => PHPExcelStyleNumberFormat::FORMAT_PERCENTAGE));

Next i used an Excel 2007 File as template. But when i'm inserting more then six rows to the first worksheet the Excel file will be damaged.
I want get any error during creation but Excel can't open it.

I'm using Excel 2003 with 2007 compatibility pack PHP 5.2.5 and set memory_limit to 512MB.

Kinde regards,

Freibeuter
Coordinator
Mar 11, 2008 at 10:23 AM
Try something like:
$objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray(
	array(
		'numberformat'    => array(
			'code'      => PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE
		),
		'alignment' => array(
			'wrap'       => true
		)
	)
);
Mar 11, 2008 at 11:33 AM
Thx for your quick help.
This was the solution.

The other problem could be solved by myself.

Kind regards,

Freibeuter