Skip to content

Instantly share code, notes, and snippets.

@wgm89
Created December 19, 2014 12:24
Show Gist options
  • Select an option

  • Save wgm89/60bdb716b1d2816b88fb to your computer and use it in GitHub Desktop.

Select an option

Save wgm89/60bdb716b1d2816b88fb to your computer and use it in GitHub Desktop.
PHPExcel usage
<?php
$packages = array();
$contents = file_get_contents('package.txt');
$packages = explode('|', $contents);
foreach ($packages as $key=>$package) {
if (empty($package)) continue;
$packages[$key] = trim($package);
}
require_once 'PHPExcel/PHPExcel/IOFactory.php';
require_once 'PHPExcel/PHPExcel.php';
$objPHPExcel = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objPHPExcel->load('GAME.xlsx');
$sheet_count = $objPHPExcel->getSheetCount();
$excel_data = array();
for ($s = 0; $s < $sheet_count; $s++) {
$objPHPExcel->setActiveSheetIndex($s);
$currentSheet = $objPHPExcel->getSheet($s);
$row_num = $currentSheet->getHighestRow();
$col_max = $currentSheet->getHighestColumn();
for($i = 2; $i <= $row_num; $i++) {
$packageId = trim($currentSheet->getCell('A'.$i)->getFormattedValue());
echo $packageId;
if (in_array($packageId, $packages)) {
echo 'row:',$s,'|',$i;
$objPHPExcel->getActiveSheet()->setCellValue('F'.$i, '1');
}
}
}
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('GAME_UPDATE.xlsx');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment