Is there a goo开发者_开发问答d PHP Class to export data from mysql to XLS file?
It's very easy to do this using the PHPExcel library. It won't read the database for you; but you can easily write a script that reads the database, then build up a worksheet as you loop through the rows.
EDIT
Read the documentation, look at the example code:
require_once './Classes/PHPExcel.php';
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC";
if ($result = $mysqli->query($query)) {
// Create a new PHPExcel object
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->setTitle('List of Cities');
// Loop through the result set
$rowNumber = 1;
while ($row = $result->fetch_row()) {
$objPHPExcel->getActiveSheet()->fromArray($row,NULL,'A'.$rowNumber++);
}
// Save as an Excel BIFF (xls) file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('CityList.xls');
}
phpMyAdmin is a PHP based mySQL interface that supports exporting to Excel. It's an application and not a standalone class, though.
精彩评论