Posts Tagged ‘PHPExcel’

PHPExcel change column background color

Posted: July 1, 2013 in PHP


PHP generate excel columns

Posted: March 21, 2013 in PHP
$column = array('A');
$char = 'A';
while ($char != 'ZZZ')
$column[] = ++$char;


A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, AK, AL, AM, AN, AO, AP, AQ, AR, AS, AT, AU, AV, AW, AX, AY, AZ, BA, BB, BC, BD, BE, BF, BG, BH, BI, BJ, BK, BL, BM, BN, BO, BP, BQ, BR, BS, BT, BU, BV, BW, BX, BY, BZ, CA, CB, CC, CD, CE,…

PHP read excel file

Posted: August 14, 2012 in PHP
Tags: , ,

I have used PHPExcel Download latest library and use below code.

<?php error_reporting(E_ALL);

require_once '../Classes/PHPExcel/IOFactory.php';

$objPHPExcel = PHPExcel_IOFactory::load("demo.xlsx");
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$rowCount = $objWorksheet->getHighestRow();
$columnCount = $objWorksheet->getHighestColumn();

$excelTitle = $objWorksheet->rangeToArray('A1:'.$columnCount.'1',null, true, true, true);
$excelTitle = $excelTitle[1];

$excelData = array();
$count = 0;
for ($row = 2; $row<=$rowCount; $row++)
$dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$columnCount.$row,null, true, true, true);
if((isset($dataRow[$row]['A'])) && (trim($dataRow[$row]['A']) != ''))
foreach($excelTitle as $columnKey => $columnHeading)
$excelData[$count][$columnHeading] = $dataRow[$row][$columnKey];
echo '<pre>';
echo '</pre>';