Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PhpOffice\PhpSpreadsheet\Spreadsheet;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- /*
- Bagian ini silahkan anggap tidak ada..
- karena dasarnya ini include composer (autoload.php)
- */
- {
- $paths = [
- __DIR__ . '/../vendor/autoload.php', // In case PhpSpreadsheet is cloned directly
- __DIR__ . '/../../../autoload.php', // In case PhpSpreadsheet is a composer dependency.
- __DIR__ . '/../../../web/example/vendor/autoload.php' //memakai ini
- ];
- foreach ($paths as $path) {
- if (file_exists($path)) {
- require_once $path;
- //echo "run:$path";
- ;
- }
- }
- }
- $callStartTime = microtime(true);
- $inputFileName = __DIR__ . '/../contoh002.xlsx';
- $spreadsheet = IOFactory::load($inputFileName);
- $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);
- echo '<pre>';
- print_r($sheetData);
- echo '</pre>';
- /**
- ##INFO##
- {"title":"excel Dasar ","detail":"Membaca excel menggunakan PHP Spreadsheet . Menampilkan isinya. <br>dari contoh ini, kita bisa explore lebih lanjut"}
- ##INFO##
- **/
- /*
- Pada Bagian ini disarankan simpan ke folder dahulu
- sebelum mengeluarkan..
- atau di download
- $file='contoh007.xlsx';
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="'.$file.'"');
- header('Content-Length: ' . filesize($file));
- header('Content-Transfer-Encoding: binary');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- ob_clean();
- flush();
- $writer = IOFactory::createWriter($objPHPExcel, 'Xlsx');
- $writer->save($file);
- $str=file_get_contents($file);
- die($str);
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement