Search
 
SCRIPT & CODE EXAMPLE
 

SQL

download mysql database to excel in android studio

<?php

$dbhost= "localhost"; //your MySQL Server 
$dbuser = "root"; //your MySQL User Name 
$dbpass = ""; //your MySQL Password 
$dbname = "smkkimmanuel2"; 

//your MySQL Database Name of which database to use this 
$tablename = "questions"; //your MySQL Table Name which one you have to create excel file 

// your mysql query here , we can edit this for your requirement 
$sql = "Select * from pendaftaran "; 
//create  code for connecting to mysql 
$Connect = @mysql_connect($dbhost, $dbuser, $dbpass) 
or die("Couldn't connect to MySQL:<br>" . mysql_error() . "<br>" . mysql_errno()); 
//select database 
$Db = @mysql_select_db($dbname, $Connect) 
or die("Couldn't select database:<br>" . mysql_error(). "<br>" . mysql_errno()); 

error_reporting(E_ALL);

// Create your database query
$query = "SELECT * FROM pendaftaran";  
// Execute the database query
$result = mysql_query($query) or die(mysql_error());

// Instantiate a new PHPExcel object
 require_once '/PHPExcel_1.8.0_doc/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel(); 
// Set the active Excel worksheet to sheet 0
$objPHPExcel->setActiveSheetIndex(0); 
// Set document properties
$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");


// Initialise the Excel row number
$rowCount = 1; 
// Iterate through each result from the SQL query in turn
// We fetch each database result row into $row in turn
while($row = mysql_fetch_array($result)){ 
    $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, $row['no_pendaftaran']); 
    $objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, $row['jurusan']); 
    // Increment the Excel row counter
    $rowCount++; 
} 

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="daftar siswa mendaftar.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');


$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
Comment

PREVIOUS NEXT
Code Example
Sql :: create-table-with-index-organization 
Sql :: sql how to get courses that i have made prerequisites 
Sql :: mysql workbench cannot find password 
Sql :: sqlite3 not commit 
Sql :: creating a joined view in mysql 
Sql :: sql to migration codeigniter online 
Sql :: how to select only id where is not in column mysql 
Sql :: oracle date summer time 
Sql :: min varias colunas spark sql 
Sql :: how much space does sql server take per row 
Sql :: php mysql set db collation 
Sql :: sql file md5 
Sql :: grouping function in mysql 
Sql :: sql workbench 
Sql :: suse start MySQL 
Sql :: sql out file formate 
Sql :: sql cheetsheet 
Sql :: DAX Code Snippet To Seclect Top Rows In Query 
Sql :: i wanted to select among the rows the highest value in mysql 
Sql :: odata expand and $select only column values 
Sql :: to_sql id colymn 
Sql :: check psql validity function 
Sql :: Enable outgoing remote MySQL access 
Sql :: mysql-split-and-join-the-values 
Sql :: sql case 1 add a string 
Sql :: psql check table fields 
Sql :: how to view full conversation with chat.db 
Sql :: row_number equivalent MS Access for sequential id By Group 
Sql :: SQL: find gap in sequence 
Sql :: how to know if table in rigt or left in sql 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =