how to export data from excel to mysql android code example
Example: download mysql database to excel in android studio
<?php
$dbhost= "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "smkkimmanuel2";
$tablename = "questions";
$sql = "Select * from pendaftaran ";
$Connect = @mysql_connect($dbhost, $dbuser, $dbpass)
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno());
$Db = @mysql_select_db($dbname, $Connect)
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno());
error_reporting(E_ALL);
$query = "SELECT * FROM pendaftaran";
$result = mysql_query($query) or die(mysql_error());
require_once '/PHPExcel_1.8.0_doc/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getProperties()->setCreator("Wanda")
->setLastModifiedBy("Wanda")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Test result file");
$rowCount = 1;
while($row = mysql_fetch_array($result)){
$objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, $row['no_pendaftaran']);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, $row['jurusan']);
$rowCount++;
}
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="daftar siswa mendaftar.xls"');
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;