PHPExcel Reader Example #15

Simple File Reader for Tab-Separated Value File using the Advanced Value Binder

'; $objReader->setDelimiter("\t"); $spreadsheet = $objReader->load($inputFileName); $spreadsheet->getActiveSheet()->setTitle(pathinfo($inputFileName, PATHINFO_BASENAME)); echo '
'; echo $spreadsheet->getSheetCount(),' worksheet',(($spreadsheet->getSheetCount() == 1) ? '' : 's'),' loaded

'; $loadedSheetNames = $spreadsheet->getSheetNames(); foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { echo 'Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Formatted)
'; $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); var_dump($sheetData); echo '
'; } echo '
'; foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { echo 'Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Unformatted)
'; $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, false, true); var_dump($sheetData); echo '
'; } echo '
'; foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { echo 'Worksheet #',$sheetIndex,' -> ',$loadedSheetName,' (Raw)
'; $spreadsheet->setActiveSheetIndexByName($loadedSheetName); $sheetData = $spreadsheet->getActiveSheet()->toArray(null, false, false, true); var_dump($sheetData); echo '
'; } ?>