<?php
require_once 'anysqltoexcel.php';
$sqlSheetList = array(
WorkbookUtil::createSqlSheet('Sheet 1', "select * from table1"),
WorkbookUtil::createSqlSheet('Sheet 2', "select field1, field2 from table2 where field2 = 'x' order by field2 limit 0,50"),
WorkbookUtil::createSqlSheet('Sheet Tiga', "select count(field) as jumlah from table3")
);
// Anda dapat membuat implementasi SqlExplorer sendiri misalnya untuk oracle.
// Kami hanya menyediakan contoh implementasi SqlExplorer untuk mysql
$sqlExplorer = new MysqlSqlExplorer('localhost', 'root', 's3cr3tp455w0rd', 'dbname');
$writerCallback = new DefaultWriterCallback();
$pearWorkBookHelper = new PearWorkBookHelper();
$pearWorkBookHelper->setSqlExplorer($sqlExplorer);
$pearWorkBookHelper->setWriterCallback($writerCallback);
$workbook =& $pearWorkBookHelper->createWorkBook($sqlSheetList);
$workbook->send('test.xls');
$workbook->close();
|