<?php
	include('admincp/modules/connect.php');
	include('Classes/PHPExcel.php');

	if(isset($_POST['btnGui'])){
		$file = $_FILES['file']['tmp_name'];
		$objReader = PHPExcel_IOFactory::createReaderForFile($file);
		$objReader ->setloadSheetsOnly('2011');

		$objExcel = $objReader ->load($file);
		$sheetData = $objExcel ->getActiveSheet()->toArray('null', true, true, true);

		$highestRow = $objExcel->setActiveSheetIndex()->getHighestRow();
		for($row = 2; $row<=$highestRow; $row++){
			$hopso = $sheetData[$row]['B'];
			$mahoso = $sheetData[$row]['C'];
			$chusudung = $sheetData[$row]['D'];
			$namcap = $sheetData[$row]['E'];
			$loaihoso = $sheetData[$row]['F'];
			$sothua = $sheetData[$row]['G'];
			$tobando = $sheetData[$row]['H'];
			$maloaidat = $sheetData[$row]['I'];
			$loaithua = $sheetData[$row]['J'];
			$mucluc = $sheetData[$row]['K'];
		$sql = "INSERT INTO hoso(hopso, mahoso, chusudung, namcap, loaihoso, sothua, tobando, maloaidat, loaithua, mucluc) VALUES ('$hopso', '$mahoso', '$chusudung', '$namcap', '$loaihoso', '$sothua', '$tobando', '$maloaidat', '$loaithua', '$mucluc')";

			$mysql = mysql_query($sql);
		}
		echo 'Insert thành công';
	}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
	<form method="POST" enctype="multipart/form-data">
		<input type="file" name="file">
		<button type="submit" name="btnGui">Import</button>
	</form>

</body>
</html>