Untitled

 avatar
user_1913875940
php
2 years ago
883 B
7
Indexable
<?php


	$inputFileName = Yii::getAlias('@webroot/public/file_excel/format_pengiriman.xls');
		$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xls');
		$spreadsheet = $reader->load($inputFileName);
		$Excel_writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
		$spreadsheet->setActiveSheetIndex(0);
		$activeSheet = $spreadsheet->getActiveSheet();
		$filename = 'data_pengiriman';
		$startNum = 5;
		$num = $startNum;
		$no = 1;

		$formatter = Yii::$app->formatter;
		foreach ($subdata as $subkey => $subitem) {
	$activeSheet->SetCellValue('A' . $num, $no);
			$activeSheet->SetCellValue('B' . $num, $subitem['nomor_po']);

        }

	header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
		header('Cache-Control: max-age=0');
		$Excel_writer->save('php://output');