Created
December 19, 2014 12:24
-
-
Save wgm89/60bdb716b1d2816b88fb to your computer and use it in GitHub Desktop.
PHPExcel usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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