Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of fridayana baabullah  >  PEAR WorkBook Helper  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Sample Usage
Class: PEAR WorkBook Helper
Generate an Excel spreadsheet with MySQL results
Author: By
Last change: memotong comment menjadi 2 baris
Date: 2011-01-08 13:33
Size: 920 bytes
 

Contents

Class file image Download
<?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();