How to center the text in PHPExcel merged cell

if you want to align only this cells, you can do something like this: $style = array( ‘alignment’ => array( ‘horizontal’ => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ) ); $sheet->getStyle(“A1:B1”)->applyFromArray($style); But, if you want to apply this style to all cells, try this: $style = array( ‘alignment’ => array( ‘horizontal’ => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, ) ); $sheet->getDefaultStyle()->applyFromArray($style);

PHPExcel and Text Wrapping

Apply to a range: $objPHPExcel->getActiveSheet()->getStyle(‘D1:E999’) ->getAlignment()->setWrapText(true); Apply to a column $objPHPExcel->getActiveSheet()->getStyle(‘D1:D’.$objPHPExcel->getActiveSheet()->getHighestRow()) ->getAlignment()->setWrapText(true);

phpexcel to download

Instead of saving it to a file, save it to php://outputĀ­Docs: $objWriter->save(‘php://output’); This will send it AS-IS to the browser. You want to add some headersĀ­Docs first, like it’s common with file downloads, so the browser knows which type that file is and how it should be named (the filename): // We’ll be outputting an … Read more

PHPExcel Make first row bold

Try this for range of cells: $from = “A1”; // or any value $to = “B5”; // or any value $objPHPExcel->getActiveSheet()->getStyle(“$from:$to”)->getFont()->setBold( true ); or single cell $cell_name = “A1”; $objPHPExcel->getActiveSheet()->getStyle( $cell_name )->getFont()->setBold( true );

Set Background cell color in PHPExcel

$sheet->getStyle(‘A1’)->applyFromArray( array( ‘fill’ => array( ‘type’ => PHPExcel_Style_Fill::FILL_SOLID, ‘color’ => array(‘rgb’ => ‘FF0000’) ) ) ); Source: http://bayu.freelancer.web.id/2010/07/16/phpexcel-advanced-read-write-excel-made-simple/

How to use phpexcel to read data and insert into database?

Using the PHPExcel library to read an Excel file and transfer the data into a database // Include PHPExcel_IOFactory include ‘PHPExcel/IOFactory.php’; $inputFileName=”./sampleData/example1.xls”; // Read your Excel workbook try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch(Exception $e) { die(‘Error loading file “‘.pathinfo($inputFileName,PATHINFO_BASENAME).'”: ‘.$e->getMessage()); } // Get worksheet dimensions $sheet = $objPHPExcel->getSheet(0); … Read more

PHPExcel auto size column width

If a column is set to AutoSize, PHPExcel attempts to calculate the column width based on the calculated value of the column (so on the result of any formulae), and any additional characters added by format masks such as thousand separators. By default, this is an estimated width: a more accurate calculation method is available, … Read more

Alternative for PHP_excel

For Writing Excel PEAR’s PHP_Excel_Writer (xls only) php_writeexcel from Bettina Attack (xls only) XLS File Generator commercial and xls only Excel Writer for PHP from Sourceforge (spreadsheetML only) Ilia Alshanetsky’s Excel extension now on github (xls and xlsx, and requires commercial libXL component) PHP’s COM extension (requires a COM enabled spreadsheet program such as MS … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)